diff src/main/java/example/SimpleJungle.java @ 3:37aab24020a0

thread test
author Kanagawa TATSUKI <tatsuki@ie.u-ryukyu.ac.jp>
date Thu, 06 Mar 2014 04:17:40 +0900
parents f716298e440a
children
line wrap: on
line diff
--- a/src/main/java/example/SimpleJungle.java	Tue Mar 04 02:02:39 2014 +0900
+++ b/src/main/java/example/SimpleJungle.java	Thu Mar 06 04:17:40 2014 +0900
@@ -24,37 +24,39 @@
 	
 	public static void main(String[] args) {
 		Jungle j = new DefaultJungle(null,"hogehoge",new DefaultTreeEditor(new DefaultTraverser()));
-		j.createNewTree("tree");
-		JungleTree tree = j.getTreeByName("tree");
-		JungleTreeEditor editor1 = tree.getTreeEditor();
-		DefaultNodePath root = new DefaultNodePath();
+		j.createNewTree("tree");//木を作った
+		JungleTree tree = j.getTreeByName("tree");//名前を取得
+		JungleTreeEditor editor1 = tree.getTreeEditor();//editorの取得
+		DefaultNodePath root = new DefaultNodePath();//パスの取得
 		
+		//eitherに値を入れる
 		Either<Error,JungleTreeEditor> either = editor1.putAttribute(root,key,value);
-		if(either.isA()){
+		if(either.isA()){//失敗した場合Aが出てくる
 			Assert.fail();
 		}
 		editor1 = either.b();
 		editor1.success();
+		//ここで初めてSUCCESS
 		
 		Node node = tree.getRootNode();
 		ByteBuffer v = node.getAttributes().get(key);
 		System.out.println(new String(v.array()));
 		
-		editor1 = tree.getTreeEditor();
-		either = editor1.addNewChildAt(root,0);
-		if(either.isA()){
+		editor1 = tree.getTreeEditor();//Treeのeditorを作成
+		either = editor1.addNewChildAt(root,0);//新しく入れるところへのパス
+		if(either.isA()){//ちゃんとパスを指定できたかチェック
 			Assert.fail();
 		}
-		editor1 = either.b();
+		editor1 = either.b();//成功した場合パスを入れる
 		DefaultNodePath childPath = root.add(0);
-		either = editor1.putAttribute(childPath,key,value);
-		if(either.isA()){
+		//そしてここで子ノードに値を入れる
+		for(int count = 0 ; count < 1000 ; count++){
+			either = editor1.putAttribute(childPath,key,value);
+			if(either.isA()){
 			Assert.fail();
-		}
-		editor1 = either.b();
-		either = editor1.success();
-		if(either.isA()){
-			Assert.fail();
+			}
+			editor1 = either.b();
+			either = editor1.success();
 		}