comparison src/treecms/tree/cassandra/v1/CassandraForest.java @ 6:12604eb6b615

added javadoc
author shoshi
date Mon, 14 Mar 2011 23:24:38 +0900
parents f5ed85be5640
children fc19e38b669b
comparison
equal deleted inserted replaced
5:87bba22e4fa2 6:12604eb6b615
1 package treecms.tree.cassandra.v1; 1 package treecms.tree.cassandra.v1;
2 2
3 import java.util.HashMap; 3 import java.util.HashMap;
4
4 import java.util.Iterator; 5 import java.util.Iterator;
5 import java.util.LinkedList; 6 import java.util.LinkedList;
6 import java.util.List; 7 import java.util.List;
7 import java.util.Map; 8 import java.util.Map;
8 import java.util.Random; 9 import java.util.Random;
31 32
32 import treecms.api.Forest; 33 import treecms.api.Forest;
33 import treecms.api.Node; 34 import treecms.api.Node;
34 import treecms.api.NodeData; 35 import treecms.api.NodeData;
35 import treecms.api.NodeID; 36 import treecms.api.NodeID;
36 import treecms.tree.id.RandomNodeID; 37 import treecms.tree.id.AbstractRandomNodeID;
37 38
38 /** 39 /**
39 * implementation of TreeCMS with Cassandra backend. 40 * implementation of TreeCMS with Cassandra backend.
40 * 41 *
41 * TreeCMSKS.NodeTable (table of all nodes) 42 * TreeCMSKS.NodeTable (table of all nodes)
331 return new CassandraNode(this,id); 332 return new CassandraNode(this,id);
332 } 333 }
333 334
334 public NodeID createID(String _uuid,String _version) 335 public NodeID createID(String _uuid,String _version)
335 { 336 {
336 return new RandomNodeIDImpl(_uuid,_version); 337 return new RandomNodeID(_uuid,_version);
337 } 338 }
338 339
339 class RandomNodeIDImpl extends RandomNodeID 340 class RandomNodeID extends AbstractRandomNodeID
340 { 341 {
341 String m_uuid; 342 String m_uuid;
342 String m_version; 343 String m_version;
343 344
344 public RandomNodeIDImpl(String _uuid,String _version) 345 public RandomNodeID(String _uuid,String _version)
345 { 346 {
346 m_uuid = (_uuid != null) ? _uuid : UUID.randomUUID().toString(); 347 m_uuid = (_uuid != null) ? _uuid : UUID.randomUUID().toString();
347 m_version = (_version != null) ? _version : Long.toHexString((new Random()).nextLong()); 348 m_version = (_version != null) ? _version : Long.toHexString((new Random()).nextLong());
348 } 349 }
349 350
350 @Override 351 @Override
351 public NodeID create() 352 public NodeID create()
352 { 353 {
353 return new RandomNodeIDImpl(null,null); 354 return new RandomNodeID(null,null);
354 } 355 }
355 356
356 @Override 357 @Override
357 public NodeID update() 358 public NodeID update()
358 { 359 {
359 return new RandomNodeIDImpl(m_uuid,null); 360 return new RandomNodeID(m_uuid,null);
360 } 361 }
361 362
362 @Override 363 @Override
363 public String getUUID() 364 public String getUUID()
364 { 365 {