Refine search
private HierarchicalStreamDriver getDefaultDriver() { if (this.defaultDriver == null) { this.defaultDriver = new XppDriver(); } return this.defaultDriver; }
@Override public HierarchicalStreamReader createReader(URL in) { return xppDriver.createReader(in); }
protected XmlPullParser createParser() throws XmlPullParserException { return createDefaultParser(); } }
public String toString() { XStream xstream = new XStream(new XppDriver(new NoNameCoder())); xstream.setMode(XStream.NO_REFERENCES); xstream.processAnnotations(getClass()); return xstream.toXML(this); } }
public PreOLOutput enviarPreOL(PreOLInput preOLInput) { XStream xstream = new XStream(new XppDriver(new NoNameCoder())); xstream.autodetectAnnotations(true); final String xml = xstream.toXML(preOLInput); final String xmlRetornoPreOL = xstream.toXML(new PreOLOutput()); String xmlRetorno = null;
public void readUserProfilesData(String filePath) throws Exception { userProfilesData.clear(); XStream xstreamProfile_ = new XStream(new XppDriver()); xstreamProfile_.alias("user-profile", UserProfileImpl.class); FileInputStream fin = new FileInputStream(filePath); ZipInputStream zin = new ZipInputStream(fin); ZipEntry ze = null; while ((ze = zin.getNextEntry()) != null) { if (ze.getName().contains("_profile.xml")) { ByteArrayOutputStream fout = new ByteArrayOutputStream(); for (int c = zin.read(); c != -1; c = zin.read()) { fout.write(c); } zin.closeEntry(); UserProfileImpl userProfile = (UserProfileImpl) xstreamProfile_.fromXML(new String(fout.toByteArray())); userProfilesData.add(userProfile); } } zin.close(); }
final @Test public void testSER_isXStreamSerializable() { if ((getComponentAdapterNature() & SERIALIZABLE) > 0) { final MutablePicoContainer picoContainer = new DefaultPicoContainer(createDefaultComponentFactory()); final ComponentAdapter componentAdapter = prepSER_isXStreamSerializable(picoContainer); assertSame(getComponentAdapterType(), componentAdapter.getClass()); final Object instance = componentAdapter.getComponentInstance(picoContainer, ComponentAdapter.NOTHING.class); assertNotNull(instance); final XStream xstream = new XStream(new XppDriver()); final String xml = xstream.toXML(componentAdapter); final ComponentAdapter serializedComponentAdapter = (ComponentAdapter)xstream.fromXML(xml); assertEquals(componentAdapter.getComponentKey(), serializedComponentAdapter.getComponentKey()); final Object instanceAfterSerialization = serializedComponentAdapter.getComponentInstance(picoContainer, ComponentAdapter.NOTHING.class); assertNotNull(instanceAfterSerialization); assertSame(instance.getClass(), instanceAfterSerialization.getClass()); } }
/** * Transforms the provided workflow to an XML representation. * * @param fullWorkflow A workflow, including its rules, actions and conditions, to convert to XML. * @return XML representation of the workflow and its children. * @throws NullPointerException if {@code fullWorkflow} is null * @throws WorkflowTransformerException if there is an error transforming workflow to XML representation */ public static String transformFullWorkflowToXml(FullWorkflow fullWorkflow) throws NullPointerException, WorkflowTransformerException { Objects.requireNonNull(fullWorkflow); final XStream xstream = new XStream(new XppDriver(new NoNameCoder())); xstream.alias("workflow", FullWorkflow.class); xstream.alias("processingRule", FullProcessingRule.class); xstream.alias("action", FullAction.class); xstream.alias("condition", ExistingCondition.class); xstream.registerConverter(new KeyAsElementNameMapConverter(xstream.getMapper(), "value", String.class)); xstream.registerConverter(new GeneralEnumToStringConverter()); xstream.registerConverter(new TypeAttributeCollectionConverter(xstream.getMapper())); xstream.omitField(BaseProcessingRule.class, "enabled"); xstream.omitField(BaseProcessingRule.class, "description"); xstream.omitField(Action.class, "description"); xstream.omitField(BaseWorkflow.class, "description"); xstream.omitField(BaseWorkflow.class, "notes"); final String asXml = xstream.toXML(fullWorkflow); return asXml; }
XStream xstream_ = new XStream(new XppDriver()); int i = 0; while (i <= usersListAccess.getSize()) { for (User user : users) { if (user != null) { xstream_.alias("user", user.getClass()); String xml = xstream_.toXML(user); zos.putNextEntry(new ZipEntry(SerializationUtils.USERS_FOLDER_NAME + user.getUserName() + SerializationUtils.USER_FILE_SUFFIX));
public static XStream createXStream() { HierarchicalStreamDriver driver; if (isXppAvaliable()) { driver = new XppDriver(); } else { driver = new DomDriver(); } final XStream xStream = new XStream(new Sun14ReflectionProvider(), driver); xStream.registerConverter(ENUM_CONVERTER); addThisClassLoader(xStream); return xStream; }
private static XStream createXStream() { XStream xstream = new XStream(new PureJavaReflectionProvider(),new XppDriver(), new ClassLoaderReference(Thread.currentThread().getContextClassLoader())); xstream.registerConverter(new JavaBeanConverter(xstream.getMapper())); return xstream; }
/** * Updates a {@link Credentials} by its XML definition. * * @param source source of the Item's new definition. * The source should be either a <code>StreamSource</code> or a <code>SAXSource</code>, other * sources may not be handled. * @throws IOException if things go wrong. * @since 2.1.1 */ @Restricted(NoExternalUse.class) public void updateByXml(Source source) throws IOException { getStore().checkPermission(CredentialsProvider.MANAGE_DOMAINS); final StringWriter out = new StringWriter(); try { XMLUtils.safeTransform(source, new StreamResult(out)); out.close(); } catch (TransformerException e) { throw new IOException("Failed to parse credential", e); } catch (SAXException e) { throw new IOException("Failed to parse credential", e); } Domain replacement = (Domain) Items.XSTREAM.unmarshal(new XppDriver().createReader(new StringReader(out.toString()))); getStore().updateDomain(domain, replacement); }
/** * Save a sampleResult to an XML output file using XStream. * * @param evt sampleResult wrapped in a sampleEvent * @param writer output stream which must be created using {@link #getFileEncoding(String)} * @throws IOException when writing data to output fails */ // Used by ResultCollector.sampleOccurred(SampleEvent event) public synchronized static void saveSampleResult(SampleEvent evt, Writer writer) throws IOException { DataHolder dh = JTLSAVER.newDataHolder(); dh.put(SAMPLE_EVENT_OBJECT, evt); // This is effectively the same as saver.toXML(Object, Writer) except we get to provide the DataHolder // Don't know why there is no method for this in the XStream class try { JTLSAVER.marshal(evt.getResult(), new XppDriver().createWriter(writer), dh); } catch(RuntimeException e) { throw new IllegalArgumentException("Failed marshalling:"+(evt.getResult() != null ? showDebuggingInfo(evt.getResult()) : "null"), e); } writer.write('\n'); }
/** * Read results from JTL file. * * @param reader of the file * @param resultCollectorHelper helper class to enable TestResultWrapperConverter to deliver the samples * @throws IOException if an I/O error occurs */ public static void loadTestResults(InputStream reader, ResultCollectorHelper resultCollectorHelper) throws IOException { // Get the InputReader to use InputStreamReader inputStreamReader = getInputStreamReader(reader); DataHolder dh = JTLSAVER.newDataHolder(); dh.put(RESULTCOLLECTOR_HELPER_OBJECT, resultCollectorHelper); // Allow TestResultWrapper to feed back the samples // This is effectively the same as saver.fromXML(InputStream) except we get to provide the DataHolder // Don't know why there is no method for this in the XStream class JTLSAVER.unmarshal(new XppDriver().createReader(reader), null, dh); inputStreamReader.close(); }
protected static HierarchicalStreamReader safeXmlStreamReader(Source source) throws IOException { final StringWriter out = new StringWriter(); try { XMLUtils.safeTransform(source, new StreamResult(out)); out.close(); } catch (TransformerException e) { throw new IOException("Failed to parse", e); } catch (SAXException e) { throw new IOException("Failed to parse", e); } return new XppDriver().createReader(new StringReader(out.toString())); } }