org.citygml4j.xml.io.writer.CityGMLWriteException Java Examples
The following examples show how to use
org.citygml4j.xml.io.writer.CityGMLWriteException.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AdditionalObjectsHandler.java From web-feature-service with Apache License 2.0 | 6 votes |
private CityModelWriter getOrCreateCacheWriter() throws CityGMLWriteException, IOException { String key = Thread.currentThread().getName(); CityModelWriter tempWriter = tempWriters.get(key); if (tempWriter == null) { // create unique temp file long n = new SecureRandom().nextLong(); n = n == Long.MIN_VALUE ? 0 : Math.abs(n); Path tempFile = Paths.get(System.getProperty("java.io.tmpdir"), "3dcitydb-wfs", Long.toString(n) + ".tmp"); Files.createDirectories(tempFile.getParent()); // create temp writer CityGMLOutputFactory out = cityGMLBuilder.createCityGMLOutputFactory(version); tempWriter = out.createCityModelWriter(tempFile.toFile(), "UTF-8"); tempWriter.setPrefixes(version); tempWriter.setPrefixes(CityGMLContext.getInstance().getADEContexts()); tempWriter.setIndentString(""); tempFiles.put(key, tempFile); tempWriters.put(key, tempWriter); } return tempWriter; }
Example #2
Source File: AbstractJAXBWriter.java From citygml4j with Apache License 2.0 | 6 votes |
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); } }
Example #3
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
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); } }
Example #4
Source File: JAXBSimpleWriter.java From citygml4j with Apache License 2.0 | 5 votes |
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); } }
Example #5
Source File: AbstractJAXBWriter.java From citygml4j with Apache License 2.0 | 5 votes |
@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(); } }
Example #6
Source File: AdditionalObjectsHandler.java From web-feature-service with Apache License 2.0 | 5 votes |
public void cleanCache() { for (Map.Entry<String, Path> entry : tempFiles.entrySet()) { CityModelWriter tempWriter = tempWriters.get(entry.getKey()); if (tempWriter != null) { try { tempWriter.close(); } catch (CityGMLWriteException e) { // } } cacheCleanerPool.addWork(new CacheCleanerWork(entry.getValue())); } }
Example #7
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityModelWriter createCityModelWriter(OutputStream outputStream, String encoding, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBModelWriter( new SAXWriter(outputStream, encoding), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #8
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityModelWriter createCityModelWriter(Writer writer, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBModelWriter( new SAXWriter(writer), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #9
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityModelWriter createCityModelWriter(StreamResult streamResult, String encoding, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBModelWriter( new SAXWriter(streamResult, encoding), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #10
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityModelWriter createCityModelWriter(OutputStream outputStream, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBModelWriter( new SAXWriter(outputStream), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #11
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityModelWriter createCityModelWriter(File file, String encoding, ModuleContext moduleContext) throws CityGMLWriteException { try { createParentDirectories(file.toPath()); return new JAXBModelWriter( new SAXWriter(new OutputStreamWriter(new FileOutputStream(file), encoding)), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #12
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
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); } }
Example #13
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityGMLWriter createCityGMLWriter(StreamResult streamResult, String encoding, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBSimpleWriter( new SAXWriter(streamResult, encoding), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #14
Source File: AbstractJAXBWriter.java From citygml4j with Apache License 2.0 | 5 votes |
public void flush() throws CityGMLWriteException { try { if (writer != null) writer.flush(); } catch (SAXException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #15
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityGMLWriter createCityGMLWriter(File file, String encoding, ModuleContext moduleContext) throws CityGMLWriteException { try { createParentDirectories(file.toPath()); return new JAXBSimpleWriter( new SAXWriter(new OutputStreamWriter(new FileOutputStream(file), encoding)), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #16
Source File: AdditionalObjectsHandler.java From web-feature-service with Apache License 2.0 | 5 votes |
protected void cacheObject(AbstractFeature feature) throws FeatureWriteException { try { if (shouldRun) getOrCreateCacheWriter().writeFeatureMember(feature); } catch (CityGMLWriteException | IOException e) { shouldRun = false; throw new FeatureWriteException("Failed to cache feature with gml:id '" + feature.getId() + "' as additional object.", e); } }
Example #17
Source File: JAXBModelWriter.java From citygml4j with Apache License 2.0 | 5 votes |
@Override public void close() throws CityGMLWriteException { if (documentState == DocumentState.START_DOCUMENT) writeEndDocument(); cityModelInfo = null; initModuleCtx = null; super.close(); }
Example #18
Source File: JAXBModelWriter.java From citygml4j with Apache License 2.0 | 5 votes |
public JAXBModelWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext, CityModelInfo cityModelInfo) throws CityGMLWriteException { this(writer, factory, moduleContext); this.cityModelInfo = cityModelInfo; }
Example #19
Source File: JAXBModelWriter.java From citygml4j with Apache License 2.0 | 5 votes |
public JAXBModelWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext) throws CityGMLWriteException { super(writer, factory, moduleContext); initModuleCtx = new ModuleContext(moduleContext); }
Example #20
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityGMLWriter createCityGMLWriter(OutputStream outputStream, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBSimpleWriter( new SAXWriter(outputStream), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #21
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityGMLWriter createCityGMLWriter(OutputStream outputStream, String encoding, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBSimpleWriter( new SAXWriter(outputStream, encoding), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #22
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 5 votes |
public CityGMLWriter createCityGMLWriter(Writer writer, ModuleContext moduleContext) throws CityGMLWriteException { try { return new JAXBSimpleWriter( new SAXWriter(writer), this, moduleContext); } catch (IOException e) { throw new CityGMLWriteException("Caused by: ", e); } }
Example #23
Source File: JAXBModelWriter.java From citygml4j with Apache License 2.0 | 4 votes |
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); } }
Example #24
Source File: JAXBModelWriter.java From citygml4j with Apache License 2.0 | 4 votes |
public void writeFeatureMember(AbstractFeature feature) throws CityGMLWriteException { writeModelMember(feature); }
Example #25
Source File: JAXBSimpleWriter.java From citygml4j with Apache License 2.0 | 4 votes |
public JAXBSimpleWriter(SAXWriter writer, JAXBOutputFactory factory, ModuleContext moduleContext) throws CityGMLWriteException { super(writer, factory, moduleContext); }
Example #26
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 4 votes |
public CityModelWriter createCityModelWriter(Writer writer) throws CityGMLWriteException { return createCityModelWriter(writer, moduleContext); }
Example #27
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 4 votes |
public CityModelWriter createCityModelWriter(StreamResult streamResult, String encoding) throws CityGMLWriteException { return createCityModelWriter(streamResult, encoding, moduleContext); }
Example #28
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 4 votes |
public CityModelWriter createCityModelWriter(OutputStream outputStream) throws CityGMLWriteException { return createCityModelWriter(outputStream, moduleContext); }
Example #29
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 4 votes |
public CityGMLWriter createCityGMLWriter(Writer writer) throws CityGMLWriteException { return createCityGMLWriter(writer, moduleContext); }
Example #30
Source File: JAXBOutputFactory.java From citygml4j with Apache License 2.0 | 4 votes |
public CityGMLWriter createCityGMLWriter(OutputStream outputStream) throws CityGMLWriteException { return createCityGMLWriter(outputStream, moduleContext); }