Skip to content

Commit 31a941c

Browse files
committed
PDFBOX-6133: refactor
git-svn-id: https://svn.apache.org/repos/asf/pdfbox/trunk@1930943 13f79535-47bb-0310-9956-ffa450edef68
1 parent c3dc8be commit 31a941c

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

xmpbox/src/main/java/org/apache/xmpbox/xml/DomXmpParser.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ private void parseSchemaExtensions(final XMPMetadata xmp, final Element descript
292292
throw new XmpParsingException(ErrorType.NoSchema,
293293
"This namespace is not from a schema: " + namespace);
294294
}
295-
PropertyType type = checkPropertyDefinition(xmp, DomHelper.getQName(schemaExtension), null);
295+
PropertyType type = checkPropertyDefinition(tm, DomHelper.getQName(schemaExtension), null);
296296
final XMPSchema schema = tm.getSchemaFactory(namespace).createXMPSchema(xmp, schemaExtension.getPrefix());
297297
loadAttributes(schema, description);
298298
ComplexPropertyContainer container = schema.getContainer();
@@ -368,7 +368,7 @@ private void parseDescriptionRootAttr(XMPMetadata xmp, Element description, Attr
368368
if( schema != null )
369369
{
370370
ComplexPropertyContainer container = schema.getContainer();
371-
PropertyType type = checkPropertyDefinition(xmp,
371+
PropertyType type = checkPropertyDefinition(tm,
372372
new QName(attr.getNamespaceURI(), attr.getLocalName(), attr.getPrefix()), null);
373373

374374
if (type == null)
@@ -426,7 +426,7 @@ private void parseChildrenAsProperties(XMPMetadata xmp, List<Element> properties
426426
{
427427
nsFinder.push(property);
428428
String namespace = property.getNamespaceURI();
429-
PropertyType type = checkPropertyDefinition(xmp, DomHelper.getQName(property), null);
429+
PropertyType type = checkPropertyDefinition(tm, DomHelper.getQName(property), null);
430430
// create the container
431431
if (!tm.isDefinedSchema(namespace))
432432
{
@@ -662,7 +662,7 @@ private void parseDescriptionInner(XMPMetadata xmp, Element description, Complex
662662
for (Element property : properties)
663663
{
664664
String name = property.getLocalName();
665-
PropertyType dtype = checkPropertyDefinition(xmp, DomHelper.getQName(property), null);
665+
PropertyType dtype = checkPropertyDefinition(tm, DomHelper.getQName(property), null);
666666
PropertyType ptype = tm.getStructuredPropMapping(dtype.type()).getPropertyType(name);
667667
// create property
668668
createProperty(xmp, property, ptype, parentContainer);
@@ -739,7 +739,7 @@ private AbstractField parseLiElement(XMPMetadata xmp, QName descriptor, Element
739739
{
740740
pm = tm.getDefinedDescriptionByNamespace(liElement.getNamespaceURI(), liElement.getLocalName());
741741
}
742-
af = tryParseAttributesAsProperties(xmp, liElement, tm, (AbstractStructuredType) af, pm, null);
742+
af = tryParseAttributesAsProperties(tm, liElement, (AbstractStructuredType) af, pm, null);
743743
}
744744
return af;
745745
}
@@ -783,7 +783,7 @@ private AbstractStructuredType parseLiDescription(XMPMetadata xmp, QName parentQ
783783
if (liDescriptionElementChildren.isEmpty())
784784
{
785785
// The list is empty
786-
return tryParseAttributesAsProperties(xmp, liDescriptionElement, tm, null, null, parentQName);
786+
return tryParseAttributesAsProperties(tm, liDescriptionElement, null, null, parentQName);
787787
}
788788
Element firstLiDescriptionElementChild = liDescriptionElementChildren.get(0);
789789
if ("rdf:Description".equals(firstLiDescriptionElementChild.getTagName()))
@@ -794,7 +794,7 @@ private AbstractStructuredType parseLiDescription(XMPMetadata xmp, QName parentQ
794794
// Instantiate abstract structured type with hint from first element
795795
nsFinder.push(firstLiDescriptionElementChild);
796796
QName firstChildQName = DomHelper.getQName(firstLiDescriptionElementChild);
797-
PropertyType ctype = checkPropertyDefinition(xmp, firstChildQName, parentQName.getLocalPart());
797+
PropertyType ctype = checkPropertyDefinition(tm, firstChildQName, parentQName.getLocalPart());
798798
if (ctype == null)
799799
{
800800
// PDFBOX-5649
@@ -883,7 +883,7 @@ else if (type.type().isStructured())
883883
}
884884

885885
}
886-
ast = tryParseAttributesAsProperties(xmp, liDescriptionElement, tm, ast, pm, parentQName);
886+
ast = tryParseAttributesAsProperties(tm, liDescriptionElement, ast, pm, parentQName);
887887
nsFinder.pop();
888888
return ast;
889889
}
@@ -1108,9 +1108,8 @@ else if (type.isDefined())
11081108
}
11091109
}
11101110

1111-
private PropertyType checkPropertyDefinition(XMPMetadata xmp, QName qName, String parentTypeName) throws XmpParsingException
1111+
private PropertyType checkPropertyDefinition(TypeMapping tm, QName qName, String parentTypeName) throws XmpParsingException
11121112
{
1113-
TypeMapping tm = xmp.getTypeMapping();
11141113
// test if namespace is set in xml
11151114
String nsuri = qName.getNamespaceURI();
11161115
if (!nsFinder.containsNamespace(nsuri))
@@ -1140,18 +1139,18 @@ private PropertyType checkPropertyDefinition(XMPMetadata xmp, QName qName, Strin
11401139
* parseDescriptionRootAttr(). This solves the problem in PDFBOX-3882 where properties appear as
11411140
* attributes in places lower than the descriptor root.
11421141
*
1143-
* @param xmp
1144-
* @param liElement
11451142
* @param tm
1143+
* @param liElement
11461144
* @param ast An AbstractStructuredType object, can be null.
11471145
* @param pm A PropertiesDescription object, must be set if ast is not null.
1148-
* @param qName QName of the parent, will be used if instanciating an AbstractStructuredType
1146+
* @param qName QName of the parent, will be used if instantiating an AbstractStructuredType
11491147
* object, must be set if ast is not null.
11501148
* @return An AbstractStructuredType, possibly created here if it was null as parameter.
11511149
* @throws XmpParsingException
11521150
*/
1153-
private AbstractStructuredType tryParseAttributesAsProperties(XMPMetadata xmp, Element liElement,
1154-
TypeMapping tm, AbstractStructuredType ast, PropertiesDescription pm, QName qName) throws XmpParsingException
1151+
private AbstractStructuredType tryParseAttributesAsProperties(
1152+
TypeMapping tm, Element liElement, AbstractStructuredType ast,
1153+
PropertiesDescription pm, QName qName) throws XmpParsingException
11551154
{
11561155
NamedNodeMap attributes = liElement.getAttributes();
11571156
if (attributes == null)
@@ -1185,7 +1184,7 @@ else if (XmpConstants.DEFAULT_RDF_PREFIX.equals(attr.getPrefix()))
11851184
// like in parseLiDescription():
11861185
// Instantiate abstract structured type with hint from first element
11871186
QName attrQName = new QName(attr.getNamespaceURI(), attr.getLocalName(), attr.getPrefix());
1188-
PropertyType ctype = checkPropertyDefinition(xmp, attrQName, null);
1187+
PropertyType ctype = checkPropertyDefinition(tm, attrQName, null);
11891188
// this is the type of the AbstractStructuredType, not of the element(s)
11901189
if (ctype == null)
11911190
{

0 commit comments

Comments
 (0)