com.thoughtworks.xstream.io.xml.DomDriver Java Examples
The following examples show how to use
com.thoughtworks.xstream.io.xml.DomDriver.
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: ExcelUtils.java From onetwo with Apache License 2.0 | 6 votes |
public static XStream registerExcelModel(){ XStream xstream = new XStream(new DomDriver()); xstream.alias("workbook", WorkbookModel.class); xstream.alias("vars", List.class); xstream.alias("var", VarModel.class); xstream.alias("sheets", List.class); xstream.alias("template", TemplateModel.class); xstream.alias("sheet", TemplateModel.class); xstream.alias("rows", List.class); xstream.alias("row", RowModel.class); xstream.alias("field", FieldModel.class); xstream.alias("valueExecutors", List.class); xstream.alias("valueExecutor", ExecutorModel.class); // xstream.useAttributeFor(Number.class); // xstream.useAttributeFor(boolean.class); // xstream.useAttributeFor(String.class); // xstream.useAttributeFor(int.class); xstream.useAttributeFor(String.class); for(Class<?> btype : getBaseTypeClass()){ xstream.useAttributeFor(btype); } return xstream; }
Example #2
Source File: UThReduxAliquot.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #3
Source File: PbBlank.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available @post <code>XStream</code> * for XML decoding is returned * * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #4
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 #5
Source File: MineralStandardModel.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ private XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #6
Source File: XStreamUtility.java From swingsane with Apache License 2.0 | 6 votes |
private static XStream loadXStream() { XStream xstream = new XStream(new DomDriver("UTF-8")) { @Override protected MapperWrapper wrapMapper(MapperWrapper next) { return new MapperWrapper(next) { @Override public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn, String fieldName) { if (definedIn == Object.class) { return false; } return super.shouldSerializeMember(definedIn, fieldName); } }; } }; xstream.setMode(XStream.NO_REFERENCES); return xstream; }
Example #7
Source File: AcceptanceTestContext.java From gatf with Apache License 2.0 | 6 votes |
private void initTestDataProviderAndGlobalVariables() { GatfTestDataConfig gatfTestDataConfig = null; if(gatfExecutorConfig.getTestDataConfigFile()!=null) { File file = getResourceFile(gatfExecutorConfig.getTestDataConfigFile()); Assert.assertNotNull("Testdata configuration file not found...", file); Assert.assertEquals("Testdata configuration file not found...", file.exists(), true); XStream xstream = new XStream(new DomDriver("UTF-8")); XStream.setupDefaultSecurity(xstream); xstream.allowTypes(new Class[]{GatfTestDataConfig.class, GatfTestDataProvider.class}); xstream.processAnnotations(new Class[]{GatfTestDataConfig.class, GatfTestDataProvider.class}); xstream.alias("gatf-testdata-provider", GatfTestDataProvider.class); xstream.alias("args", String[].class); xstream.alias("arg", String.class); gatfTestDataConfig = (GatfTestDataConfig)xstream.fromXML(file); gatfExecutorConfig.setGatfTestDataConfig(gatfTestDataConfig); } else { gatfTestDataConfig = gatfExecutorConfig.getGatfTestDataConfig(); } handleTestDataSourcesAndHooks(gatfTestDataConfig); }
Example #8
Source File: PhysicalConstants.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ private XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #9
Source File: BluetoothGattSpecificationReader.java From bluetooth-gatt-parser with Apache License 2.0 | 6 votes |
private <T> T getSpec(URL file) { try { XStream xstream = new XStream(new DomDriver()); xstream.autodetectAnnotations(true); xstream.processAnnotations(Bit.class); xstream.processAnnotations(BitField.class); xstream.processAnnotations(Characteristic.class); xstream.processAnnotations(Enumeration.class); xstream.processAnnotations(Enumerations.class); xstream.processAnnotations(Field.class); xstream.processAnnotations(InformativeText.class); xstream.processAnnotations(Service.class); xstream.processAnnotations(Value.class); xstream.processAnnotations(Reserved.class); xstream.processAnnotations(Examples.class); xstream.processAnnotations(CharacteristicAccess.class); xstream.processAnnotations(Characteristics.class); xstream.processAnnotations(Properties.class); xstream.ignoreUnknownElements(); xstream.setClassLoader(Characteristic.class.getClassLoader()); return (T) xstream.fromXML(file); } catch (Exception e) { logger.error("Could not read file: " + file, e); } return null; }
Example #10
Source File: XmlUtil.java From CoreModule with Apache License 2.0 | 6 votes |
/** * 将一个xml流转换为bean实体类 * * @param type * @param is * @return */ @SuppressWarnings("unchecked") public synchronized static <T> T toBean(Class<T> type, InputStream is) { XStream xmStream = new XStream(new DomDriver()); // 设置可忽略为在javabean类中定义的界面属性 xmStream.ignoreUnknownElements(); xmStream.processAnnotations(type); T obj = null; try { obj = (T) xmStream.fromXML(is); } catch (Exception e) { Logger.log("===解析xml发生异常:" + e.getMessage()); } finally { FileUtils.closeIO(is); } return obj; }
Example #11
Source File: Job.java From scava with Eclipse Public License 2.0 | 6 votes |
public String getXML() { String id = this.id; int failures = this.getFailures(); String correlationId = this.correlationId; boolean cached = this.cached; boolean cacheable = this.cacheable; this.id = null; this.correlationId = null; this.failures = 0; this.cached = false; this.cacheable = true; String xml = new XStream(new DomDriver()).toXML(this); this.id = id; this.correlationId = correlationId; this.cached = cached; this.failures = failures; this.cacheable = cacheable; return xml; }
Example #12
Source File: ShardTableRuleFactoryBean.java From AsuraFramework with Apache License 2.0 | 6 votes |
/** * * 加载配置文件 * @return * @throws Exception */ @SuppressWarnings("unchecked") protected Map<String, Rule> loadRules() throws Exception { final Map<String, Rule> routerMap = new HashMap<String, Rule>(); if (getRuleConfige() != null) { final XStream xstream = new XStream(new DomDriver()); xstream.alias("rules", List.class); xstream.alias("rule", Entity.class); List<Entity> rules = new ArrayList<Entity>(); rules = (List<Entity>) xstream.fromXML(getRuleConfige().getInputStream()); for (final Entity entity : rules) { final Rule router = new Rule(); final Class<?> clazz = Class.forName(entity.strategy); final IStrategy instance = (IStrategy) clazz.newInstance(); instance.initStrategy(entity.tables.split(",")); router.setShardStrategy(instance); router.setXmlTableParam(entity.tableParam); router.setFieldParam(entity.field); makeRouterMap(entity, router, routerMap); } } return routerMap; }
Example #13
Source File: Parser.java From KJFrameForAndroid with Apache License 2.0 | 6 votes |
public static <T> T xmlToBean(Class<T> type, String xml) { T data = null; try { XStream xStream = new XStream(new DomDriver("UTF-8")); xStream.processAnnotations(type); data = (T) xStream.fromXML(xml); } catch (Exception e) { try { data = type.newInstance(); } catch (Exception ee) { } finally { Log.e("kymjs", "xml解析异常"); } } return data; }
Example #14
Source File: AnalysisFraction.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #15
Source File: UPbFraction.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ private XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #16
Source File: UPbReduxAliquot.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #17
Source File: SampleMetaData.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available * @post <code>XStream</code> for XML decoding is returned * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #18
Source File: SESARSampleMetadata.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * gets an <code>XStream</code> reader. Creates, customizes, and returns * <code>XStream</code> for XML serialization * * @pre <code>XStream</code> package is available * @post <code>XStream</code> for XML decoding is returned * @return <code>XStream</code> - for XML serialization decoding */ public XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #19
Source File: AbstractRatiosDataModel.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ protected XStream getXStream() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #20
Source File: ReportSettingsInterface.java From ET_Redux with Apache License 2.0 | 6 votes |
/** * * @return */ public default XStream getXStreamReader() { XStream xstream = new XStream(new DomDriver()); customizeXstream(xstream); // http://x-stream.github.io/security.html XStream.setupDefaultSecurity(xstream); // clear out existing permissions and set own ones xstream.addPermission(NoTypePermission.NONE); // allow some basics xstream.addPermission(NullPermission.NULL); xstream.addPermission(PrimitiveTypePermission.PRIMITIVES); xstream.allowTypeHierarchy(Collection.class); xstream.addPermission(AnyTypePermission.ANY); return xstream; }
Example #21
Source File: ReplaceableSingleValueConverterTest.java From saros with GNU General Public License v2.0 | 5 votes |
@Test public void reset() { /* Mocks */ SingleValueConverter c1 = EasyMock.createMock(SingleValueConverter.class); expect(c1.canConvert(Dummy.class)).andStubReturn(true); EasyMock.expect(c1.toString(isA(Object.class))).andReturn("dummy").once(); EasyMock.replay(c1); /* XStream config */ XStream xstream = XStreamFactory.getSecureXStream(new DomDriver()); ReplaceableSingleValueConverter resetable = new ReplaceableSingleValueConverter(c1); xstream.registerConverter(resetable); /* Test it */ assertFalse("ReplaceableSingleValueConverter was not properly set up", resetable.isReset()); assertNotNull("Converter cannot convert", xstream.toXML(new Dummy())); resetable.reset(); assertTrue("ReplaceableSingleValueConverter was not properly reset", resetable.isReset()); /* * This call should not reach the actual converter. */ xstream.toXML(new Dummy()); /* * Verify that the converter was used exactly once, i.e. it was not * called while it was inactive. */ EasyMock.verify(c1); }
Example #22
Source File: XmlUtil.java From EasyEE with MIT License | 5 votes |
/** * java bean 转化为xml * * @param object * @param objClass * @return */ public static String parseBeanToXml(Object object, Class<?> objClass) { String xmlString = ""; XStream xStream = new XStream(new DomDriver()); xStream.processAnnotations(objClass); xmlString = xStream.toXML(object); xmlString = header + xmlString; return xmlString; }
Example #23
Source File: ResourceTransportWrapperConverterTest.java From saros with GNU General Public License v2.0 | 5 votes |
@Test public void conversionLeavingReceiver() { /* Mocks */ ISarosSession senderSession = EasyMock.createMock(ISarosSession.class); expect(senderSession.getReferencePointId(referencePoint)).andStubReturn("ABC"); expect(senderSession.getReferencePoint("ABC")).andStubReturn(referencePoint); ISarosSession receiverSession = EasyMock.createMock(ISarosSession.class); expect(receiverSession.getReferencePointId(referencePoint)).andReturn("ABC"); expect(receiverSession.getReferencePoint("ABC")).andReturn(referencePoint); expect(receiverSession.getReferencePointId(referencePoint)).andReturn(null); expect(receiverSession.getReferencePoint("ABC")).andReturn(null); EasyMock.replay(senderSession, receiverSession); /* XStream */ XStream sender = XStreamFactory.getSecureXStream(new DomDriver()); sender.registerConverter(new ResourceTransportWrapperConverter(senderSession, pathFactory)); XStream receiver = XStreamFactory.getSecureXStream(new DomDriver()); receiver.registerConverter(new ResourceTransportWrapperConverter(receiverSession, pathFactory)); /* Test */ ResourceTransportWrapper<IFile> wrappedFile = new ResourceTransportWrapper<>(file); // first call on running session on receiver side receiver.fromXML(sender.toXML(wrappedFile)); // second call on non-functional session on receiver side ResourceTransportWrapper<?> copy2 = (ResourceTransportWrapper<?>) receiver.fromXML(sender.toXML(wrappedFile)); assertNull(copy2); }
Example #24
Source File: XMLTestCaseFinder.java From gatf with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") public List<TestCase> resolveTestCases(File testCaseFile) throws Exception { XStream xstream = new XStream(new DomDriver("UTF-8")); XStream.setupDefaultSecurity(xstream); xstream.allowTypes(new Class[]{TestCase.class}); xstream.processAnnotations(new Class[]{TestCase.class}); xstream.alias("TestCases", List.class); List<TestCase> xmlTestCases = (List<TestCase>)xstream.fromXML(testCaseFile); return xmlTestCases; }
Example #25
Source File: XmlUtil.java From EasyEE with MIT License | 5 votes |
/** * java bean 转化为xml * * @param object * @param objClass * @return */ public static String parseBeanToXml(Object object, Class<?> objClass) { String xmlString = ""; XStream xStream = new XStream(new DomDriver()); xStream.processAnnotations(objClass); xmlString = xStream.toXML(object); xmlString = header + xmlString; return xmlString; }
Example #26
Source File: XmlUtil.java From EasyEE with MIT License | 5 votes |
/** * java bean 转化为xml * * @param object * @param objClass * @return */ public static String parseBeanToXml(Object object, Class<?> objClass) { String xmlString = ""; XStream xStream = new XStream(new DomDriver()); xStream.processAnnotations(objClass); xmlString = xStream.toXML(object); xmlString = header + xmlString; return xmlString; }
Example #27
Source File: XmlUtil.java From EasyEE with MIT License | 5 votes |
/** * java bean 转化为xml * * @param object * @param objClass * @return */ public static String parseBeanToXml(Object object, Class<?> objClass) { String xmlString = ""; XStream xStream = new XStream(new DomDriver()); xStream.processAnnotations(objClass); xmlString = xStream.toXML(object); xmlString = header + xmlString; return xmlString; }
Example #28
Source File: VXQueryCompilationListener.java From vxquery with Apache License 2.0 | 5 votes |
/** * Outputs the abstract syntax tree obtained from parsing by serializing the DomDriver object to a pretty-printed XML * String. * * @param moduleNode */ @Override public void notifyParseResult(ModuleNode moduleNode) { if (showAST) { System.err.println("***Abstract Syntax Tree: "); System.err.println(new XStream(new DomDriver()).toXML(moduleNode)); } }
Example #29
Source File: ConfigPersister.java From jmkvpropedit with BSD 2-Clause "Simplified" License | 5 votes |
private ConfigPersister() { _xstream = new XStream(new DomDriver()); _xstream.alias("launch4jConfig", Config.class); _xstream.alias("classPath", ClassPath.class); _xstream.alias("jre", Jre.class); _xstream.alias("splash", Splash.class); _xstream.alias("versionInfo", VersionInfo.class); _xstream.addImplicitCollection(Config.class, "headerObjects", "obj", String.class); _xstream.addImplicitCollection(Config.class, "libs", "lib", String.class); _xstream.addImplicitCollection(Config.class, "variables", "var", String.class); _xstream.addImplicitCollection(ClassPath.class, "paths", "cp", String.class); _xstream.addImplicitCollection(Jre.class, "options", "opt", String.class); }
Example #30
Source File: StreamConverter.java From gama with GNU General Public License v3.0 | 5 votes |
public static XStream loadAndBuildNetwork(final ConverterScope cs) { final XStream dataStreamer = new XStream(new DomDriver()); dataStreamer.setClassLoader(GamaClassLoader.getInstance()); final Converter[] cnv = Converters.converterNetworkFactory(cs); for (final Converter c : cnv) { StreamConverter.registerConverter(dataStreamer, c); } return dataStreamer; }