Commit 38715130 authored by Matthias Betz's avatar Matthias Betz
Browse files

Merge branch 'citygml3'

parents 6cf1abce bd8f73de
Pipeline #7210 passed with stage
in 7 seconds
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed 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 de.hft.stuttgart.quality.adapter.properties;
import de.hft.stuttgart.quality.model.properties.PolygonIdListProperty;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlinePropertyAdapter;
import javax.xml.namespace.QName;
public class PolygonIdListPropertyAdapter extends AbstractInlinePropertyAdapter<PolygonIdListProperty> {
@Override
public PolygonIdListProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new PolygonIdListProperty();
}
}
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed 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 de.hft.stuttgart.quality.adapter.properties;
import de.hft.stuttgart.quality.model.properties.RequirementProperty;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlinePropertyAdapter;
import javax.xml.namespace.QName;
public class RequirementPropertyAdapter extends AbstractInlinePropertyAdapter<RequirementProperty> {
@Override
public RequirementProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new RequirementProperty();
}
}
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed 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 de.hft.stuttgart.quality.adapter.properties;
import de.hft.stuttgart.quality.model.properties.StatisticsProperty;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlinePropertyAdapter;
import javax.xml.namespace.QName;
public class StatisticsPropertyAdapter extends AbstractInlinePropertyAdapter<StatisticsProperty> {
@Override
public StatisticsProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new StatisticsProperty();
}
}
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed 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 de.hft.stuttgart.quality.adapter.properties;
import de.hft.stuttgart.quality.model.properties.ValidationPlanProperty;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlinePropertyAdapter;
import javax.xml.namespace.QName;
public class ValidationPlanPropertyAdapter extends AbstractInlinePropertyAdapter<ValidationPlanProperty> {
@Override
public ValidationPlanProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new ValidationPlanProperty();
}
}
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed 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 de.hft.stuttgart.quality.adapter.properties;
import javax.xml.namespace.QName;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlineOrByReferencePropertyAdapter;
import de.hft.stuttgart.quality.model.properties.ValidationProperty;
public class ValidationPropertyAdapter extends AbstractInlineOrByReferencePropertyAdapter<ValidationProperty> {
@Override
public ValidationProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new ValidationProperty();
}
}
/*-
* Copyright 2022 Hochschule für Technik Stuttgart
*
* Licensed 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 de.hft.stuttgart.quality.adapter.properties;
import javax.xml.namespace.QName;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.base.AbstractInlineOrByReferencePropertyAdapter;
import de.hft.stuttgart.quality.model.properties.ValidationResultProperty;
public class ValidationResultPropertyAdapter
extends AbstractInlineOrByReferencePropertyAdapter<ValidationResultProperty> {
@Override
public ValidationResultProperty createObject(QName name, Object parent) throws ObjectBuildException {
return new ValidationResultProperty();
}
}
package de.hft.stuttgart.quality.adapter.types;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializer;
import de.hft.stuttgart.quality.model.types.AbstractError;
public abstract class AbstractErrorAdapter<T extends AbstractError> implements ObjectBuilder<T>, ObjectSerializer<T> {
}
package de.hft.stuttgart.quality.adapter.types;
import de.hft.stuttgart.quality.model.types.AbstractGeometryError;
public abstract class AbstractGeometryErrorAdapter<T extends AbstractGeometryError> extends AbstractErrorAdapter<T> {
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.AbstractPolygonError;
public abstract class AbstractPolygonErrorAdapter<T extends AbstractPolygonError>
extends AbstractGeometryErrorAdapter<T> {
@Override
public void buildChildObject(AbstractPolygonError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "polygonId":
reader.getTextContent().ifPresent(object::setPolygonId);
break;
default:
throw new IllegalStateException(
"Cannot handle name " + name + " when building AbstractPolygonError element");
}
}
@Override
public void writeChildElements(AbstractPolygonError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getPolygonId() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "polygonId").addTextContent(object.getPolygonId()));
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.AbstractRingError;
public abstract class AbstractRingErrorAdapter<T extends AbstractRingError> extends AbstractGeometryErrorAdapter<T> {
@Override
public void buildChildObject(AbstractRingError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "linearRingId":
reader.getTextContent().ifPresent(object::setLinearRingId);
break;
}
}
@Override
public void writeChildElements(AbstractRingError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getLinearRingId() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "linearRingId")
.addTextContent(object.getLinearRingId()));
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import de.hft.stuttgart.quality.model.types.AbstractSemanticError;
public abstract class AbstractSemanticErrorAdapter<T extends AbstractSemanticError> extends AbstractErrorAdapter<T> {
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.AbstractSolidError;
public abstract class AbstractSolidErrorAdapter<T extends AbstractSolidError> extends AbstractGeometryErrorAdapter<T> {
@Override
public void buildChildObject(AbstractSolidError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "geometryId":
reader.getTextContent().ifPresent(object::setGeometryId);
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building AbstractSolidError element");
}
}
@Override
public void writeChildElements(AbstractSolidError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getGeometryId() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "geometryId").addTextContent(object.getGeometryId()));
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.AllPolygonsOrientedWrongError;
@XMLElement(name = "GE_S_ALL_POLYGONS_WRONG_ORIENTATION", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class AllPolygonsOrientedWrongErrorAdapter extends AbstractSolidErrorAdapter<AllPolygonsOrientedWrongError> {
@Override
public AllPolygonsOrientedWrongError createObject(QName name, Object parent) throws ObjectBuildException {
return new AllPolygonsOrientedWrongError();
}
@Override
public Element createElement(AllPolygonsOrientedWrongError object, Namespaces namespaces)
throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_S_ALL_POLYGONS_WRONG_ORIENTATION");
}
}
package de.hft.stuttgart.quality.adapter.types;
import de.hft.stuttgart.quality.model.enums.TopLevelFeatureType;
import de.hft.stuttgart.quality.model.types.Checking;
import de.hft.stuttgart.quality.QualityADEModule;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import javax.xml.namespace.QName;
@XMLElement(name = "Checking", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class CheckingAdapter implements ObjectBuilder<Checking>, ObjectSerializer<Checking> {
@Override
public Checking createObject(QName name, Object parent) throws ObjectBuildException {
return new Checking();
}
@Override
public void buildChildObject(Checking object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "featureType":
reader.getTextContent().ifPresent(s -> object.setFeatureType(TopLevelFeatureType.valueOf(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Checking element");
}
}
@Override
public Element createElement(Checking object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Checking");
}
@Override
public void writeChildElements(Checking object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getFeatureType() != null) {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "featureType")
.addTextContent(object.getFeatureType().toString()));
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.ValidationResultPropertyAdapter;
import de.hft.stuttgart.quality.model.types.CityObjectProperties;
@XMLElement(name = "validationResult", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class CityObjectPropertiesAdapter
implements ObjectBuilder<CityObjectProperties>, ObjectSerializer<CityObjectProperties> {
@Override
public CityObjectProperties createObject(QName name, Object parent) throws ObjectBuildException {
return new CityObjectProperties();
}
@Override
public void buildChildObject(CityObjectProperties object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "ValidationResult":
object.setValidationResult(reader.getObjectUsingBuilder(ValidationResultPropertyAdapter.class));
break;
default:
throw new IllegalStateException(
"Cannot handle name " + name + " when building CityObjectProperties element");
}
}
@Override
public void writeChildElements(CityObjectProperties object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getValidationResult() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "validationResult"),
object.getValidationResult(), ValidationResultPropertyAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.gml.adapter.geometry.DirectPositionAdapter;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.ConsecutivePointsSameError;
@XMLElement(name = "GE_R_CONSECUTIVE_POINTS_SAME", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ConsecutivePointsSameErrorAdapter extends AbstractRingErrorAdapter<ConsecutivePointsSameError> {
@Override
public ConsecutivePointsSameError createObject(QName name, Object parent) throws ObjectBuildException {
return new ConsecutivePointsSameError();
}
@Override
public void buildChildObject(ConsecutivePointsSameError object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "vertex1":
object.setVertex1(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
case "vertex2":
object.setVertex2(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
default:
super.buildChildObject(object, name, attributes, reader);
}
}
@Override
public Element createElement(ConsecutivePointsSameError object, Namespaces namespaces)
throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "GE_R_CONSECUTIVE_POINTS_SAME");
}
@Override
public void writeChildElements(ConsecutivePointsSameError object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
super.writeChildElements(object, namespaces, writer);
if (object.getVertex1() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "vertex1"),
object.getVertex1(), DirectPositionAdapter.class, namespaces);
}
if (object.getVertex2() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "vertex2"),
object.getVertex2(), DirectPositionAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.gml.adapter.geometry.DirectPositionAdapter;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.types.Edge;
@XMLElement(name = "Edge", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class EdgeAdapter implements ObjectBuilder<Edge>, ObjectSerializer<Edge> {
@Override
public Edge createObject(QName name, Object parent) throws ObjectBuildException {
return new Edge();
}
@Override
public void buildChildObject(Edge object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "from":
object.setFrom(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
case "to":
object.setTo(reader.getObjectUsingBuilder(DirectPositionAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Edge element");
}
}
@Override
public Element createElement(Edge object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Edge");
}
@Override
public void writeChildElements(Edge object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
if (object.getFrom() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "from"), object.getFrom(),
DirectPositionAdapter.class, namespaces);
}
if (object.getTo() != null) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "to"), object.getTo(),
DirectPositionAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.adapter.properties.EdgePropertyAdapter;
import de.hft.stuttgart.quality.model.properties.EdgeProperty;
import de.hft.stuttgart.quality.model.types.EdgeList;
@XMLElement(name = "EdgeList", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class EdgeListAdapter implements ObjectBuilder<EdgeList>, ObjectSerializer<EdgeList> {
@Override
public EdgeList createObject(QName name, Object parent) throws ObjectBuildException {
return new EdgeList();
}
@Override
public void buildChildObject(EdgeList object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "edge":
object.getEdges().add(reader.getObjectUsingBuilder(EdgePropertyAdapter.class));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building EdgeList element");
}
}
@Override
public Element createElement(EdgeList object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "EdgeList");
}
@Override
public void writeChildElements(EdgeList object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
for (EdgeProperty edgeProp : object.getEdges()) {
writer.writeElementUsingSerializer(Element.of(QualityADEModule.NAMESPACE_URI, "edge"), edgeProp,
EdgePropertyAdapter.class, namespaces);
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import javax.xml.namespace.QName;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import de.hft.stuttgart.quality.QualityADEModule;
import de.hft.stuttgart.quality.model.enums.ErrorId;
import de.hft.stuttgart.quality.model.types.Error;
@XMLElement(name = "Error", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class ErrorAdapter implements ObjectBuilder<Error>, ObjectSerializer<Error> {
@Override
public Error createObject(QName name, Object parent) throws ObjectBuildException {
return new Error();
}
@Override
public void buildChildObject(Error object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "occurrences":
reader.getTextContent().ifPresent(s -> object.setOccurrences(Integer.parseInt(s)));
break;
case "name":
reader.getTextContent().ifPresent(s -> object.setName(ErrorId.valueOf(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building Error element");
}
}
@Override
public Element createElement(Error object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "Error");
}
@Override
public void writeChildElements(Error object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "occurrences")
.addTextContent(Integer.toString(object.getOccurrences())));
if (object.getName() != null) {
writer.writeElement(
Element.of(QualityADEModule.NAMESPACE_URI, "name").addTextContent(object.getName().toString()));
}
}
}
package de.hft.stuttgart.quality.adapter.types;
import de.hft.stuttgart.quality.model.types.FeatureStatistics;
import de.hft.stuttgart.quality.QualityADEModule;
import org.xmlobjects.annotation.XMLElement;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.serializer.ObjectSerializeException;
import org.xmlobjects.serializer.ObjectSerializer;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import org.xmlobjects.stream.XMLWriteException;
import org.xmlobjects.stream.XMLWriter;
import org.xmlobjects.xml.Attributes;
import org.xmlobjects.xml.Element;
import org.xmlobjects.xml.Namespaces;
import javax.xml.namespace.QName;
@XMLElement(name = "FeatureStatistics", namespaceURI = QualityADEModule.NAMESPACE_URI)
public class FeatureStatisticsAdapter implements ObjectBuilder<FeatureStatistics>, ObjectSerializer<FeatureStatistics> {
@Override
public FeatureStatistics createObject(QName name, Object parent) throws ObjectBuildException {
return new FeatureStatistics();
}
@Override
public void buildChildObject(FeatureStatistics object, QName name, Attributes attributes, XMLReader reader)
throws ObjectBuildException, XMLReadException {
if (!QualityADEModule.NAMESPACE_URI.equals(name.getNamespaceURI())) {
return;
}
switch (name.getLocalPart()) {
case "numChecked":
reader.getTextContent().ifPresent(s -> object.setNumChecked(Integer.parseInt(s)));
break;
case "numErrors":
reader.getTextContent().ifPresent(s -> object.setNumErrors(Integer.parseInt(s)));
break;
default:
throw new IllegalStateException("Cannot handle name " + name + " when building FeatureStatistics element");
}
}
@Override
public Element createElement(FeatureStatistics object, Namespaces namespaces) throws ObjectSerializeException {
return Element.of(QualityADEModule.NAMESPACE_URI, "FeatureStatistics");
}
@Override
public void writeChildElements(FeatureStatistics object, Namespaces namespaces, XMLWriter writer)
throws ObjectSerializeException, XMLWriteException {
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "numChecked")
.addTextContent(Integer.toString(object.getNumChecked())));
writer.writeElement(Element.of(QualityADEModule.NAMESPACE_URI, "numErrors")
.addTextContent(Integer.toString(object.getNumErrors())));
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment