Package com.thoughtworks.xstream

Examples of com.thoughtworks.xstream.XStream


    // retrieve metadata folder
    _metadataFolder = _tmlFile.getParent().getFolder(new Path("metadata"));
    if (_metadataFolder.exists()) {
      _metadataFile = _metadataFolder.getFile(_tmlFile.getName().substring(0, _tmlFile.getName().length() - _tmlFile.getFileExtension().length()) + "metadata.xml");
      if (_metadataFile.exists()) {
        XStream xstream = new XStream(new DomDriver());
        xstream.alias(TMLMetadataInfo.XSTREAM_ALIAS, TMLMetadataInfo.class);
        Reader reader = null;
        try {
          if(!_metadataFile.isSynchronized(IResource.DEPTH_ZERO)){
            _metadataFile.refreshLocal(IResource.DEPTH_ZERO, new NullProgressMonitor());
          }
          reader = new InputStreamReader(_metadataFile.getContents(), _fileEncoding);
          TMLMetadataInfo metaData = (TMLMetadataInfo) xstream.fromXML(reader);
          directAccess = metaData.isDirectAccess();
          cacheable = metaData.isCacheable();
          description = metaData.getDescription();
          category = metaData.getCategory();
        } catch (CoreException e) {
View Full Code Here


      TMLMetadataInfo metaData = new TMLMetadataInfo();
      metaData.setDirectAccess(directAccess);
      metaData.setDescription(description);
      metaData.setCacheable(cacheable);
      metaData.setCategory(category);
      XStream xstream = new XStream(new DomDriver());
      xstream.alias(TMLMetadataInfo.XSTREAM_ALIAS, TMLMetadataInfo.class);
      Writer writer = null;
      try {
        if (!_metadataFolder.exists()) {
          _metadataFolder.create(true, true, new NullProgressMonitor())
          _metadataFile = _metadataFolder.getFile(_tmlFile.getName().substring(0, _tmlFile.getName().length() - _tmlFile.getFileExtension().length()) + "metadata.xml");
        }

        writer = new OutputStreamWriter(new FileOutputStream(_metadataFile.getLocation().toFile()), _fileEncoding);
        xstream.toXML(metaData, writer);
       
      } catch (CoreException e) {
        IOException ioe = new IOException("Unable to save metadata file '" + _metadataFile.getLocation() + "'.");
        ioe.setStackTrace(e.getStackTrace());
        throw ioe;
View Full Code Here

  public static TMLTagDefinitions fromXML(Reader in) {
    return (TMLTagDefinitions) createXStream().fromXML(in);
  }

  private static XStream createXStream() {
    XStream xstream = new XStream(new DomDriver());
    xstream.setClassLoader(TMLTagDefinitions.class.getClassLoader());
    xstream.setMode(XStream.NO_REFERENCES);
    xstream.alias("tagDefinitions", TMLTagDefinitions.class);
    xstream.alias("tag", TMLTag.class);
    xstream.alias("attribute", TMLTagAttribute.class);
    xstream.alias("attributeGroup", TMLAttributeGroup.class);

    addXStreamAliasFields(xstream, getXStreamAliasFields(), TMLTagDefinitions.class);
    addXStreamAliasFields(xstream, TMLAttributeGroup.getXStreamAliasFields(), TMLAttributeGroup.class);
    addXStreamAliasFields(xstream, TMLTag.getXStreamAliasFields(), TMLTag.class);
    addXStreamAliasFields(xstream, TMLTagAttribute.getXStreamAliasFields(), TMLTagAttribute.class);
View Full Code Here

        if (controller != null) {
                ModelAndView modelAndView = controller.handleRequest(request, response);
                if (modelAndView.getModel() != null) {
                    TransportableModel tm = new TransportableModel();
                    tm.putAll(modelAndView.getModel());
                    XStream x = new XStream();
                    x.toXML(tm, response.getWriter());
                }
        }
        return null;
    }
View Full Code Here

            long t = System.currentTimeMillis();
            try {
                shiftFiles(0);
                OutputStream os = new FileOutputStream(makeFile());
                try {
                    new XStream().toXML(statsData, os);
                } finally {
                    os.close();
                }
            } catch (Exception e) {
                logger.error("Could not write stats data to " + makeFile().getAbsolutePath(), e);
View Full Code Here

        if (f.exists() && f.canRead()) {
            long t = System.currentTimeMillis();
            try {
                FileInputStream fis = new FileInputStream(f);
                try {
                    stats = (Map) (new XStream().fromXML(fis));

                    if (stats != null) {
                        // adjust stats data so that charts look realistic.
                        // we do that by ending the previous stats group with 0 value
                        // and starting the current stats group also with 0
View Full Code Here

  public void removeTemplate(DesignTemplate template){
    _templates.remove(template);   
  }
 
  public static  String asXML(DesignTemplateStore ts){
    return new XStream().toXML(ts);
  }
View Full Code Here

  public static  String asXML(DesignTemplateStore ts){
    return new XStream().toXML(ts);
  }
 
  public static DesignTemplateStore fromXML(String xml){
    XStream xstream = new XStream(new Dom4JDriver());
    return (DesignTemplateStore)xstream.fromXML(xml);
  }
View Full Code Here

        FileUtils.cleanDirectory(colDir);
    }

    @Test
    public void addingAuthors1() {
        XStream xstream = XBirdCollectionStrategy.getAnnotationProcessableXStreamInstance();
        XBirdCollectionStrategy<String, Object> strategy = new XBirdCollectionStrategy<String, Object>(COLLECTION_NAME, xstream);

        //xstream.processAnnotations(Author.class);

        List<Author> list = new XmlArrayList(strategy);
View Full Code Here

        list2.clear();
    }

    //@Test
    public void addingRendezvousMessages1() throws DbException, XQueryException {
        XStream xstream = new XStream();
        XBirdCollectionStrategy<String, Object> strategy = new XBirdCollectionStrategy<String, Object>(COLLECTION_NAME, xstream);
        xstream.processAnnotations(RendezvousMessage.class);

        RendezvousMessage msg1 = new RendezvousMessage(15, Arrays.asList(new Author("anonymous"), new Author("makoto")));
        System.out.println(xstream.toXML(msg1));
        System.out.println();

        RendezvousMessage msg2 = new RendezvousMessage(15, Arrays.asList(new Author("anonymous")), "firstPart", "secondPart");
        System.out.println(xstream.toXML(msg2));
        System.out.println();

        List<RendezvousMessage> list = new XmlArrayList(strategy);
        list.add(msg1);
        list.add(msg2);
        Assert.assertEquals(2, list.size());

        String query1 = "fn:collection('/" + COLLECTION_NAME + "/1.xml')//author[1]";
        XQueryProcessor proc = new XQueryProcessor();
        XQueryModule compiled1 = proc.parse(query1);
        StringWriter sw = new StringWriter();
        SAXWriter handler = new SAXWriter(sw);
        SAXSerializer ser = new SAXSerializer(handler);

        proc.execute(compiled1, ser);
        handler.flush();
        String result1 = sw.toString();

        System.err.println(result1);

        Author author1 = (Author) xstream.fromXML(result1);
        Assert.assertEquals("anonymous", author1.getName());
    }
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.