changeset 21:1abbfc8f11f2

add ShowAttribute
author one
date Sun, 30 Jun 2013 04:18:12 +0900
parents 506388c02b4b
children fc49b0839908
files pom.xml src/jungle/test/codesegment/practice/ShowAttribute.java
diffstat 2 files changed, 94 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/pom.xml	Sun Jun 30 04:18:12 2013 +0900
@@ -0,0 +1,36 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>jungle.test.codesegment.practice</groupId>
+  <artifactId>StartJungleCodeSegment</artifactId>
+  <version>0.0.1-SNAPSHOT</version>
+  <packaging>jar</packaging>
+
+  <name>jungleAlice</name>
+  <url>http://maven.apache.org</url>
+
+  <properties>
+    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+  </properties>
+
+  <dependencies>
+    <dependency>
+        <groupId>com.google.guava</groupId>
+        <artifactId>guava</artifactId>
+        <version>12.0</version>
+    </dependency>
+  </dependencies>
+  <build>
+        <plugins>
+                <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-compiler-plugin</artifactId>
+                        <configuration>
+                                <source>1.6</source>
+                                <target>1.6</target>
+                        </configuration>
+                </plugin>
+        </plugins>
+  </build>
+</project>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/jungle/test/codesegment/practice/ShowAttribute.java	Sun Jun 30 04:18:12 2013 +0900
@@ -0,0 +1,58 @@
+package jungle.test.codesegment.practice;
+
+import java.nio.ByteBuffer;
+
+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.JungleTreeEditor;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Children;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.core.Node;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.store.impl.DefaultNodePath;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Either;
+import jp.ac.u_ryukyu.ie.cr.shoshi.jungle.util.Error;
+import alice.codesegment.CodeSegment;
+import alice.datasegment.CommandType;
+import alice.datasegment.Receiver;
+
+public class ShowAttribute extends CodeSegment {
+	
+	Receiver arg1 = ids.create(CommandType.TAKE);
+	
+	public ShowAttribute() {
+		arg1.setKey("show");
+	}
+	
+	public void run() {
+		System.out.println("--ShowAttribute--");
+		
+		Jungle jungle = new JungleManager().getJungle();
+		JungleTree tree = jungle.getTreeByName("tree");
+		JungleTreeEditor editor = tree.getTreeEditor();
+		DefaultNodePath root = new DefaultNodePath();
+		Either<Error,JungleTreeEditor>  either = editor.addNewChildAt(root, 0);
+		if(either.isA()) {
+			throw new IllegalStateException();
+		}
+		editor = either.b();
+		either =  editor.putAttribute(root.add(0), "key1", ByteBuffer.wrap("message".getBytes()));
+		if(either.isA()) {
+			throw new IllegalStateException();
+		}
+		editor = either.b();
+		Either<Error,JungleTreeEditor> result = editor.success();
+		if(result.isA()) {
+			throw new IllegalStateException();
+		}
+		
+		Node node = tree.getRootNode();
+		Children<Node> chs = node.getChildren();
+		for(Node n : chs) {
+			System.out.println(n.getAttributes().get("key1"));
+		}
+		
+		System.exit(0);
+		
+		
+	}
+
+}