Mercurial > hg > Members > nobuyasu > jungle-network
view src/alice/jungle/persistence/PersistentJungle.java @ 88:0c98717f186e
Removed cast code
author | one |
---|---|
date | Tue, 05 Nov 2013 09:13:30 +0900 |
parents | f142dd4abc74 |
children |
line wrap: on
line source
package alice.jungle.persistence; import java.util.Iterator; import java.util.concurrent.ConcurrentHashMap; import fj.data.List; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.Jungle; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.JungleTree; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.persistent.ChangeList; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.ChangeSet; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.TreeEditor; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.operations.TreeOperation; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeContext; import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.transaction.DefaultTreeNode; public class PersistentJungle implements Jungle { private PersistentJournal journal; private ConcurrentHashMap<String,JungleTree> trees; final private String uuid; private TreeEditor editor; public PersistentJungle(PersistentJournal _journal,String _uuid,TreeEditor _editor) { journal = _journal; trees = new ConcurrentHashMap<String,JungleTree>(); uuid = _uuid; editor = _editor; } @Override public JungleTree getTreeByName(String _name) { return trees.get(_name); } @Override public JungleTree createNewTree(final String _name) { ChangeList list = new ChangeList(){ @Override public Iterator<TreeOperation> iterator() { List<TreeOperation> nil = List.nil(); return nil.iterator(); } @Override public String uuid() { return uuid; } @Override public String getTreeName() { return _name; } }; DefaultTreeNode root = new DefaultTreeNode(); ChangeSet set = new PersistentChangeSet(root.getAsNode(),null,list,uuid,_name,0); DefaultTreeContext<DefaultTreeNode> tc = new DefaultTreeContext<DefaultTreeNode>(root,set); JungleTree newTree = new PersistentJungleTree<DefaultTreeNode>(_name, tc,uuid, journal.getWriter(),editor); if(trees.putIfAbsent(_name,newTree) != null){ return null; } return newTree; } }