Mercurial > hg > Database > jungle-sharp
view Main/jungle-main/transaction/DefaultTreeNodeAttribute.cs @ 20:1f99e150f336
fix folder and add Object Mapper.
author | Kazuma Takeda |
---|---|
date | Thu, 15 Dec 2016 22:52:48 +0900 |
parents | |
children | 9588ad364fdd |
line wrap: on
line source
using UnityEngine; using System.Collections; using System.Collections.Generic; using System; using System.Text; namespace JungleDB { public class DefaultTreeNodeAttribute : TreeNodeAttributes { public List<TreeNode> children; public TreeMap<string, byte[]> attrs; public DefaultTreeNodeAttribute(List<TreeNode> _children, TreeMap<string, byte[]> _attrs){ children = _children; // null? attrs = _attrs; } public TreeMap<string, byte[]> getAttributesAsRawMap(){ return attrs; } public Either<Error, TreeNode> delete(string _key) { if (_key == null) { return DefaultEither<Error,TreeNode>.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); } if (null == attrs.getRoot()) { return DefaultEither<Error,TreeNode>.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } TreeMap<string, byte[]> newMap = attrs.delete(_key); TreeNode newNode = new DefaultTreeNode(children, newMap); return DefaultEither<Error,TreeNode>.newB(newNode); } public Either<Error, TreeNode> put(string _key, byte[] _value){ if (_key == null || _value == null) { return DefaultEither<Error, TreeNode>.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); } TreeMap<string, byte[]> newMap = attrs.put (_key, _value); TreeNode newNode = new DefaultTreeNode (children, newMap); return DefaultEither<Error, TreeNode>.newB (newNode); } public byte[] get(string _key) { if (_key == null) { return new byte[1]{0}; } byte[] op = attrs.get(_key); //null if (op != null) { return op; } return new byte[1]{0}; } public string getString(string key, Encoding enc) { char[] attribute = key.ToCharArray(); if (attribute != null){ return new string(attribute); } return null; } public string getString(string key) { return null; } public IEnumerator<string> getKeys(){ return attrs.keys (); } } }