public Unit getUnit(String resourceUri) { return factory.getUnit(resourceUri); }
public static UnitFactory getInstance() { if (factory == null) factory = new UnitFactory(); return factory; }
private void collect() { for(String newUri : unitTypeClasses) { try { Unit unitType = UnitFactory.getInstance().getUnit(namespace +newUri); if (unitType != null) availableUnitTypes.add(unitType); List<String> uris = UnitFactory.getInstance().getURIs(namespace +newUri); for(String uri : uris) { Unit unit = UnitFactory.getInstance().getUnit(uri); if (unit != null) availableUnits.add(unit); } } catch (Exception e) { LOG.warn("No entry found"); } } }
public List<String> getURIs(URI type) { List<String> uris = new ArrayList<>(); List<String> qudtURIs = UnitFactory.getInstance().getURIs(type); for (String qudtString : qudtURIs) { String uoURI = qudt2uo.get(qudtString); if (uoURI != null) { uris.add(uoURI); } } return uris; } }
public Unit getUnit(URI resource) { if (resource == null) { throw new IllegalArgumentException("The URI cannot be null"); } URI mappedURI = asURI(uo2qudt.get(resource.toString())); if (mappedURI != null) { return UnitFactory.getInstance().getUnit(mappedURI); } else { return null; } }
UnitProvider() { factory = UnitFactory.getInstance(); UnitCollector collector = new UnitCollector(); this.availableUnits.addAll(collector.getAvailableUnits()); this.availableUnitTypes.addAll(collector.getAvailableUnitTypes()); }
public List<String> getURIs(String type) { URI uri; try { uri = new URI(type); } catch (URISyntaxException exception) { throw new IllegalStateException("Invalid URI: " + type, exception); } return getURIs(uri); }
private UnitFactory() { repos = new LinkedHashModel(); try { OntoReader.read(repos, "unit"); OntoReader.read(repos, "qudt"); OntoReader.read(repos, "quantity"); OntoReader.read(repos, "ops.ttl"); } catch (Exception exception) { throw new IllegalStateException( "Could not load the QUDT ontologies: " + exception.getMessage(), exception ); } }
private void collect() { for(String newUri : unitTypeClasses) { try { Unit unitType = UnitFactory.getInstance().getUnit(namespace +newUri); if (unitType != null) availableUnitTypes.add(unitType); List<String> uris = UnitFactory.getInstance().getURIs(namespace +newUri); for(String uri : uris) { Unit unit = UnitFactory.getInstance().getUnit(uri); if (unit != null) availableUnits.add(unit); } } catch (Exception e) { LOG.warn("No entry found"); } } }
public List<String> getURIs(URI type) { List<String> uris = new ArrayList<>(); List<String> qudtURIs = UnitFactory.getInstance().getURIs(type); for (String qudtString : qudtURIs) { String uoURI = qudt2uo.get(qudtString); if (uoURI != null) { uris.add(uoURI); } } return uris; } }
public Unit getUnit(URI resource) { if (resource == null) { throw new IllegalArgumentException("The URI cannot be null"); } URI mappedURI = asURI(uo2qudt.get(resource.toString())); if (mappedURI != null) { return UnitFactory.getInstance().getUnit(mappedURI); } else { return null; } }
public Unit getUnit(String resourceUri) { return factory.getUnit(resourceUri); }
public static UnitFactory getInstance() { if (factory == null) factory = new UnitFactory(); return factory; }
UnitProvider() { factory = UnitFactory.getInstance(); UnitCollector collector = new UnitCollector(); this.availableUnits.addAll(collector.getAvailableUnits()); this.availableUnitTypes.addAll(collector.getAvailableUnitTypes()); }
public List<String> getURIs(String type) { URI uri; try { uri = new URI(type); } catch (URISyntaxException exception) { throw new IllegalStateException("Invalid URI: " + type, exception); } return getURIs(uri); }
private UnitFactory() { repos = new LinkedHashModel(); try { OntoReader.read(repos, "unit"); OntoReader.read(repos, "qudt"); OntoReader.read(repos, "quantity"); OntoReader.read(repos, "ops.ttl"); } catch (Exception exception) { throw new IllegalStateException( "Could not load the QUDT ontologies: " + exception.getMessage(), exception ); } }
public Unit getUnit(String resource) { URI uri; try { uri = new URI(resource); } catch (URISyntaxException exception) { throw new IllegalStateException("Invalid URI: " + resource, exception); } return getUnit(uri); }
public Unit getUnit(String resource) { URI uri; try { uri = new URI(resource); } catch (URISyntaxException exception) { throw new IllegalStateException("Invalid URI: " + resource, exception); } return getUnit(uri); }
public List<Unit> findUnits(String symbol) { if (symbol == null) throw new IllegalArgumentException("The symbol cannot be null"); ValueFactory f = ValueFactoryImpl.getInstance(); Model statements = repos.filter(null, QUDT.ABBREVIATION, f.createLiteral(symbol, XMLSchema.STRING)); if (statements.isEmpty()) return Collections.emptyList(); List<Unit> foundUnits = new ArrayList<>(); for (Statement statement : statements) { Object type = statement.getSubject(); try { if (type instanceof org.eclipse.rdf4j.model.URI) { org.eclipse.rdf4j.model.URI typeURI = (org.eclipse.rdf4j.model.URI)type; foundUnits.add(getUnit(typeURI.toString())); } } catch (Exception exception) { // ignore } } return foundUnits; }
public List<Unit> findUnits(String symbol) { if (symbol == null) throw new IllegalArgumentException("The symbol cannot be null"); ValueFactory f = ValueFactoryImpl.getInstance(); Model statements = repos.filter(null, QUDT.ABBREVIATION, f.createLiteral(symbol, XMLSchema.STRING)); if (statements.isEmpty()) return Collections.emptyList(); List<Unit> foundUnits = new ArrayList<>(); for (Statement statement : statements) { Object type = statement.getSubject(); try { if (type instanceof org.eclipse.rdf4j.model.URI) { org.eclipse.rdf4j.model.URI typeURI = (org.eclipse.rdf4j.model.URI)type; foundUnits.add(getUnit(typeURI.toString())); } } catch (Exception exception) { // ignore } } return foundUnits; }