using UnityEngine; using System.Collections; using System.Collections.Generic; using System; using System.Text; public class DefaultTreeNodeAttribute : TreeNodeAttributes { public List children; public TreeMap attrs; public DefaultTreeNodeAttribute(List _children, TreeMap _attrs){ children = _children; // null? attrs = _attrs; } public TreeMap getAttributesAsRawMap(){ return attrs; } public Either delete(string _key) { if (_key == null) { return DefaultEither.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); } if (null == attrs.getRoot()) { return DefaultEither.newA(NodeEditorError.DELETE_KEY_NOT_FOUND); } TreeMap newMap = attrs.delete(_key); TreeNode newNode = new DefaultTreeNode(children, newMap); return DefaultEither.newB(newNode); } public Either put(string _key, byte[] _value){ if (_key == null || _value == null) { return DefaultEither.newA (NodeEditorError.NULL_VALUE_NOT_ALLOWED); } TreeMap newMap = attrs.put (_key, _value); TreeNode newNode = new DefaultTreeNode (children, newMap); return DefaultEither.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 getKeys(){ return attrs.keys (); } }