com.olapdb.obase.data.EntityDict Maven / Gradle / Ivy
The newest version!
package com.olapdb.obase.data;
import com.olapdb.obase.data.index.Value;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class EntityDict {
/*
item.attr("").get()
item.attr("").set(byte[])
item.attr("").del()
item.list("").get() list
item.list("").add("")
item.list("").del("")
item.dict("").get() map
item.dict("").get("") byte[]
item.dict("").put("", value)
item.dict("").del("")
*/
private JsonEntity entity;
private String name;
public EntityDict(JsonEntity entity, String name){
this.entity = entity;
this.name = name;
}
public List keys(){
return entity.getAttributeItems(name);
}
public Map get(){
Map map = new HashMap();
for(String key : keys()){
map.put(key, get(key));
}
return map;
}
public void put(String key, Value value){
entity.setAttribute(name, key, value.encode());
}
public Value get(String key){
return Value.decode(entity.getAttribute(name, key));
}
public void del(String key){
entity.deleteAttribute(name, key);
}
public void del(){
entity.deleteAttributeItems(name);
}
public boolean has(String key){
return entity.getAttribute(name, key) != null;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy