本文整理汇总了Java中org.citygml4j.xml.io.writer.CityGMLWriteException类的典型用法代码示例。如果您正苦于以下问题:Java CityGMLWriteException类的具体用法?Java CityGMLWriteException怎么用?Java CityGMLWriteException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CityGMLWriteException类属于org.citygml4j.xml.io.writer包,在下文中一共展示了CityGMLWriteException类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: close
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void close() throws CityGMLWriteException {
try {
jaxbMarshaller = null;
jaxbContext = null;
featureSplitter = null;
schemaHandler = null;
validationSchemaHandler = null;
validationEventHandler = null;
if (writer != null)
writer.close();
} catch (SAXException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例2: JAXBModelWriter
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public JAXBModelWriter(SAXWriter writer,
JAXBOutputFactory factory,
ModuleContext moduleContext) throws CityGMLWriteException {
super(writer, factory, moduleContext);
initModuleCtx = new ModuleContext(moduleContext);
}
示例3: close
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
@Override
public void close() throws CityGMLWriteException {
if (documentState == DocumentState.START_DOCUMENT)
writeEndDocument();
cityModelInfo = null;
initModuleCtx = null;
super.close();
}
示例4: createCityGMLWriter
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public CityGMLWriter createCityGMLWriter(File file, ModuleContext moduleContext) throws CityGMLWriteException {
try {
createParentDirectories(file.toPath());
return new JAXBSimpleWriter(
new SAXWriter(new OutputStreamWriter(new FileOutputStream(file))),
this,
moduleContext);
} catch (IOException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例5: createCityModelWriter
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public CityModelWriter createCityModelWriter(File file, ModuleContext moduleContext) throws CityGMLWriteException {
try {
createParentDirectories(file.toPath());
return new JAXBModelWriter(
new SAXWriter(new OutputStreamWriter(new FileOutputStream(file))),
this,
moduleContext);
} catch (IOException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例6: setTransformationTemplates
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void setTransformationTemplates(Templates... transformationTemplates) throws CityGMLWriteException {
if (transformationTemplates == null)
throw new IllegalArgumentException("transformation templates may not be null.");
try {
if (transformerChainFactory == null)
transformerChainFactory = new TransformerChainFactory(transformationTemplates);
else
transformerChainFactory.updateTemplates(transformationTemplates);
} catch (TransformerConfigurationException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例7: write
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void write(AbstractFeature abstractFeature) throws CityGMLWriteException {
if (featureWriteMode == FeatureWriteMode.SPLIT_PER_COLLECTION_MEMBER && featureSplitter != null)
abstractFeature = split(abstractFeature);
try {
JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(abstractFeature);
if (jaxbElement != null) {
Marshaller marshaller = jaxbContext.createMarshaller();
// validate output
if (useValidation) {
marshaller.setSchema(validationSchemaHandler.getSchema());
if (validationEventHandler != null)
marshaller.setEventHandler(validationEventHandler);
}
// marshal output
if (transformerChainFactory == null)
marshaller.marshal(jaxbElement, writer);
else {
// apply transformation before marshalling
TransformerChain chain = transformerChainFactory.buildChain();
chain.tail().setResult(new SAXResult(writer));
marshaller.marshal(jaxbElement, chain.head());
}
writer.flush();
}
} catch (JAXBException | SAXException | TransformerConfigurationException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例8: AbstractJAXBWriter
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public AbstractJAXBWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext) throws CityGMLWriteException {
this.writer = writer;
jaxbMarshaller = factory.builder.createJAXBMarshaller(new ModuleContext(moduleContext));
jaxbContext = factory.builder.getJAXBContext();
schemaHandler = factory.getSchemaHandler();
transformerChainFactory = factory.getTransformerChainFactory();
featureWriteMode = (FeatureWriteMode)factory.getProperty(CityGMLOutputFactory.FEATURE_WRITE_MODE);
useValidation = (Boolean)factory.getProperty(CityGMLOutputFactory.USE_VALIDATION);
if (featureWriteMode == FeatureWriteMode.SPLIT_PER_COLLECTION_MEMBER) {
featureSplitter = new FeatureSplitter()
.setSchemaHandler(schemaHandler)
.setGMLIdManager(factory.getGMLIdManager())
.setSplitMode(FeatureSplitMode.SPLIT_PER_COLLECTION_MEMBER)
.keepInlineAppearance((Boolean)factory.getProperty(CityGMLOutputFactory.KEEP_INLINE_APPEARANCE))
.splitCopy((Boolean)factory.getProperty(CityGMLOutputFactory.SPLIT_COPY))
.exclude((Set<Class<? extends CityGML>>)factory.getProperty(CityGMLOutputFactory.EXCLUDE_FROM_SPLITTING));
}
if (useValidation) {
if (schemaHandler == null) {
try {
schemaHandler = factory.builder.getDefaultSchemaHandler();
} catch (CityGMLBuilderException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
validationSchemaHandler = new ValidationSchemaHandler(schemaHandler);
validationEventHandler = factory.getValidationEventHandler();
}
}
示例9: flush
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void flush() throws CityGMLWriteException {
try {
if (writer != null)
writer.flush();
} catch (SAXException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例10: print
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void print(AbstractFeature abstractFeature) throws CityGMLWriteException {
FeatureProperty<? extends AbstractFeature> member = null;
// wrap feature with a feature property element
if (abstractFeature instanceof AbstractCityObject) {
member = new CityObjectMemberImpl();
((CityObjectMember)member).setCityObject((AbstractCityObject)abstractFeature);
}
else if (abstractFeature instanceof Appearance) {
member = new AppearanceMemberImpl();
((AppearanceMember)member).setAppearance((Appearance)abstractFeature);
}
else {
member = new FeatureMemberImpl();
((FeatureMember)member).setFeature(abstractFeature);
}
if (member != null) {
try {
SAXEventBuffer buffer = new SAXEventBuffer();
Marshaller marshaller = jaxbBuilder.getJAXBContext().createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);
JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(member);
if (jaxbElement != null)
marshaller.marshal(jaxbElement, buffer);
if (!buffer.isEmpty())
ioWriterPool.addWork(buffer);
} catch (JAXBException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
}
示例11: writeFeatureMember
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void writeFeatureMember(AbstractFeature feature) throws CityGMLWriteException {
writeModelMember(feature);
}
示例12: writeEndDocument
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void writeEndDocument() throws CityGMLWriteException {
switch (documentState) {
case END_DOCUMENT:
throw new IllegalStateException("CityModel end element can only be written once.");
case INITIAL:
writeStartDocument();
case START_DOCUMENT:
break;
default:
throw new IllegalStateException("Unknown document state '" + documentState + "'");
}
try {
CityModel cityModel = new CityModel();
if (cityModelInfo != null) {
if (cityModelInfo.isSetGenericApplicationPropertyOfCityModel())
cityModel.setGenericApplicationPropertyOfCityModel(
cityModelInfo.getGenericApplicationPropertyOfCityModel());
if (cityModelInfo.isSetGenericADEElement())
cityModel.setGenericADEElement(
cityModelInfo.getGenericADEElement());
}
ModuleContext tmp = jaxbMarshaller.getModuleContext();
jaxbMarshaller.setModuleContext(initModuleCtx);
JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(cityModel);
if (jaxbElement != null) {
SAXFragmentWriter fragmentWriter = new SAXFragmentWriter(
new QName(jaxbMarshaller.getModuleContext().getModule(CityGMLModuleType.CORE).getNamespaceURI(), "CityModel"), writer, WriteMode.TAIL);
createMarshaller(true).marshal(jaxbElement, fragmentWriter);
}
jaxbMarshaller.setModuleContext(tmp);
documentState = DocumentState.END_DOCUMENT;
} catch (JAXBException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例13: writeFeatureMembers
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public void writeFeatureMembers(List<ModelObject> features) throws CityGMLWriteException {
switch (documentState) {
case END_DOCUMENT:
throw new IllegalStateException("CityModel members cannot be written after document end.");
case INITIAL:
writeStartDocument();
break;
case START_DOCUMENT:
break;
default:
throw new IllegalStateException("Unknown document state '" + documentState + "'");
}
FeatureArrayProperty members = new FeatureArrayProperty();
List<FeatureProperty<? extends AbstractFeature>> featureArray = new ArrayList<FeatureProperty<? extends AbstractFeature>>();
for (ModelObject feature : features) {
if (feature instanceof AbstractFeature || feature instanceof ADEComponent) {
if (featureWriteMode == FeatureWriteMode.SPLIT_PER_COLLECTION_MEMBER)
featureArray.addAll(split(feature));
else
featureArray.add(wrap(feature));
}
}
for (FeatureProperty<? extends AbstractFeature> member : featureArray) {
if (member != null) {
if (member.isSetFeature())
members.addFeature(member.getFeature());
else if (member.isSetGenericADEElement())
members.addGenericADEElement(member.getGenericADEElement());
}
}
try {
JAXBElement<?> jaxbElement = jaxbMarshaller.marshalJAXBElement(members);
if (jaxbElement != null) {
Marshaller marshaller = createMarshaller(true);
if (transformerChainFactory == null)
marshaller.marshal(jaxbElement, writer);
else {
// apply transformation before marshalling
TransformerChain chain = transformerChainFactory.buildChain();
chain.tail().setResult(new SAXResult(writer));
chain.head().startDocument();
marshaller.marshal(jaxbElement, chain.head());
chain.head().endDocument();
}
}
} catch (JAXBException | SAXException | TransformerConfigurationException e) {
throw new CityGMLWriteException("Caused by: ", e);
}
}
示例14: JAXBSimpleWriter
import org.citygml4j.xml.io.writer.CityGMLWriteException; //导入依赖的package包/类
public JAXBSimpleWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext) throws CityGMLWriteException {
super(writer, factory, moduleContext);
}