astra.reasoner.util.StringMapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of astra-interpreter Show documentation
Show all versions of astra-interpreter Show documentation
Core interpreter artifact for the ASTRA Language
package astra.reasoner.util;
import java.util.HashMap;
import java.util.Map;
import java.util.TreeMap;
public class StringMapper {
private Map stringMap = new HashMap();
private Map idMap = new TreeMap();
public synchronized int toId(String predicate) {
Integer id = stringMap.get(predicate);
if (id == null) {
id = predicate.hashCode();
idMap.put(id, predicate);
stringMap.put(predicate, id);
}
return id;
}
public String fromId(int id) {
return idMap.get(id);
}
}