Package org.trellisldp.file
Class FileNamespaceService
- java.lang.Object
-
- org.trellisldp.file.FileNamespaceService
-
- All Implemented Interfaces:
NamespaceService
@Alternative public class FileNamespaceService extends Object implements NamespaceService
Create a namespace service based on reading/writing the namespaces to a central JSON file.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCONFIG_FILE_NAMESPACE_PATHThe configuration key controlling the path to a JSON-formatted namespace file.
-
Constructor Summary
Constructors Constructor Description FileNamespaceService()Create a JSON-based Namespace service.FileNamespaceService(String path)Create a JSON-based Namespace service.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,String>getNamespaces()Fetch the entire namespace mapping.booleansetPrefix(String prefix, String namespace)Set the namespace for a given prefix.
-
-
-
Field Detail
-
CONFIG_FILE_NAMESPACE_PATH
public static final String CONFIG_FILE_NAMESPACE_PATH
The configuration key controlling the path to a JSON-formatted namespace file.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
FileNamespaceService
public FileNamespaceService()
Create a JSON-based Namespace service.
-
FileNamespaceService
public FileNamespaceService(String path)
Create a JSON-based Namespace service.- Parameters:
path- the path to the JSON file
-
-
Method Detail
-
getNamespaces
public Map<String,String> getNamespaces()
Description copied from interface:NamespaceServiceFetch the entire namespace mapping.- Specified by:
getNamespacesin interfaceNamespaceService- Returns:
- the namespace mapping as prefix, namespace pairs
-
setPrefix
public boolean setPrefix(String prefix, String namespace)
Description copied from interface:NamespaceServiceSet the namespace for a given prefix.- Specified by:
setPrefixin interfaceNamespaceService- Parameters:
prefix- the prefixnamespace- the namespace- Returns:
- whether the new prefix was set
-
-