/** * Creates a XStream TrAX source, specifying the object to marshal and a configured (with * aliases) XStream facade. * * @param source the object to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is * <code>null</code>. * @see #setSource(java.lang.Object) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(Object source, XStream xstream) { super(new InputSource()); this.setSource(source); this.setXStream(xstream); }
/** * Sets the XStream facade to use when marshalling objects. * * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>xstream</code> is <code>null</code>. */ public void setXStream(XStream xstream) { if (xstream == null) { throw new IllegalArgumentException("xstream"); } this.xstream = xstream; this.configureXMLReader(); }
/** * Returns the XMLReader to be used for the Source. * <p> * This implementation returns a * specific XMLReader ({@link SaxWriter}) generating the XML from a list of input objects. * </p> * * @return an XMLReader generating the XML from a list of input objects. */ public XMLReader getXMLReader() { if (this.xmlReader == null) { this.createXMLReader(null); } return this.xmlReader; }
/** * Creates a XStream TrAX source, setting the objects to marshal and a configured (with * aliases) XStream facade. * * @param source the list of objects to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is * <code>null</code> or <code>source</code> is empty. * @see #setSourceAsList(java.util.List) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(List source, XStream xstream) { super(new InputSource()); this.setSourceAsList(source); this.setXStream(xstream); }
/** * Creates a XStream TrAX source, setting the objects to marshal. * * @param source the list of objects to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code> or * empty. * @see #setSourceAsList(java.util.List) */ public TraxSource(List source) { super(new InputSource()); this.setSourceAsList(source); }
/** * Creates a XStream TrAX source, specifying the object to marshal. * * @param source the object to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code>. * @see #setSource(java.lang.Object) */ public TraxSource(Object source) { super(new InputSource()); this.setSource(source); }
/** * Creates a XStream TrAX source, setting the objects to marshal and a configured (with aliases) XStream facade. * * @param source the list of objects to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is <code>null</code> or * <code>source</code> is empty. * @see #setSourceAsList(java.util.List) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(final List<?> source, final XStream xstream) { super(new InputSource()); setSourceAsList(source); setXStream(xstream); }
/** * Sets the object to marshal. * * @param obj the object to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code>. */ public void setSource(Object obj) { if (obj == null) { throw new IllegalArgumentException("obj"); } List list = new ArrayList(1); list.add(obj); this.setSourceAsList(list); }
public void setSource(Object source) { super.setSource(source); this.object = source; } }
/** * Creates a XStream TrAX source, specifying the object to marshal and a configured (with aliases) XStream facade. * * @param source the object to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is <code>null</code>. * @see #setSource(java.lang.Object) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(final Object source, final XStream xstream) { super(new InputSource()); setSource(source); setXStream(xstream); }
/** * Creates a XStream TrAX source, setting the objects to marshal and a configured (with * aliases) XStream facade. * * @param source the list of objects to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is * <code>null</code> or <code>source</code> is empty. * @see #setSourceAsList(java.util.List) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(List source, XStream xstream) { super(new InputSource()); this.setSourceAsList(source); this.setXStream(xstream); }
/** * Sets the list of objects to marshal. * <p> * When dealing with non-text input (such as SAX * or DOM), XSLT processors support multiple root node children for the source tree (see <a * href="http://www.w3.org/TR/xslt#root-node-children">section 3.1</a> of the "XSL * Transformations (XSLT) Version 1.0" specification. Using a list of objects as source * makes use of this feature and allows creating XML documents merging the XML serialization * of several Java objects. * * @param list the list of objects to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code> or * empty. */ public void setSourceAsList(List list) { if ((list == null) || (list.isEmpty())) { throw new IllegalArgumentException("list"); } this.source = list; this.configureXMLReader(); }
/** * Creates a XStream TrAX source, setting the objects to marshal. * * @param source the list of objects to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code> or empty. * @see #setSourceAsList(java.util.List) */ public TraxSource(final List<?> source) { super(new InputSource()); setSourceAsList(source); }
/** * Set the XMLReader to be used for the Source. * <p> * As this implementation only supports * object lists as data source, this method throws an {@link UnsupportedOperationException} * if the provided reader object does not implement the SAX {@link XMLFilter} interface. * Otherwise, a {@link SaxWriter} instance will be attached as parent of the filter chain. * </p> * * @param reader a valid XMLReader or XMLFilter reference. * @throws UnsupportedOperationException if <code>reader</code> is not a SAX * {@link XMLFilter}. * @see #getXMLReader */ public void setXMLReader(XMLReader reader) { this.createXMLReader(reader); }
/** * Creates a XStream TrAX source, specifying the object to marshal. * * @param source the object to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code>. * @see #setSource(java.lang.Object) */ public TraxSource(final Object source) { super(new InputSource()); setSource(source); }
/** * Creates a XStream TrAX source, specifying the object to marshal and a configured (with * aliases) XStream facade. * * @param source the object to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is * <code>null</code>. * @see #setSource(java.lang.Object) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(Object source, XStream xstream) { super(new InputSource()); this.setSource(source); this.setXStream(xstream); }
/** * Creates a XStream TrAX source, setting the objects to marshal and a configured (with * aliases) XStream facade. * * @param source the list of objects to marshal. * @param xstream a configured XStream facade. * @throws IllegalArgumentException if <code>source</code> or <code>xstream</code> is * <code>null</code> or <code>source</code> is empty. * @see #setSourceAsList(java.util.List) * @see #setXStream(com.thoughtworks.xstream.XStream) */ public TraxSource(List source, XStream xstream) { super(new InputSource()); this.setSourceAsList(source); this.setXStream(xstream); }
private void createXMLReader(XMLReader filterChain) { if (filterChain == null) { this.xmlReader = new SaxWriter(); } else { if (filterChain instanceof XMLFilter) { // Connect the filter chain to a document reader. XMLFilter filter = (XMLFilter)filterChain; while (filter.getParent() instanceof XMLFilter) { filter = (XMLFilter)(filter.getParent()); } if (!(filter.getParent() instanceof SaxWriter)) { filter.setParent(new SaxWriter()); } // Read XML data from filter chain. this.xmlReader = filterChain; } else { throw new UnsupportedOperationException(); } } this.configureXMLReader(); }
/** * Creates a XStream TrAX source, setting the objects to marshal. * * @param source the list of objects to marshal. * @throws IllegalArgumentException if <code>source</code> is <code>null</code> or * empty. * @see #setSourceAsList(java.util.List) */ public TraxSource(List source) { super(new InputSource()); this.setSourceAsList(source); }
/** * Returns the XMLReader to be used for the Source. <p/> This implementation returns a * specific XMLReader ({@link SaxWriter}) generating the XML from a list of input objects. * </p> * * @return an XMLReader generating the XML from a list of input objects. */ public XMLReader getXMLReader() { if (this.xmlReader == null) { this.createXMLReader(null); } return this.xmlReader; }