This is an automated email from the ASF dual-hosted git repository. sseifert pushed a commit to branch feature/SLING-12281-parent-60 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git
commit fbd204302edd7f5c27be5199b20b5795e2398337 Author: Stefan Seifert <[email protected]> AuthorDate: Tue Apr 9 10:33:21 2024 +0200 SLING-12281 apply spotless code formatting --- pom.xml | 32 ++++++------ .../xml/internal/XMLContentParser.java | 58 ++++++++++------------ .../xml/internal/XMLContentParserTest.java | 55 ++++++++++---------- 3 files changed, 72 insertions(+), 73 deletions(-) diff --git a/pom.xml b/pom.xml index f04d783..8d4b9a0 100644 --- a/pom.xml +++ b/pom.xml @@ -1,4 +1,4 @@ -<?xml version="1.0" encoding="ISO-8859-1"?> +<?xml version="1.0" encoding="UTF-8"?> <!-- Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file @@ -30,29 +30,15 @@ <version>2.0.1-SNAPSHOT</version> <name>Apache Sling Content Parser for XML</name> - <description> - Apache Sling Content Parser for resource trees stored in XML files - </description> + <description>Apache Sling Content Parser for resource trees stored in XML files</description> <scm> <connection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git</connection> <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/sling-org-apache-sling-contentparser-xml.git</developerConnection> - <url>https://github.com/apache/sling-org-apache-sling-contentparser-xml.git</url> <tag>HEAD</tag> + <url>https://github.com/apache/sling-org-apache-sling-contentparser-xml.git</url> </scm> - <build> - <plugins> - <plugin> - <groupId>biz.aQute.bnd</groupId> - <artifactId>bnd-baseline-maven-plugin</artifactId> - <configuration> - <failOnMissing>false</failOnMissing> - </configuration> - </plugin> - </plugins> - </build> - <dependencies> <dependency> <groupId>org.apache.sling</groupId> @@ -83,4 +69,16 @@ <scope>test</scope> </dependency> </dependencies> + + <build> + <plugins> + <plugin> + <groupId>biz.aQute.bnd</groupId> + <artifactId>bnd-baseline-maven-plugin</artifactId> + <configuration> + <failOnMissing>false</failOnMissing> + </configuration> + </plugin> + </plugins> + </build> </project> diff --git a/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java b/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java index 7a9612e..6776b44 100644 --- a/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java +++ b/src/main/java/org/apache/sling/contentparser/xml/internal/XMLContentParser.java @@ -1,23 +1,27 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.sling.contentparser.xml.internal; +import javax.xml.XMLConstants; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + import java.io.IOException; import java.io.InputStream; import java.math.BigDecimal; @@ -26,10 +30,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import javax.xml.XMLConstants; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; - import org.apache.commons.lang3.StringUtils; import org.apache.sling.contentparser.api.ContentHandler; import org.apache.sling.contentparser.api.ContentParser; @@ -45,11 +45,7 @@ import org.w3c.dom.NodeList; * Parses XML files that contains content fragments. * Instance of this class is thread-safe. */ -@Component( - property = { - ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=xml" - } -) +@Component(property = {ContentParser.SERVICE_PROPERTY_CONTENT_TYPE + "=xml"}) public final class XMLContentParser implements ContentParser { private static final String JCR_PRIMARY_TYPE = "jcr:primaryType"; @@ -79,7 +75,8 @@ public final class XMLContentParser implements ContentParser { } } - private void parse(ContentHandler handler, Element element, ParserOptions parserOptions, String parentPath) throws IOException { + private void parse(ContentHandler handler, Element element, ParserOptions parserOptions, String parentPath) + throws IOException { // build node path String path; if (parentPath == null) { @@ -99,7 +96,8 @@ public final class XMLContentParser implements ContentParser { // primary node type and mixins String primaryType = getChildText(element, "primaryNodeType"); - if (StringUtils.isNotBlank(primaryType) && !parserOptions.getIgnorePropertyNames().contains(JCR_PRIMARY_TYPE)) { + if (StringUtils.isNotBlank(primaryType) + && !parserOptions.getIgnorePropertyNames().contains(JCR_PRIMARY_TYPE)) { properties.put(JCR_PRIMARY_TYPE, primaryType); } String[] mixins = getChildTextArray(element, "mixinNodeType"); @@ -155,7 +153,6 @@ public final class XMLContentParser implements ContentParser { for (Element node : nodeElements) { parse(handler, node, parserOptions, path); } - } private List<Element> getChildren(Element element, String childName) { @@ -225,5 +222,4 @@ public final class XMLContentParser implements ContentParser { } return ParserHelper.convertSingleTypeArray(result); } - } diff --git a/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java b/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java index a801746..0709249 100644 --- a/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java +++ b/src/test/java/org/apache/sling/contentparser/xml/internal/XMLContentParserTest.java @@ -1,21 +1,21 @@ -/*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - ~ Licensed to the Apache Software Foundation (ASF) under one - ~ or more contributor license agreements. See the NOTICE file - ~ distributed with this work for additional information - ~ regarding copyright ownership. The ASF licenses this file - ~ to you under the Apache License, Version 2.0 (the - ~ "License"); you may not use this file except in compliance - ~ with the License. You may obtain a copy of the License at - ~ - ~ http://www.apache.org/licenses/LICENSE-2.0 - ~ - ~ Unless required by applicable law or agreed to in writing, - ~ software distributed under the License is distributed on an - ~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - ~ KIND, either express or implied. See the License for the - ~ specific language governing permissions and limitations - ~ under the License. - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ package org.apache.sling.contentparser.xml.internal; import java.io.File; @@ -70,9 +70,10 @@ public class XMLContentParserTest { assertEquals(new BigDecimal("1.2345"), props.get("decimalProp")); assertEquals(true, props.get("booleanProp")); - assertArrayEquals(new Long[]{1234567890123L, 55L}, (Long[]) props.get("longPropMulti")); - assertArrayEquals(new BigDecimal[]{new BigDecimal("1.2345"), new BigDecimal("1.1")}, (BigDecimal[]) props.get("decimalPropMulti")); - assertArrayEquals(new Boolean[]{true, false}, (Boolean[]) props.get("booleanPropMulti")); + assertArrayEquals(new Long[] {1234567890123L, 55L}, (Long[]) props.get("longPropMulti")); + assertArrayEquals(new BigDecimal[] {new BigDecimal("1.2345"), new BigDecimal("1.1")}, (BigDecimal[]) + props.get("decimalPropMulti")); + assertArrayEquals(new Boolean[] {true, false}, (Boolean[]) props.get("booleanPropMulti")); } @Test @@ -132,9 +133,14 @@ public class XMLContentParserTest { @Test public void testIgnoreResourcesProperties() throws Exception { - ContentElement content = TestUtils.parse(underTest, - new ParserOptions().ignoreResourceNames(Collections.unmodifiableSet(new HashSet<>(Arrays.asList("header", "newslist")))) - .ignorePropertyNames(Collections.unmodifiableSet(new HashSet<>(Collections.singletonList("jcr:title")))), file); + ContentElement content = TestUtils.parse( + underTest, + new ParserOptions() + .ignoreResourceNames( + Collections.unmodifiableSet(new HashSet<>(Arrays.asList("header", "newslist")))) + .ignorePropertyNames( + Collections.unmodifiableSet(new HashSet<>(Collections.singletonList("jcr:title")))), + file); ContentElement child = content.getChild("jcr:content"); assertNotNull("Expected child at jcr:content", child); Map<String, Object> props = child.getProperties(); @@ -166,5 +172,4 @@ public class XMLContentParserTest { invalidChild = content.getChild("/jcr:content"); assertNull(invalidChild); } - }
