/** * Write a model to an OutputStream. * @param model * @param os * @param context * @throws ContributionWriteException */ public void write(Object model, OutputStream os, ProcessorContext context) throws ContributionWriteException { try { XMLStreamWriter writer = outputFactory.createXMLStreamWriter(os); write(model, writer, context); writer.flush(); writer.close(); } catch (XMLStreamException e) { ContributionWriteException cw = new ContributionWriteException(e); error(context.getMonitor(), "ContributionWriteException", outputFactory, cw); throw cw; } }
/** * Write a model to an OutputStream. * @param model * @param os * @param context * @throws ContributionWriteException */ public void write(Object model, OutputStream os, ProcessorContext context) throws ContributionWriteException { try { XMLStreamWriter writer = outputFactory.createXMLStreamWriter(os); write(model, writer, context); writer.flush(); writer.close(); } catch (XMLStreamException e) { ContributionWriteException cw = new ContributionWriteException(e); error(context.getMonitor(), "ContributionWriteException", outputFactory, cw); throw cw; } }
public Object read(XMLStreamReader source, ProcessorContext context) throws ContributionReadException, XMLStreamException { Monitor monitor = context.getMonitor(); // Delegate to the processor associated with the element QName int event = source.getEventType(); if (event == XMLStreamConstants.START_DOCUMENT) { while (source.next() != XMLStreamReader.START_ELEMENT); } QName name = source.getName(); StAXArtifactProcessor<?> processor = (StAXArtifactProcessor<?>)processors.getProcessor(name); if (processor == null) { Location location = source.getLocation(); error(monitor, "ElementCannotBeProcessed", processors, name, location); StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT); if (anyElementProcessor != null) { return anyElementProcessor.read(source, context); } else { return null; } } return processor.read(source, context); }
public Object read(XMLStreamReader source, ProcessorContext context) throws ContributionReadException, XMLStreamException { Monitor monitor = context.getMonitor(); // Delegate to the processor associated with the element QName int event = source.getEventType(); if (event == XMLStreamConstants.START_DOCUMENT) { while (source.next() != XMLStreamReader.START_ELEMENT); } QName name = source.getName(); StAXArtifactProcessor<?> processor = (StAXArtifactProcessor<?>)processors.getProcessor(name); if (processor == null) { Location location = source.getLocation(); error(monitor, "ElementCannotBeProcessed", processors, name, location); StAXArtifactProcessor anyElementProcessor = processors.getProcessor(ANY_ELEMENT); if (anyElementProcessor != null) { return anyElementProcessor.read(source, context); } else { return null; } } return processor.read(source, context); }
return type.cast(mo); } else { error(monitor, "UnrecognizedElementException", reader, name); UnrecognizedElementException e = new UnrecognizedElementException(name); throw e; e.setLine(location.getLineNumber()); e.setColumn(location.getColumnNumber()); error(monitor, "ContributionReadException", reader, e); throw e; } finally { error(monitor, "ContributionReadException", inputFactory, ce); throw ce;
return type.cast(mo); } else { error(monitor, "UnrecognizedElementException", reader, name); UnrecognizedElementException e = new UnrecognizedElementException(name); throw e; e.setLine(location.getLineNumber()); e.setColumn(location.getColumnNumber()); error(monitor, "ContributionReadException", reader, e); throw e; } finally { error(monitor, "ContributionReadException", inputFactory, ce); throw ce;