This is an automated email from the ASF dual-hosted git repository.

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git

commit d38b17c046b889b1457ca83b071bcc467a4dec02
Author: Martin Desruisseaux <martin.desruisse...@geomatys.com>
AuthorDate: Fri Jun 30 10:46:13 2023 +0200

    Add a placeholder for a JAXB adapter for expressions,
    then verifies that current JAXB annotations are valid.
---
 core/sis-portrayal/pom.xml                         |  5 ++
 .../java/org/apache/sis/style/se1/ElseFilter.java  | 51 ++++++++++++++++
 .../apache/sis/style/se1/ExpressionAdapter.java    | 50 +++++++++++++++
 .../main/java/org/apache/sis/style/se1/Rule.java   | 15 +++++
 .../org/apache/sis/style/se1/package-info.java     | 71 ++++++++++++++++++++++
 .../java/org/apache/sis/style/se1/XmlTest.java     | 50 +++++++++++++++
 6 files changed, 242 insertions(+)

diff --git a/core/sis-portrayal/pom.xml b/core/sis-portrayal/pom.xml
index 521d22b4f7..d599f2e4fe 100644
--- a/core/sis-portrayal/pom.xml
+++ b/core/sis-portrayal/pom.xml
@@ -141,6 +141,11 @@
       <type>test-jar</type>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.glassfish.jaxb</groupId>
+      <artifactId>jaxb-runtime</artifactId>
+      <scope>test</scope>
+    </dependency>
   </dependencies>
 
 </project>
diff --git 
a/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/ElseFilter.java 
b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/ElseFilter.java
new file mode 100644
index 0000000000..a6e4fce3f5
--- /dev/null
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/ElseFilter.java
@@ -0,0 +1,51 @@
+/*
+ * 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.sis.style.se1;
+
+import jakarta.xml.bind.annotation.XmlType;
+import jakarta.xml.bind.annotation.XmlRootElement;
+
+
+/**
+ * The element to marshall when no other rule matches the conditions.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.5
+ * @since   1.5
+ */
+@XmlType(name = "ElseFilterType")
+@XmlRootElement(name = "ElseFilter")
+final class ElseFilter {
+    /**
+     * The singleton instance.
+     */
+    static final ElseFilter INSTANCE = new ElseFilter();
+
+    /**
+     * Creates the singleton instance.
+     */
+    private ElseFilter() {
+    }
+
+    /**
+     * Returns a string representation of this element.
+     */
+    @Override
+    public String toString() {
+        return "ElseFilter";
+    }
+}
diff --git 
a/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/ExpressionAdapter.java
 
b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/ExpressionAdapter.java
new file mode 100644
index 0000000000..97d24dfbaf
--- /dev/null
+++ 
b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/ExpressionAdapter.java
@@ -0,0 +1,50 @@
+/*
+ * 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.sis.style.se1;
+
+import jakarta.xml.bind.annotation.adapters.XmlAdapter;
+
+// Branch-dependent imports
+import org.opengis.feature.Feature;
+import org.opengis.filter.Expression;
+
+
+/**
+ * Adapter for expression in style.
+ * This is a place-holder for future work.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.5
+ * @since   1.5
+ */
+final class ExpressionAdapter extends XmlAdapter<String, 
Expression<Feature,?>> {
+    /**
+     * Creates an adapter.
+     */
+    public ExpressionAdapter() {
+    }
+
+    @Override
+    public String marshal(Expression<Feature,?> value) {
+        return null;
+    }
+
+    @Override
+    public Expression<Feature,?> unmarshal(String value) {
+        return null;
+    }
+}
diff --git 
a/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/Rule.java 
b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/Rule.java
index 8d72197b73..dd376e43ea 100644
--- a/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/Rule.java
+++ b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/Rule.java
@@ -281,6 +281,21 @@ public class Rule<R> extends StyleElement {
         isElseFilter = value;
     }
 
