/* * citygml4j - The Open Source Java API for CityGML * https://github.com/citygml4j * * Copyright 2013-2017 Claus Nagel <claus.nagel@gmail.com> * * 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.builder.jaxb.marshal.citygml.landuse; import javax.xml.bind.JAXBElement; import net.opengis.citygml.landuse._2.ObjectFactory; import net.opengis.citygml.landuse._2.LandUseType; import org.citygml4j.builder.jaxb.marshal.JAXBMarshaller; import org.citygml4j.builder.jaxb.marshal.citygml.CityGMLMarshaller; import org.citygml4j.model.citygml.ade.ADEComponent; import org.citygml4j.model.citygml.landuse.LandUse; import org.citygml4j.model.citygml.landuse.LandUseModuleComponent; import org.citygml4j.model.common.base.ModelObject; import org.citygml4j.model.gml.basicTypes.Code; public class LandUse200Marshaller { private final ObjectFactory luse = new ObjectFactory(); private final JAXBMarshaller jaxb; private final CityGMLMarshaller citygml; public LandUse200Marshaller(CityGMLMarshaller citygml) { this.citygml = citygml; jaxb = citygml.getJAXBMarshaller(); } public JAXBElement<?> marshalJAXBElement(Object src) { JAXBElement<?> dest = null; if (src instanceof LandUseModuleComponent) src = marshal((LandUseModuleComponent)src); if (src instanceof LandUseType) dest = luse.createLandUse((LandUseType)src); return dest; } public Object marshal(ModelObject src) { Object dest = null; if (src instanceof LandUse) dest = marshalLandUse((LandUse)src); return dest; } public void marshalLandUse(LandUse src, LandUseType dest) { citygml.getCore200Marshaller().marshalAbstractCityObject(src, dest); if (src.isSetClazz()) dest.setClazz(jaxb.getGMLMarshaller().marshalCode(src.getClazz())); if (src.isSetFunction()) { for (Code function : src.getFunction()) dest.getFunction().add(jaxb.getGMLMarshaller().marshalCode(function)); } if (src.isSetUsage()) { for (Code usage : src.getUsage()) dest.getUsage().add(jaxb.getGMLMarshaller().marshalCode(usage)); } if (src.isSetLod0MultiSurface()) dest.setLod0MultiSurface(jaxb.getGMLMarshaller().marshalMultiSurfaceProperty(src.getLod0MultiSurface())); if (src.isSetLod1MultiSurface()) dest.setLod1MultiSurface(jaxb.getGMLMarshaller().marshalMultiSurfaceProperty(src.getLod1MultiSurface())); if (src.isSetLod2MultiSurface()) dest.setLod2MultiSurface(jaxb.getGMLMarshaller().marshalMultiSurfaceProperty(src.getLod2MultiSurface())); if (src.isSetLod3MultiSurface()) dest.setLod3MultiSurface(jaxb.getGMLMarshaller().marshalMultiSurfaceProperty(src.getLod3MultiSurface())); if (src.isSetLod4MultiSurface()) dest.setLod4MultiSurface(jaxb.getGMLMarshaller().marshalMultiSurfaceProperty(src.getLod4MultiSurface())); if (src.isSetGenericApplicationPropertyOfLandUse()) { for (ADEComponent adeComponent :src.getGenericApplicationPropertyOfLandUse()) if (adeComponent.isSetContent()) dest.get_GenericApplicationPropertyOfLandUse().add(citygml.ade2jaxbElement(adeComponent)); } } public LandUseType marshalLandUse(LandUse src) { LandUseType dest = luse.createLandUseType(); marshalLandUse(src, dest); return dest; } }