@Override protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException { try { MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext(); IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter); marshallingContext.setXmlWriter(xmlWriter); marshallingContext.marshalDocument(graph); } catch (JiBXException ex) { throw convertJibxException(ex, false); } }
@Override protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) { try { UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext(); IXMLReader xmlReader = new StAXReaderWrapper(streamReader, null, true); unmarshallingContext.setDocument(xmlReader); return unmarshallingContext.unmarshalElement(); } catch (JiBXException ex) { throw convertJibxException(ex, false); } }
@Override protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException { try { MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext(); IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter); marshallingContext.setXmlWriter(xmlWriter); marshallingContext.marshalDocument(graph); } catch (JiBXException ex) { throw convertJibxException(ex, false); } }
public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException { // make sure we're at the appropriate start tag UnmarshallingContext ctx = (UnmarshallingContext)ictx; if (!ctx.isAt(m_uri, m_name)) { return null; } // get object reference for ID obj = ctx.attributeExistingIDREF(null, getAttributeName(), 0); // skip past the element ctx.parsePastEndTag(m_uri, m_name); return obj; } }
public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException { // just discard and return null ((UnmarshallingContext)ictx).skipElement(); return null; } }
/** * Build the fully-qualified name for a package or class by appending the supplied name attribute value to the * fully-qualified name of the containing package. * * @param contain * @param ctx * @throws JiBXException */ private String buildFullName(PackageCustom contain, UnmarshallingContext ctx) throws JiBXException { String lead = ""; if (contain != null) { lead = contain.getName() + '.'; } return lead + ctx.attributeText(null, "name"); }
/** * Set the byte buffer. * * @param buff */ public void setBuffer(IOutByteBuffer buff) { m_byteBuffer = buff; m_buffer = buff.getBuffer(); if (m_buffer.length < MINIMUM_BUFFER_SIZE) { throw new IllegalArgumentException("Buffer size must be at least " + MINIMUM_BUFFER_SIZE); } m_offset = buff.getOffset(); }
public boolean isPresent(IUnmarshallingContext ctx) throws JiBXException { if (!(ctx instanceof UnmarshallingContext)) { throw new JiBXException ("Unmarshalling context not of expected type"); } else { return ((UnmarshallingContext)ctx).currentEvent() != IXMLReader.END_TAG; } }
/** * Copy constructor. This initializes the writer and extension namespace information from an existing instance. * * @param base existing instance * @param uris ordered array of URIs for namespaces used in document */ public JibxWriter(JibxWriter base, String[] uris) { super(base, uris); m_writer = base.m_writer; m_parent = base; }
/** * Constructor. * * @param uri version selection attribute URI (<code>null</code> if none) * @param name version selection attribute name * @param versions array of version texts (first is default) * @param bindings array of binding names corresponding to versions */ public BindingSelector(String uri, String name, String[] versions, String[] bindings) { m_attributeUri = uri; m_attributeName = name; m_versionTexts = versions; m_versionBindings = bindings; m_context = new UnmarshallingContext(); m_outputIndent = -1; }
/** * Make space for more data in buffer. This makes at least the requested * number of bytes available. * * @param bytes minimum number of bytes of space required * @throws IOException on error writing to stream */ private final void makeSpace(int bytes) throws IOException { m_byteBuffer.setOffset(m_offset); if (m_markOffset >= 0) { m_byteBuffer.free(m_markOffset, bytes); } else { m_byteBuffer.free(m_offset, bytes); } m_buffer = m_byteBuffer.getBuffer(); m_offset = m_byteBuffer.getOffset(); }
public void reset() { super.reset(); this.document = new Document(); this.currentElement = null; }
@Override protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) { try { UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext(); IXMLReader xmlReader = new StAXReaderWrapper(streamReader, null, true); unmarshallingContext.setDocument(xmlReader); return unmarshallingContext.unmarshalElement(); } catch (JiBXException ex) { throw convertJibxException(ex, false); } }
protected void marshalXmlStreamWriter(Object graph, XMLStreamWriter streamWriter) throws XmlMappingException { try { MarshallingContext marshallingContext = (MarshallingContext) createMarshallingContext(); IXMLWriter xmlWriter = new StAXWriter(marshallingContext.getNamespaces(), streamWriter); marshallingContext.setXmlWriter(xmlWriter); marshallingContext.marshalDocument(graph); } catch (JiBXException ex) { throw convertJibxException(ex, false); } }
public Object unmarshal(Object obj, IUnmarshallingContext ictx) throws JiBXException { // just discard all elements and return null while (!ictx.isEnd()) { ((UnmarshallingContext)ictx).skipElement(); } return null; } }
/** * Parameter value unmarshalling factory. This gets the containing element and the name so that the standard * constructor can be used. * * @param ictx * @return created instance * @throws JiBXException */ private static ThrowsCustom throwsFactory(IUnmarshallingContext ictx) throws JiBXException { return new ThrowsCustom((OperationCustom)getContainingObject(ictx), ((UnmarshallingContext)ictx).attributeText( null, "class")); } }
public boolean isPresent(IUnmarshallingContext ctx) throws JiBXException { if (!(ctx instanceof UnmarshallingContext)) { throw new JiBXException ("Unmarshalling context not of expected type"); } else { return ((UnmarshallingContext)ctx).currentEvent() != IXMLReader.END_TAG; } }
/** * Constructor. This creates a byte buffer of the default size. * * @param uris ordered array of URIs for namespaces used in document (must be constant; the value in position 0 must * always be the empty string "", and the value in position 1 must always be the XML namespace * "http://www.w3.org/XML/1998/namespace") */ public JibxStreamWriter(String[] uris) { this(uris, new OutByteBuffer(XBISWriter.DEFAULT_BUFFER_SIZE)); }
protected Object unmarshalXmlStreamReader(XMLStreamReader streamReader) { try { UnmarshallingContext unmarshallingContext = (UnmarshallingContext) createUnmarshallingContext(); IXMLReader xmlReader = new StAXReaderWrapper(streamReader, null, true); unmarshallingContext.setDocument(xmlReader); return unmarshallingContext.unmarshalElement(); } catch (JiBXException ex) { throw convertJibxException(ex, false); } }
public boolean isPresent(IUnmarshallingContext ctx) throws JiBXException { if (!(ctx instanceof UnmarshallingContext)) { throw new JiBXException ("Unmarshalling context not of expected type"); } else { return ((UnmarshallingContext)ctx).currentEvent() != IXMLReader.END_TAG; } }