
org.citygml4j.xml.adapter.ade.ADEBuilderHelper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of citygml4j-xml Show documentation
Show all versions of citygml4j-xml Show documentation
The Open Source Java API for CityGML
/*
* citygml4j - The Open Source Java API for CityGML
* https://github.com/citygml4j
*
* Copyright 2013-2025 Claus Nagel
*
* 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 org.citygml4j.xml.adapter.ade;
import com.sun.xml.xsom.XSElementDecl;
import com.sun.xml.xsom.XSSchemaSet;
import org.citygml4j.core.model.ade.ADEProperty;
import org.citygml4j.core.model.core.AbstractFeature;
import org.citygml4j.xml.reader.CityGMLInputFactory;
import org.citygml4j.xml.reader.MissingADESchemaException;
import org.w3c.dom.Element;
import org.xmlobjects.annotation.XMLElements;
import org.xmlobjects.builder.ObjectBuildException;
import org.xmlobjects.builder.ObjectBuilder;
import org.xmlobjects.schema.SchemaHandler;
import org.xmlobjects.schema.SchemaHandlerException;
import org.xmlobjects.stream.EventType;
import org.xmlobjects.stream.XMLReadException;
import org.xmlobjects.stream.XMLReader;
import javax.xml.namespace.QName;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
public class ADEBuilderHelper {
public static void addADEProperty(AbstractFeature feature, Function creator, XMLReader reader) throws ObjectBuildException, XMLReadException {
if (reader.hasNext() && reader.nextTag() == EventType.START_ELEMENT) {
QName name = reader.getName();
ObjectBuilder builder = reader.getXMLObjects().getBuilder(name, ADEProperty.class);
if (builder != null) {
buildADEProperty(feature, name, builder, reader);
} else if (reader.isCreateDOMAsFallback()) {
feature.addADEProperty(creator.apply(reader.getDOMElement()));
}
}
}
public static boolean addADEProperty(AbstractFeature feature, QName name, Function creator, XMLReader reader, QName... substitutionGroups) throws ObjectBuildException, XMLReadException {
ObjectBuilder builder = reader.getXMLObjects().getBuilder(name, ADEProperty.class);
if (builder != null) {
buildADEProperty(feature, name, builder, reader);
return true;
} else if (reader.isCreateDOMAsFallback() && substitutes(name, reader, substitutionGroups)) {
feature.addADEProperty(creator.apply(reader.getDOMElement()));
return true;
}
return false;
}
@SuppressWarnings("unchecked")
private static void buildADEProperty(AbstractFeature feature, QName name, ObjectBuilder builder, XMLReader reader) throws ObjectBuildException, XMLReadException {
Map
© 2015 - 2025 Weber Informatics LLC | Privacy Policy