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