
astra.reasoner.util.StringMapper Maven / Gradle / Ivy
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);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy