Package net.sf.okapi.lib.xliff2
Class URIPrefixes
- java.lang.Object
-
- net.sf.okapi.lib.xliff2.URIPrefixes
-
public class URIPrefixes extends Object
Represents the prefixes for modules and extensions in XLIFF URI fragment identifiers. This object is set to load automatically a default mapping and possibly a custom one the first timeresolve(String)is called.
-
-
Constructor Summary
Constructors Constructor Description URIPrefixes()Creates a simple URIPrefixes object.URIPrefixes(File extraPrefixes)Creates a URIPrefixes object with a given file where custom prefixes are stored.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Map<String,String> map)Adds a collection of uri/prefix to this object.voidaddExtra(File inputFile)Adds prefixes from a given properties file.voiddoAutoLoads()Performs the auto-loading steps: load the defaults, then adds the custom prefixes if a file for them is set.Map<String,List<String>>get()Gets the current mapping of prefixes.voidloadDefaults()Loads the default prefixes from the default properties file.Map<String,List<String>>loadFromRegistry()List<String>resolve(String prefix)Resolves a given prefix.
-
-
-
Constructor Detail
-
URIPrefixes
public URIPrefixes()
Creates a simple URIPrefixes object.
-
URIPrefixes
public URIPrefixes(File extraPrefixes)
Creates a URIPrefixes object with a given file where custom prefixes are stored.- Parameters:
extraPrefixes- the properties file where the custom prefixes are stored (can be null)
-
-
Method Detail
-
loadDefaults
public void loadDefaults()
Loads the default prefixes from the default properties file. This method is called automatically if needed inresolve(String).
-
add
public void add(Map<String,String> map)
Adds a collection of uri/prefix to this object. CallsdoAutoLoads()if no mapping is loaded yet.- Parameters:
map- the map to add.
-
addExtra
public void addExtra(File inputFile)
Adds prefixes from a given properties file. If no mapping is loaded yet, the default one is loaded automatically before loading the one defined in this given properties file.- Parameters:
inputFile- the properties file where to get the extra prefixes from.
-
resolve
public List<String> resolve(String prefix)
Resolves a given prefix. CallsdoAutoLoads()if no mapping is loaded yet.- Parameters:
prefix- the prefix to look-up.- Returns:
- the array of namespace URIs associated with the given prefix, or null if the prefix is not found.
-
get
public Map<String,List<String>> get()
Gets the current mapping of prefixes. CallsdoAutoLoads()if no mapping is loaded yet.- Returns:
- the current mapping.
-
doAutoLoads
public void doAutoLoads()
Performs the auto-loading steps: load the defaults, then adds the custom prefixes if a file for them is set.
-
-