|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjavax.xml.transform.sax.SAXSource
com.thoughtworks.xstream.io.xml.TraxSource
public class TraxSource
A JAXP TrAX Source that enables using XStream
object serialization as direct input for XSLT processors without
resorting to an intermediate representation such as text XML, DOM
or DOM4J.
source):
public static String transform(List source, String stylesheet) {
try {
Transformer transformer = TransformerFactory.newInstance()
.newTransformer(new StreamSource(stylesheet));
XStreamSource in = new XStreamSource(source);
Writer out = new StringWriter();
transformer.transform(in, new StreamResult(out));
return out.toString();
}
catch (TransformerException e) {
throw new RuntimeException("XSLT Transformation failed", e);
}
}
| Field Summary | |
|---|---|
static java.lang.String |
XSTREAM_FEATURE
If TransformerFactory.getFeature(java.lang.String)
returns true when passed this value as an
argument, the Transformer natively supports XStream. |
| Fields inherited from class javax.xml.transform.sax.SAXSource |
|---|
FEATURE |
| Constructor Summary | |
|---|---|
TraxSource()
Creates a XStream TrAX source. |
|
TraxSource(java.util.List source)
Creates a XStream TrAX source, setting the objects to marshal. |
|
TraxSource(java.util.List source,
XStream xstream)
Creates a XStream TrAX source, setting the objects to marshal and a configured (with aliases) XStream facade. |
|
TraxSource(java.lang.Object source)
Creates a XStream TrAX source, specifying the object to marshal. |
|
TraxSource(java.lang.Object source,
XStream xstream)
Creates a XStream TrAX source, specifying the object to marshal and a configured (with aliases) XStream facade. |
|
| Method Summary | |
|---|---|
org.xml.sax.XMLReader |
getXMLReader()
Returns the XMLReader to be used for the Source. |
void |
setInputSource(org.xml.sax.InputSource inputSource)
Sets the SAX InputSource to be used for the Source. |
void |
setSource(java.lang.Object obj)
Sets the object to marshal. |
void |
setSourceAsList(java.util.List list)
Sets the list of objects to marshal. |
void |
setXMLReader(org.xml.sax.XMLReader reader)
Set the XMLReader to be used for the Source. |
void |
setXStream(XStream xstream)
Sets the XStream facade to use when marshalling objects. |
| Methods inherited from class javax.xml.transform.sax.SAXSource |
|---|
getInputSource, getSystemId, setSystemId, sourceToInputSource |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final java.lang.String XSTREAM_FEATURE
TransformerFactory.getFeature(java.lang.String)
returns true when passed this value as an
argument, the Transformer natively supports XStream.
Note: This implementation does not override
the SAXSource.FEATURE value defined by its superclass
to be considered as a SAXSource by Transformer implementations
not natively supporting this XStream-specific source
| Constructor Detail |
|---|
public TraxSource()
public TraxSource(java.lang.Object source)
source - the object to marshal.
java.lang.IllegalArgumentException - if source is
null.setSource(java.lang.Object)
public TraxSource(java.lang.Object source,
XStream xstream)
source - the object to marshal.xstream - a configured XStream facade.
java.lang.IllegalArgumentException - if source or
xstream is null.setSource(java.lang.Object),
setXStream(com.thoughtworks.xstream.XStream)public TraxSource(java.util.List source)
source - the list of objects to marshal.
java.lang.IllegalArgumentException - if source is
null or empty.setSourceAsList(java.util.List)
public TraxSource(java.util.List source,
XStream xstream)
source - the list of objects to marshal.xstream - a configured XStream facade.
java.lang.IllegalArgumentException - if source or
xstream is null or
source is empty.setSourceAsList(java.util.List),
setXStream(com.thoughtworks.xstream.XStream)| Method Detail |
|---|
public void setInputSource(org.xml.sax.InputSource inputSource)
UnsupportedOperationException.
setInputSource in class javax.xml.transform.sax.SAXSourceinputSource - a valid InputSource reference.
java.lang.UnsupportedOperationException - always!public void setXMLReader(org.xml.sax.XMLReader reader)
UnsupportedOperationException if the provided reader
object does not implement the SAX XMLFilter
interface. Otherwise, a SaxWriter instance will be
attached as parent of the filter chain.
setXMLReader in class javax.xml.transform.sax.SAXSourcereader - a valid XMLReader or XMLFilter reference.
java.lang.UnsupportedOperationException - if reader
is not a SAX
XMLFilter.getXMLReader()public org.xml.sax.XMLReader getXMLReader()
SaxWriter) generating the XML from a list of input
objects.
getXMLReader in class javax.xml.transform.sax.SAXSourcepublic void setXStream(XStream xstream)
xstream - a configured XStream facade.
java.lang.IllegalArgumentException - if xstream is
null.public void setSource(java.lang.Object obj)
obj - the object to marshal.
java.lang.IllegalArgumentException - if source is
null.public void setSourceAsList(java.util.List list)
list - the list of objects to marshal.
java.lang.IllegalArgumentException - if source is
null or empty.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||