Package com.thoughtworks.xstream

Examples of com.thoughtworks.xstream.XStream


     * @param mediaType
     *            The serialization media type.
     * @return The XStream object.
     */
    protected XStream createXstream(MediaType mediaType) {
        XStream result = null;

        try {
            if (MediaType.APPLICATION_JSON.isCompatible(mediaType)) {
                result = new XStream(getJsonDriverClass().newInstance());
                result.setMode(XStream.NO_REFERENCES);
            } else {
                result = new XStream(getXmlDriverClass().newInstance());
            }

            result.autodetectAnnotations(true);
        } catch (Exception e) {
            Context.getCurrentLogger().log(Level.WARNING,
                    "Unable to create the XStream driver.", e);
        }

View Full Code Here


    public Object handle( Object params )
    {
        if ( log.isLoggable( Level.FINEST ) )
        {
            XStream xstream = new XStream();
            log.log( Level.FINEST, xstream.toXML( params ) );
        }

        if ( params instanceof ObjectBean )
        {
            ObjectBean bean = new ObjectBean();
View Full Code Here

  }

  public Collection query() {
    try {
      if (new File(filename).exists()) {
        XStream xstream = new XStream(new DomDriver());
        xstream.setMode(XStream.ID_REFERENCES);
        FileReader reader = new FileReader(filename);
        objects = (Set) xstream.fromXML(reader);
        reader.close();
      }
      return objects;
    } catch (Exception e) {
      e.printStackTrace();
View Full Code Here

    }
  }

  public void close() {
    try {
      XStream xstream = new XStream(new DomDriver());
      xstream.setMode(XStream.ID_REFERENCES);
      FileWriter writer = new FileWriter(filename);
      xstream.toXML(objects, writer);
      writer.close();
    } catch (Exception e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
View Full Code Here

  /**
   * Writes objects to XML-File.
   */
  public void write(Collection objects) {
    try {
      XStream xstream = new XStream(new DomDriver());
      xstream.setMode(XStream.ID_REFERENCES);
      FileWriter writer = new FileWriter(filename);
      xstream.toXML(new ArrayList(objects), writer);
      writer.close();
    } catch (IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
    }
View Full Code Here

  /**
   * Reads collection from XML-File.
   */
  public Collection read() {
    try {
      XStream xstream = new XStream(new DomDriver());
      xstream.setMode(XStream.ID_REFERENCES);
      FileReader reader = new FileReader(filename);
      List objects = (List) xstream.fromXML(reader);
      reader.close();
      return objects;
    } catch (IOException e) {
      e.printStackTrace();
      throw new RuntimeException(e);
View Full Code Here

  private XStream xstream;
  private Converter nodeConverter;
  private Converter nodeArrayConverter;

  public Serializer() {
    xstream = new XStream();
    xstream.registerConverter(new BlobConverter());
    nodeConverter = new SingleValueConverterWrapper(new NodeConverter());
    nodeArrayConverter = new DelegateArrayConverter(nodeConverter,
        xstream.getMapper());
  }
View Full Code Here

  private static class Component {
    String domain, editor, icon, view;
  }

  private static void init(String resource) throws Exception {
    XStream xstream = new XStream();
    xstream.alias("jease", List.class);
    xstream.alias("component", Component.class);
    Enumeration<URL> urls = Registry.class.getClassLoader().getResources(
        resource);
    while (urls.hasMoreElements()) {
      InputStream url = urls.nextElement().openStream();
      for (Component component : (List<Component>) xstream.fromXML(url)) {
        registerComponent(component);
      }
      url.close();
    }
    initDomainTypes(editors.keySet());
View Full Code Here

  /**
   * Factory to create a fresh XStream instance. Use this when reading and
   * writing to a configured XML mapping
   */
  public static XStream createXStreamInstance() {
    return new XStream();
  }
View Full Code Here

   * @see org.olat.core.commons.modules.glossary.morphService.FlexionServiceClient#getFlexions(java.lang.String,
   *      java.lang.String)
   */
  public ArrayList<String> getFlexions(String partOfSpeech, String word) {
    InputStream xmlReplyStream = retreiveXMLReply(partOfSpeech, word);
    XStream xstream = XStreamHelper.createXStreamInstance();
    xstream.alias("xml", FlexionReply.class);
    xstream.alias("wordform", String.class);
    ArrayList<String> stemWithWordforms;
    try {
      Object msReply = XStreamHelper.readObject(xstream, xmlReplyStream);
      FlexionReply flexionReply = (FlexionReply) msReply;
      // set reply status to remind it
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.XStream

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.