本文整理匯總了Java中com.thoughtworks.xstream.io.xml.XppDriver類的典型用法代碼示例。如果您正苦於以下問題:Java XppDriver類的具體用法?Java XppDriver怎麽用?Java XppDriver使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
XppDriver類屬於com.thoughtworks.xstream.io.xml包,在下文中一共展示了XppDriver類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: DriverEndToEndTestSuite
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public DriverEndToEndTestSuite() {
super(DriverEndToEndTestSuite.class.getName());
addDriverTest(new BEAStaxDriver());
addDriverTest(new BinaryStreamDriver());
addDriverTest(new Dom4JDriver());
addDriverTest(new DomDriver());
addDriverTest(new JDomDriver());
addDriverTest(new JDom2Driver());
addDriverTest(new KXml2DomDriver());
addDriverTest(new KXml2Driver());
addDriverTest(new StaxDriver());
addDriverTest(new StandardStaxDriver());
addDriverTest(new WstxDriver());
addDriverTest(new XomDriver());
addDriverTest(new Xpp3DomDriver());
addDriverTest(new Xpp3Driver());
addDriverTest(new XppDomDriver());
addDriverTest(new XppDriver());
addDriverTest(new JettisonMappedXmlDriver());
}
示例2: XStreamXml
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public XStreamXml() {
XStream prototype = new XStream();
MapperWrapper mapperWrapper = new MapperWrapper(prototype.getMapper()) {
/**
* Overridden to force a class attribute to be emitted on elements whose tag name is not already the name or
* alias of a class.
*/
@Override
public Class defaultImplementationOf(Class type) {
return null;
}
};
xStream = new XStream(prototype.getReflectionProvider(), new XppDriver(), prototype.getClassLoaderReference(),
mapperWrapper);
xStream.setMode(XStream.ID_REFERENCES);
}
示例3: getXstream
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
protected static XStream getXstream()
{
if (xstream == null)
{
xstream = new XStream(new XppDriver()
{
@Override
public HierarchicalStreamWriter createWriter(Writer out)
{
return new PrettyPrintWriter(out)
{
@Override
protected void writeText(QuickWriter writer, String text)
{
writer.write("<![CDATA[");
writer.write(text);
writer.write("]]>");
}
};
}
});
}
return xstream;
}
示例4: loadChart
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
@SuppressWarnings("rawtypes")
public static List loadChart(File dir, String fileName) {
try {
File file = new File(dir, fileName + CHART_EXT);
log.error("filepathComplete: " + file);
XStream xStream = new XStream(new XppDriver());
xStream.setMode(XStream.NO_REFERENCES);
try (InputStream is = new FileInputStream(file);
BufferedReader reader = new BufferedReader(new InputStreamReader(is, UTF_8)))
{
return (List) xStream.fromXML(reader);
}
} catch (Exception err) {
log.error("Unexpected error while loading chart", err);
}
return new ArrayList<>();
}
示例5: EncodingTestSuite
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public EncodingTestSuite() {
super(EncodingTestSuite.class.getName());
addDriverTest(new Dom4JDriver());
addDriverTest(new DomDriver());
addDriverTest(new JDomDriver());
addDriverTest(new JDom2Driver());
addDriverTest(new StaxDriver());
if (!SystemUtils.IS_OS_WINDOWS) { // see comment below for Windows
addDriverTest(new StandardStaxDriver());
addDriverTest(new BEAStaxDriver());
addDriverTest(new WstxDriver());
}
addDriverTest(new KXml2DomDriver());
addDriverTest(new KXml2Driver());
addDriverTest(new XppDomDriver());
addDriverTest(new XppDriver());
addDriverTest(new XomDriver());
}
示例6: testCanBeOverloadedToDeserializeTransientFields
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public void testCanBeOverloadedToDeserializeTransientFields() {
XStream xstream = new XStream(new XppDriver());
xstream.allowTypes(TypesOfFields.class);
xstream.alias("types", TypesOfFields.class);
xstream.registerConverter(new ReflectionConverter(xstream.getMapper(), xstream
.getReflectionProvider()) {
public boolean canConvert(Class type) {
return type == TypesOfFields.class;
}
protected boolean shouldUnmarshalTransientFields() {
return true;
}
});
String xml = ""
+ "<types>\n"
+ " <normal>normal</normal>\n"
+ " <trans>foo</trans>\n"
+ "</types>";
TypesOfFields fields = (TypesOfFields)xstream.fromXML(xml);
assertEquals("foo", fields.trans);
}
示例7: setUp
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
protected void setUp() throws Exception {
super.setUp();
final ClassAliasingMapper classAliasingMapper = new ClassAliasingMapper(
new DefaultMapper(new ClassLoaderReference(getClass().getClassLoader())));
classAliasingMapper.addClassAlias("x", X.class);
classAliasingMapper.addClassAlias("software", Software.class);
classAliasingMapper.addClassAlias("open-source", OpenSourceSoftware.class);
mapper = new DefaultImplementationsMapper(new ArrayMapper(classAliasingMapper));
reflectionProvider = new SunUnsafeReflectionProvider();
driver = new XppDriver();
converterLookup = new DefaultConverterLookup();
converterLookup.registerConverter(
new SingleValueConverterWrapper(new StringConverter()), 0);
converterLookup.registerConverter(
new SingleValueConverterWrapper(new IntConverter()), 0);
converterLookup.registerConverter(new ArrayConverter(mapper), 0);
converterLookup.registerConverter(
new ReflectionConverter(mapper, reflectionProvider), -1);
}
示例8: createDriver
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
protected HierarchicalStreamDriver createDriver() {
// if the system property is set, use it to load the driver
String driver = null;
try {
driver = System.getProperty("xstream.driver");
if (driver != null) {
System.out.println("Using driver: " + driver);
Class type = Class.forName(driver);
return (HierarchicalStreamDriver) type.newInstance();
}
}
catch (Exception e) {
throw new RuntimeException("Could not load driver: " + driver);
}
return new XppDriver();
}
示例9: setUp
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
protected void setUp() throws Exception {
super.setUp();
// server side setup.
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
server = new SocketServer((ServerMonitor) mockServerMonitor.proxy(), new RefusingStubRetriever(), new NullAuthenticator(),
new XmlStream(new XStream(new XppDriver())), executorService, new ThreadLocalServerContextFactory(), new InetSocketAddress(10099));
testServer = new TestFacadeImpl();
Publication pd = new Publication(TestFacade.class).addAdditionalFacades(TestFacade3.class, TestFacade2.class);
server.publish(testServer, "Hello", pd);
server.start();
// Client side setup
sr = new ServiceResolver(new SocketTransport(new ConsoleClientMonitor(),
new org.codehaus.jremoting.client.streams.XmlStream(new XStream(new XppDriver())), new SocketDetails("127.0.0.1", 10099)));
testClient = sr.resolveService("Hello");
}
示例10: setUp
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
protected void setUp() throws Exception {
super.setUp();
// server side setup.
ScheduledExecutorService executorService = Executors.newScheduledThreadPool(10);
server = new SocketServer((ServerMonitor) mockServerMonitor.proxy(), new RefusingStubRetriever(), new NullAuthenticator(),
new XmlStream(new XStream(new XppDriver())), executorService, new ThreadLocalServerContextFactory(), new InetSocketAddress(10099));
testServer = new TestFacadeImpl();
Publication pd = new Publication(TestFacade.class).addAdditionalFacades(TestFacade3.class, TestFacade2.class);
server.publish(testServer, "Hello", pd);
server.start();
// Client side setup
sr = new ServiceResolver(new SocketTransport(
new ConsoleClientMonitor(), new org.codehaus.jremoting.client.streams.XmlStream(
new XStream(new XppDriver())), new SocketDetails("127.0.0.1", 10099)
), new StubsOnClient());
testClient = sr.resolveService("Hello");
}
示例11: get
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public synchronized static XStream get(String type) {
if (JAXP_DOM_XML.equals(type)) {
xstream = createXMLXStream();
xstream.autodetectAnnotations(true);
} else if (XPP3_XML_PARSER.equals(type)) {
xstream = new XStream(new XppDriver());
xstream.autodetectAnnotations(true);
} else if (STAX_JSON_PARSER.equals(type)) {
xstream = new XStream(new JettisonMappedXmlDriver());
xstream.setMode(XStream.NO_REFERENCES);
} else if (WRITER_JSON_PARSER.equals(type)) {
xstream = new XStream(new JsonHierarchicalStreamDriver());
xstream.setMode(XStream.NO_REFERENCES);
} else {
xstream = createXMLXStream();
xstream.autodetectAnnotations(true);
}
return xstream;
}
示例12: buildXstream
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
private XStream buildXstream() {
return new XStream(new XppDriver() {
public HierarchicalStreamWriter createWriter(Writer out) {
return new PrettyPrintWriter(out) {
List<String> cdataFields = asList("title", "author");
boolean cdata = false;
public void startNode(String name, Class clazz) {
super.startNode(name, clazz);
cdata = cdataFields.contains(name);
}
protected void writeText(QuickWriter writer, String text) {
if (cdata) {
writer.write("<![CDATA[");
writer.write(text);
writer.write("]]>");
} else {
writer.write(text);
}
}
};
}
});
}
示例13: saveToFile
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
/**
* writes glossary to xml-file prepend doc-book dtd: <!DOCTYPE glossary PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
* "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd">
*
* @param glossaryFile
* @param glossaryItemArr
*/
private void saveToFile(VFSLeaf glossaryFile, ArrayList<GlossaryItem> glossaryItemArr) {
// cdata-tags should be used instead of strings, overwrite writer.
XStream xstream = new XStream(new XppDriver() {
@Override
public HierarchicalStreamWriter createWriter(Writer out) {
return new PrettyPrintWriter(out) {
@Override
protected void writeText(QuickWriter writer, String text) {
if (text.contains("<") || text.contains(">") || text.contains("&")) {
writer.write("<![CDATA[");
writer.write(text);
writer.write("]]>");
} else {
writer.write(text);
}
}
};
}
});
xstream.alias(XML_GLOSSARY_ITEM_NAME, GlossaryItem.class);
glossaryItemArr = removeEmptyGlossaryItems(glossaryItemArr);
XStreamHelper.writeObject(xstream, glossaryFile, glossaryItemArr);
}
示例14: getLoteXStream
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public static XStream getLoteXStream()
{
XStream xstream = new XStream(new XppDriver()
{
public HierarchicalStreamWriter createWriter(Writer out)
{
return new PrettyPrintWriter(out)
{
protected void writeText(QuickWriter writer, String text)
{
writer.write(text);
}
};
}
});
xstream.alias("lote", LoteXml.class);
xstream.alias("comprobante", ComprobanteXml.class);
xstream.registerConverter(new ComprobanteXmlConverter());
return xstream;
}
示例15: getRespuestaXStream
import com.thoughtworks.xstream.io.xml.XppDriver; //導入依賴的package包/類
public static XStream getRespuestaXStream()
{
XStream xstream = new XStream(new XppDriver()
{
public HierarchicalStreamWriter createWriter(Writer out)
{
return new PrettyPrintWriter(out)
{
protected void writeText(QuickWriter writer, String text)
{
writer.write(text);
}
};
}
});
xstream.alias("respuesta", RespuestaComprobante.class);
xstream.alias("autorizacion", Autorizacion.class);
xstream.alias("fechaAutorizacion", XMLGregorianCalendarImpl.class);
xstream.alias("mensaje", Mensaje.class);
xstream.registerConverter(new RespuestaDateConverter());
return xstream;
}