Mercurial > hg > Database > jungle-sharp
comparison src/main/csharp/jp.ac.u-ryukyu.ie.cr/jungle/transaction/DefaultTreeNodeAttribute.cs @ 0:dec15de2c6ff
first commit
author | Kazuma |
---|---|
date | Tue, 21 Jun 2016 17:11:12 +0900 |
parents | |
children | 4d08270a61c8 02b2ab7bffe6 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:dec15de2c6ff |
---|---|
1 using UnityEngine; | |
2 using System.Collections; | |
3 using System.Collections.Generic; | |
4 using System; | |
5 using System.Text; | |
6 | |
7 public class DefaultTreeNodeAttribute : TreeNodeAttributes { | |
8 public List<TreeNode> children; | |
9 public TreeMap<string,GameObject> attrs; | |
10 | |
11 public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<string,GameObject> _attrs){ | |
12 children = _children; // null? | |
13 attrs = _attrs; | |
14 } | |
15 | |
16 public TreeMap<string, GameObject> getAttributesAsRawMap(){ | |
17 return attrs; | |
18 } | |
19 | |
20 public Either<Error, TreeNode> delete(string _key) { | |
21 if (_key == null) { | |
22 return DefaultEither<Error,TreeNode>.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); | |
23 } | |
24 | |
25 if (null == attrs.getRoot()) { | |
26 return DefaultEither<Error,TreeNode>.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); | |
27 } | |
28 | |
29 TreeMap<string, GameObject> newMap = attrs.delete(_key); | |
30 TreeNode newNode = new DefaultTreeNode(children, newMap); | |
31 return DefaultEither<Error,TreeNode>.newB(newNode); | |
32 } | |
33 | |
34 public Either<Error, TreeNode> put(string _key, GameObject _value){ | |
35 if (_key == null || _value == null) { | |
36 return DefaultEither<Error, TreeNode>.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); | |
37 } | |
38 | |
39 TreeMap<string, GameObject> newMap = attrs.put (_key, _value); | |
40 | |
41 TreeNode newNode = new DefaultTreeNode (children, newMap); | |
42 | |
43 return DefaultEither<Error, TreeNode>.newB (newNode); | |
44 } | |
45 | |
46 public GameObject get(string _key) { | |
47 if (_key == null) { | |
48 return null; | |
49 } | |
50 GameObject op = attrs.get(_key); //null | |
51 if (op != null) { | |
52 return op.gameObject; | |
53 } | |
54 return null; | |
55 } | |
56 | |
57 public string getString(string key , Encoding enc) { | |
58 char[] attribute = key.ToCharArray(); | |
59 if (attribute != null){ | |
60 return new string(attribute); | |
61 } | |
62 return null; | |
63 } | |
64 | |
65 public string getString(string key) { | |
66 return null; | |
67 } | |
68 public IEnumerator<string> getKeys(){ | |
69 return attrs.keys (); | |
70 } | |
71 | |
72 } |