Java Code Examples for com.thoughtworks.xstream.XStream#setMode()
The following examples show how to use
com.thoughtworks.xstream.XStream#setMode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ViewDocXStreamConfig.java From depan with Apache License 2.0 | 6 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias(VIEW_PREFS, ViewPreferences.class); converter = ViewDocumentConverter.configXStream(xstream); EdgeReferenceConverter.configXStream(xstream, converter); NodeReferenceConverter.configXStream(xstream, converter); CameraPosConverter.configXStream(xstream); CameraDirConverter.configXStream(xstream); GraphModelReferenceConverter.configXStream(xstream); Point2DConverter.configXStream(xstream); ViewExtensionConverter.configXStream(xstream); }
Example 2
Source File: PersistenceEngineXStream.java From jease with GNU General Public License v3.0 | 6 votes |
@Override public Collection<Object> query() { try { if (new File(filename).exists()) { XStream xstream = new XStream(new DomDriver()); xstream.setMode(XStream.ID_REFERENCES); FileReader reader = new FileReader(filename); Object r = xstream.fromXML(reader); clearObjects(); if (r instanceof Collection) { @SuppressWarnings("unchecked") Collection<Object> c = (Collection<Object>) r; objects.addAll(c); } else { objects.add(r); } reader.close(); } return objects; } catch (Exception e) { throw new RuntimeException(e.getMessage(), e); } }
Example 3
Source File: XStreamInitializer.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public static XStream getInstance() { XStream xstream = new XStream(new XppDriver() { @Override public HierarchicalStreamWriter createWriter(Writer out) { return new PrettyPrintWriter(out, getNameCoder()) { protected String PREFIX_CDATA = "<![CDATA["; protected String SUFFIX_CDATA = "]]>"; protected String PREFIX_MEDIA_ID = "<MediaId>"; protected String SUFFIX_MEDIA_ID = "</MediaId>"; @Override protected void writeText(QuickWriter writer, String text) { if (text.startsWith(PREFIX_CDATA) && text.endsWith(SUFFIX_CDATA)) { writer.write(text); } else if (text.startsWith(PREFIX_MEDIA_ID) && text.endsWith(SUFFIX_MEDIA_ID)) { writer.write(text); } else { super.writeText(writer, text); } } }; } }); xstream.ignoreUnknownElements(); xstream.setMode(XStream.NO_REFERENCES); xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); return xstream; }
Example 4
Source File: XmlXstreamTest.java From amforeas with GNU General Public License v3.0 | 5 votes |
public static ErrorResponse errorFromXML (final String xml) { XStream xStreamInstance = new XStream(); xStreamInstance.setMode(XStream.NO_REFERENCES); xStreamInstance.autodetectAnnotations(false); xStreamInstance.alias("response", ErrorResponse.class); return (ErrorResponse) xStreamInstance.fromXML(xml); }
Example 5
Source File: UserDashboardPersister.java From openmeetings with Apache License 2.0 | 5 votes |
public XStreamDashboardPersister() { this.file = getUserDashboard(getUserId()); xstream = new XStream(new DomDriver(UTF_8.name())); xstream.setMode(XStream.NO_REFERENCES); xstream.addPermission(NoTypePermission.NONE); xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypesByWildcard(new String[] {"org.apache.openmeetings.web.**"}); xstream.allowTypeHierarchy(ArrayList.class); xstream.alias("dashboard", UserDashboard.class); }
Example 6
Source File: XmlXstreamTest.java From amforeas with GNU General Public License v3.0 | 5 votes |
public static SuccessResponse successFromXML (final String xml) { XStream xStreamInstance = new XStream(); xStreamInstance.setMode(XStream.NO_REFERENCES); xStreamInstance.autodetectAnnotations(false); xStreamInstance.alias("response", SuccessResponse.class); xStreamInstance.alias("row", Row.class); xStreamInstance.alias("cells", HashMap.class); xStreamInstance.alias("roi", Integer.class); xStreamInstance.registerConverter(new AmforeasMapConverter()); xStreamInstance.addImplicitCollection(SuccessResponse.class, "rows", Row.class); return (SuccessResponse) xStreamInstance.fromXML(xml); }
Example 7
Source File: XStreamFile.java From jease with GNU General Public License v3.0 | 5 votes |
/** * Reads collection from XML-File. */ public Collection<Object> read() { try { XStream xstream = new XStream(new DomDriver()); xstream.setMode(XStream.ID_REFERENCES); FileReader reader = new FileReader(filename); List<Object> objects = (List<Object>) xstream.fromXML(reader); reader.close(); return objects; } catch (IOException e) { throw new RuntimeException(e.getMessage(), e); } }
Example 8
Source File: GerritAssert.java From gerrit-rest-java-client with Apache License 2.0 | 5 votes |
private static void assertXmlOutputEqual(Object actual, Object expected) { XStream xStream = new XStream(); xStream.setMode(XStream.NO_REFERENCES); xStream.aliasSystemAttribute(null, "class"); // we only care about the content (but not internal attributes) xStream.aliasSystemAttribute(null, "resolves-to"); String actualXml = xStream.toXML(actual); String expectedXml = xStream.toXML(expected); Truth.assertThat(actualXml).isEqualTo(expectedXml); }
Example 9
Source File: CoreUtil.java From ctsms with GNU Lesser General Public License v2.1 | 5 votes |
public static String toXML(Object obj, boolean excludeEncryptedFields) throws Exception { XStream xstream = new XStream(); if (excludeEncryptedFields) { OmittedFields.omitFields(xstream); } xstream.setMode(XStream.ID_REFERENCES); return xstream.toXML(obj); }
Example 10
Source File: ProjectSlackNotificationsBeanJsonSerialiser.java From tcSlackBuildNotifier with MIT License | 5 votes |
public static String serialise(ProjectSlackNotificationsBean project){ XStream xstream = new XStream(new JsonHierarchicalStreamDriver()); xstream.setMode(XStream.NO_REFERENCES); xstream.alias("projectSlacknotificationConfig", ProjectSlackNotificationsBean.class); /* For some reason, the items are coming back as "@name" and "@value" * so strip those out with a regex. */ return xstream.toXML(project); }
Example 11
Source File: ConsultarLoteRpsResposta.java From nfse with MIT License | 5 votes |
public static ConsultarLoteRpsResposta toPojo(String xml) { XStream xstream = new XStream(); xstream.setMode(XStream.NO_REFERENCES); xstream.autodetectAnnotations(true); xstream.ignoreUnknownElements(); xstream.alias("ConsultarLoteRpsResposta", ConsultarLoteRpsResposta.class); xstream.alias("Nfse", Nfse.class); ConsultarLoteRpsResposta gerarNfseResposta = (ConsultarLoteRpsResposta) xstream.fromXML(xml); return gerarNfseResposta; }
Example 12
Source File: GraphDocXStreamConfig.java From depan with Apache License 2.0 | 5 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias(GRAPH_INFO_TAG, GraphDocument.class); GraphModelConverter.configXStream(xstream); EdgeConverter.configXStream(xstream); }
Example 13
Source File: XStreamInitializer.java From weixin-java-tools with Apache License 2.0 | 5 votes |
public static XStream getInstance() { XStream xstream = new XStream(new PureJavaReflectionProvider(), new XppDriver() { @Override public HierarchicalStreamWriter createWriter(Writer out) { return new PrettyPrintWriter(out, getNameCoder()) { protected String PREFIX_CDATA = "<![CDATA["; protected String SUFFIX_CDATA = "]]>"; protected String PREFIX_MEDIA_ID = "<MediaId>"; protected String SUFFIX_MEDIA_ID = "</MediaId>"; @Override protected void writeText(QuickWriter writer, String text) { if (text.startsWith(this.PREFIX_CDATA) && text.endsWith(this.SUFFIX_CDATA)) { writer.write(text); } else if (text.startsWith(this.PREFIX_MEDIA_ID) && text.endsWith(this.SUFFIX_MEDIA_ID)) { writer.write(text); } else { super.writeText(writer, text); } } @Override public String encodeNode(String name) { //防止将_转换成__ return name; } }; } }); xstream.ignoreUnknownElements(); xstream.setMode(XStream.NO_REFERENCES); xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.setClassLoader(Thread.currentThread().getContextClassLoader()); return xstream; }
Example 14
Source File: FavoritesUtil.java From nextreports-designer with Apache License 2.0 | 4 votes |
public static XStream createXStream() { XStream xstream = new XStream(new DomDriver("UTF-8")); xstream.setMode(XStream.NO_REFERENCES); xstream.alias("favorite", FavoriteEntry.class); return xstream; }
Example 15
Source File: RelationDisplayDocXStreamConfig.java From depan with Apache License 2.0 | 4 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias(RELATION_DISPLAY_INFO_TAG, RelationDisplayDocument.class); }
Example 16
Source File: RemapTaskDocXStreamConfig.java From depan with Apache License 2.0 | 4 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias(REMAP_INFO_TAG, MigrationTask.class); }
Example 17
Source File: NodeKindDocXStreamConfig.java From depan with Apache License 2.0 | 4 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias(NODE_KIND_INFO_TAG, NodeKindDocument.class); }
Example 18
Source File: ContextualFilterXStreamConfig.java From depan with Apache License 2.0 | 4 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias( CONTEXTUAL_FILTER_DOCUMENT_INFO_TAG, ContextualFilterDocument.class); }
Example 19
Source File: EdgeDisplayDocXStreamConfig.java From depan with Apache License 2.0 | 4 votes |
@Override public void config(XStream xstream) { xstream.setMode(XStream.NO_REFERENCES); xstream.alias(EDGE_DISPLAY_INFO_TAG, EdgeDisplayDocument.class); }
Example 20
Source File: ReportObjectStreamFactoryImpl.java From yes-cart with Apache License 2.0 | 3 votes |
/** * Get configured xstream object. * @return {@link XStream} */ private XStream getXStream() { final XStream xStream = new XStream(new DomDriver()); xStream.addPermission(AnyTypePermission.ANY); xStream.setMode(XStream.NO_REFERENCES); return xStream; }