Package com.thoughtworks.xstream.persistence

Examples of com.thoughtworks.xstream.persistence.XmlArrayList


        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);

        // adds four authors
        list.add(new Author("joe walnes"));
        list.add(new Author("joerg schaible"));
        list.add(new Author("mauro talevi"));
        list.add(new Author("guilherme silveira"));

        // adding an extra author
        Author mistake = new Author("mama");
        list.add(mistake);

        Assert.assertEquals(5, list.size());

        List<Author> list2 = new XmlArrayList(strategy);
        Iterator<Author> itor = list2.iterator();
        while(itor.hasNext()) {
            Author author = itor.next();
            if(author.getName().equals("mama")) {
                System.out.println("Removing mama...");
                itor.remove();
            } else {
                System.out.println("Keeping " + author.getName());
            }
        }

        Assert.assertEquals(4, list.size());
        list2.clear();
    }
View Full Code Here


        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();
View Full Code Here

        List<Author> author2 = Arrays.asList(new Author("makoto"), new Author("leo"), new Author("grun"));
        RendezvousMessage msg2 = new RendezvousMessage(15, author2, "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 + "/.*.xml')//author";
        XQueryProcessor proc = new XQueryProcessor();
        XQueryModule compiled1 = proc.parse(query1);
        Sequence<? extends Item> items = proc.execute(compiled1);
View Full Code Here

    }

    private final class PersistenceArrayListConverter implements Converter {
        public void marshal(Object source, HierarchicalStreamWriter writer,
            MarshallingContext context) {
            final XmlArrayList list = new XmlArrayList(new FilePersistenceStrategy(dir, xstream));
            context.convertAnother(dir);
            list.addAll((Collection)source);
        }
View Full Code Here

        }

        public Object unmarshal(HierarchicalStreamReader reader,
            UnmarshallingContext context) {
            final File directory = (File)context.convertAnother(null, File.class);
            final XmlArrayList persistentList = new XmlArrayList(new FilePersistenceStrategy(directory, xstream));
            final ArrayList list = new ArrayList(persistentList);
            //persistentList.clear(); // remove files
            return list;
        }
View Full Code Here

  //prepares the file strategy to directory /tmp
  StreamStrategy strategy = new FileStreamStrategy(new File(path1+ "WEB-INF" + c));

  // creates the list:
  List list = new XmlArrayList(strategy);
  list.add(server)
      } catch (Exception e)
      {
         e.printStackTrace();
   r=false;
      }
View Full Code Here

        }

      //System.out.println("RUTA:"+ruta+"/"+serName);
      PersistenceStrategy strategy = new FilePersistenceStrategy(new File(ruta));
      // creates the list:
      List list = new XmlArrayList(strategy);
      list.add(event);
      return true;
    }
    catch(Exception e){
      e.printStackTrace();
      return false;
View Full Code Here

   }
  
   public Event getEventByID(String id,String path,String serName){
       PersistenceStrategy strategy = new FilePersistenceStrategy(new File(path+"/"+serName));
    // creates the list:
    List list = new XmlArrayList(strategy);
    for(Iterator it = list.iterator(); it.hasNext(); ) {
      Event event = (Event) it.next();
      if(event.getId().equals(id)) {
        return event;
      }
    }
View Full Code Here

      String[] listDirs = file.list(onlyDir);
      Vector vector =new Vector();
      for(int i = 0;i<listDirs.length;i++){
        try{
          PersistenceStrategy strategy = new FilePersistenceStrategy(new File(path+"/"+serName+"/"+listDirs[i]));
          List list = new XmlArrayList(strategy);
       
          for(Iterator it = list.iterator(); it.hasNext(); ) {
           
            Event event = (Event) it.next();
            //Date dateEvent =  new Date(event.getDate());
            //dfMySQLDate.format(dfDateField.parse(request.getParameter("EventDate")));
             //String s = dfMySQLDate.format(dfDateField.parse(startDate));
View Full Code Here

   }
     
   public Event[] getAllEvents(String path,String serName){
       PersistenceStrategy strategy = new FilePersistenceStrategy(new File(path+"/"+serName));
    // creates the list:
    List list = new XmlArrayList(strategy);
    if(list.size()>0){
      Event[] array = (Event[])list.toArray(new Event[list.size()]);
      return array;
    }
    else
      return null;
   }
View Full Code Here

TOP

Related Classes of com.thoughtworks.xstream.persistence.XmlArrayList

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.