+    /**
+     * Invoked by JAXB at marshalling time for expressing the boolean {@code 
isElseFilter} value as an XML element.
+     */
+    @XmlElement(name = "ElseFilter")
+    private ElseFilter getElseFilter() {
+        return isElseFilter ? ElseFilter.INSTANCE : null;
+    }
+
+    /**
+     * Invoked at JAXB unmarshalling time when an {@code <ElseFilter/>} 
element is found.
+     */
+    private void setElseFilter(final ElseFilter value) {
+        isElseFilter = (value != null);
+    }
+
     /**
      * Returns the minimum value (inclusive) in the denominator of map scale 
at which this rule will apply.
      * If, for example, this value was 10000, then this rule would only apply 
at scales of 1:<var>X</var>
diff --git 
a/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/package-info.java 
b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/package-info.java
new file mode 100644
index 0000000000..d70474e0f3
--- /dev/null
+++ 
b/core/sis-portrayal/src/main/java/org/apache/sis/style/se1/package-info.java
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+
+/**
+ * Symbology encoding for styling map data independently of their source.
+ * The classes in this package are derived from
+ * OGC 05-077r4 — <a href="https://www.ogc.org/standard/se/";>Symbology 
Encoding</a> Implementation Specification 1.1.0.
+ * That document defines an XML encoding that can be used for styling feature 
and coverage data.
+ * The root elements are
+ * {@link org.apache.sis.style.se1.FeatureTypeStyle} and
+ * {@link org.apache.sis.style.se1.CoverageStyle}.
+ * Those classes include different kinds of {@link 
org.apache.sis.style.se1.Symbolizer}.
+ *
+ * @todo Add {@code CoverageStyle}. May require a common parent with {@code 
FeatureTypeStyle}.
+ *
+ * <h2>Future evolution</h2>
+ * This package defines a XML encoding.
+ * It is not an abstract model for sophisticated styling.
+ * Apache SIS temporarily uses the classes of the XML encoding as a style API,
+ * but a future version may replace this API by a more abstract one.
+ * A good candidate may be ISO 19117:2012 — Portrayal.
+ * As of 2023, various OGC working groups are also working on new style API.
+ * The final form of such API has not yet been settled down.
+ *
+ * <h2>Synchronization</h2>
+ * Classes in this package are not thread-safe.
+ * Synchronization, if desired, must be done by the caller.
+ *
+ * @author  Johann Sorel (Geomatys)
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.5
+ * @since   1.5
+ */
+@XmlSchema(location="https://schemas.opengis.net/se/1.1.0/FeatureStyle.xsd";,
+           elementFormDefault=XmlNsForm.QUALIFIED, namespace=Namespaces.SE,
+           xmlns = {
+                @XmlNs(prefix = "se", namespaceURI = Namespaces.SE)
+})
+@XmlAccessorType(XmlAccessType.NONE)
+@XmlJavaTypeAdapters({
+    @XmlJavaTypeAdapter(ExpressionAdapter.class),
+    @XmlJavaTypeAdapter(InternationalStringConverter.class),
+    @XmlJavaTypeAdapter(UnitAdapter.class)
+})
+package org.apache.sis.style.se1;
+
+import jakarta.xml.bind.annotation.XmlAccessType;
+import jakarta.xml.bind.annotation.XmlAccessorType;
+import jakarta.xml.bind.annotation.XmlNs;
+import jakarta.xml.bind.annotation.XmlNsForm;
+import jakarta.xml.bind.annotation.XmlSchema;
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
+import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapters;
+import org.apache.sis.internal.jaxb.gco.InternationalStringConverter;
+import org.apache.sis.internal.jaxb.gco.UnitAdapter;
+import org.apache.sis.xml.Namespaces;
diff --git 
a/core/sis-portrayal/src/test/java/org/apache/sis/style/se1/XmlTest.java 
b/core/sis-portrayal/src/test/java/org/apache/sis/style/se1/XmlTest.java
new file mode 100644
index 0000000000..e3a72d8b48
--- /dev/null
+++ b/core/sis-portrayal/src/test/java/org/apache/sis/style/se1/XmlTest.java
@@ -0,0 +1,50 @@
+/*
+ * 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.sis.style.se1;
+
+import jakarta.xml.bind.JAXBContext;
+import jakarta.xml.bind.JAXBException;
+import org.apache.sis.test.TestCase;
+import org.junit.Test;
+
+
+/**
+ * Test of XML marshalling.
+ * The current version only verifies that {@link JAXBContext} can be created.
+ * We do not yet have sufficient JAXB annotations and adapters for real 
marshalling.
+ *
+ * @author  Martin Desruisseaux (Geomatys)
+ * @version 1.5
+ * @since   1.5
+ */
+public final class XmlTest extends TestCase {
+    /**
+     * Creates a new test case.
+     */
+    public XmlTest() {
+    }
+
+    /**
+     * Tests the creation of a JAXB context.
+     *
+     * @throws JAXBException if some invalid annotations were found.
+     */
+    @Test
+    public void testContext() throws JAXBException {
+        JAXBContext.newInstance(Symbolizer.class);
+    }
+}

Reply via email to