Package org.incenp.obofoundry.kgcl.robot
Class IDRangeHelper
java.lang.Object
org.incenp.obofoundry.kgcl.robot.IDRangeHelper
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringFinds an ID range policy file in the current directory.static IAutoIDGeneratorgetIDGenerator(org.semanticweb.owlapi.model.OWLOntology ontology, String rangeFile, String rangeName, String[] altNames, boolean random) Gets an ID generator initialised with data from the specified range file.static IAutoIDGeneratormaybeGetIDGenerator(org.semanticweb.owlapi.model.OWLOntology ontology, String rangeFile, String rangeName, String[] altNames, boolean random) Gets an ID generator initialised with data from the specified range file, or a default file.
-
Constructor Details
-
IDRangeHelper
public IDRangeHelper()
-
-
Method Details
-
findIDRangeFile
Finds an ID range policy file in the current directory. This methods looks for a single file whose name ends with-idranges.owlin the current directory.- Returns:
- The name of the ID range policy file, if such a file exists;
otherwise
null.
-
getIDGenerator
public static IAutoIDGenerator getIDGenerator(org.semanticweb.owlapi.model.OWLOntology ontology, String rangeFile, String rangeName, String[] altNames, boolean random) throws IDRangePolicyException Gets an ID generator initialised with data from the specified range file.- Parameters:
ontology- The ontology to generate IDs for.rangeFile- The range file to initialise the generator with.rangeName- The name of the range to use. This should match theallocatedtoannotation of one of the ranges in the file. May benull, in which case the method will look for a range that matches one of the alternative names instead. If notnulland a corresponding range cannot be found, an exception will be thrown.altNames- A list of default range names to use ifrangeNameisnull.random- Iftrue, the generator will produce IDs picked at random within the target range; otherwise, IDs will be picked sequentially.- Returns:
- A newly initialised ID generator.
- Throws:
IDRangePolicyException- If the range file cannot be read for any reason, if the requestedrangeNamecannot be found, or if none of the default ranges can be found.
-
maybeGetIDGenerator
public static IAutoIDGenerator maybeGetIDGenerator(org.semanticweb.owlapi.model.OWLOntology ontology, String rangeFile, String rangeName, String[] altNames, boolean random) throws IDRangePolicyException Gets an ID generator initialised with data from the specified range file, or a default file. This method is similar togetIDGenerator(OWLOntology, String, String, String[], boolean), except that if therangeFileparameter isnull, it tries to find a default range file (using thefindIDRangeFile()method); in that case, no exception will be thrown.- Parameters:
ontology- The ontology to generate IDs for.rangeFile- The range file to initialise the generator with. Ifnull, the method will try to find a default file.rangeName- The name of the range to use. This should match theallocatedtoannotation of one of the ranges in the file. May benull, in which case the method will look for a range that matches one of the alternative names instead.altNames- A list of default range names to use ifrangeNameisnull.random- Iftrue, the generator will produce IDs picked at random within the target range; otherwise, IDs will be picked sequentially.- Returns:
- A newly initialised ID generator or
nullif no range file has been specified and no suitable default file was found. - Throws:
IDRangePolicyException- Only ifrangeFileis notnull: iIf the range file cannot be read for any reason, if the requestedrangeNamecannot be found, or if none of the default ranges can be found.
-