net.sf.okapi.lib.xliff2

## Class URIPrefixes

- java.lang.Object
- - net.sf.okapi.lib.xliff2.URIPrefixes

-     public class URIPrefixes
      extends java.lang.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 time `resolve(String)` is called.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `URIPrefixes()` Creates a simple URIPrefixes object.
    `URIPrefixes(java.io.File extraPrefixes)` Creates a URIPrefixes object with a given file where custom prefixes are stored.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `add(java.util.Map<java.lang.String,java.lang.String> map)` Adds a collection of uri/prefix to this object.
    `void` | `addExtra(java.io.File inputFile)` Adds prefixes from a given properties file.
    `void` | `doAutoLoads()` Performs the auto-loading steps: load the defaults, then adds the custom prefixes if a file for them is set.
    `java.util.Map<java.lang.String,java.util.List<java.lang.String>>` | `get()` Gets the current mapping of prefixes.
    `void` | `loadDefaults()` Loads the default prefixes from the default properties file.
    `java.util.Map<java.lang.String,java.util.List<java.lang.String>>` | `loadFromRegistry()`
    `java.util.List<java.lang.String>` | `resolve(java.lang.String prefix)` Resolves a given prefix.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### URIPrefixes

          public URIPrefixes()

      Creates a simple URIPrefixes object.

    - #### URIPrefixes

          public URIPrefixes(java.io.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 in `resolve(String)`.

    - #### add

          public void add(java.util.Map<java.lang.String,java.lang.String> map)

      Adds a collection of uri/prefix to this object. Calls `doAutoLoads()` if no mapping is loaded yet.
      Parameters:
        `map` - the map to add.

    - #### addExtra

          public void addExtra(java.io.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 java.util.List<java.lang.String> resolve(java.lang.String prefix)

      Resolves a given prefix. Calls `doAutoLoads()` 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 java.util.Map<java.lang.String,java.util.List<java.lang.String>> get()

      Gets the current mapping of prefixes. Calls `doAutoLoads()` 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.

    - #### loadFromRegistry

          public java.util.Map<java.lang.String,java.util.List<java.lang.String>> loadFromRegistry()