All Downloads are FREE. Search and download functionalities are using the official Maven repository.

astra.reasoner.util.StringMapper Maven / Gradle / Ivy

There is a newer version: 1.4.2
Show newest version
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 - 2024 Weber Informatics LLC | Privacy Policy