GeoPubby  Version 0.1.0.0
VocabularyStore.ValueCache< K > Class Template Referenceabstract
Inheritance diagram for VocabularyStore.ValueCache< K >:
Collaboration diagram for VocabularyStore.ValueCache< K >:

Package Functions

 ValueCache (Property property, boolean inverse)
 
abstract K pickBestValue (Set< RDFNode > candidates)
 
get (String iri)
 
getCached (String iri)
 

Private Member Functions

pickBestFromModel (Model m, String iri)
 
Set< RDFNode > getValues (Resource r)
 
Set< RDFNode > getInverseValues (Resource r)
 

Private Attributes

final Property property
 
final boolean inverse
 
final Map< String, K > cache = new HashMap<String, K>()
 

Constructor & Destructor Documentation

◆ ValueCache()

ValueCache ( Property  property,
boolean  inverse 
)
package
157  {
158  this.property = property;
159  this.inverse = inverse;
160  }
final Property property
Definition: VocabularyStore.java:154
final boolean inverse
Definition: VocabularyStore.java:155

References VocabularyStore.ValueCache< K >.inverse, and VocabularyStore.ValueCache< K >.property.

Member Function Documentation

◆ get()

K get ( String  iri)
package
162  {
163  if (cache.containsKey(iri)) {
164  return cache.get(iri);
165  }
166  K best = null;
167  if (dataSource.canDescribe(iri)) {
169  }
170  cache.put(iri, best);
171  return best;
172  }
boolean canDescribe(String absoluteIRI)
Indicates whether this data source may have some information about a given IRI.
Model describeResource(String absoluteIRI)
Returns a subgraph of the data source describing one resource.
DataSource dataSource
Definition: VocabularyStore.java:32
K pickBestFromModel(Model m, String iri)
Definition: VocabularyStore.java:176
final Map< String, K > cache
Definition: VocabularyStore.java:156

References VocabularyStore.ValueCache< K >.cache, DataSource.canDescribe(), VocabularyStore.dataSource, DataSource.describeResource(), and VocabularyStore.ValueCache< K >.pickBestFromModel().

Referenced by VocabularyStore.getWeight().

◆ getCached()

K getCached ( String  iri)
package
173  {
174  return cache.get(iri);
175  }

References VocabularyStore.ValueCache< K >.cache.

◆ getInverseValues()

Set<RDFNode> getInverseValues ( Resource  r)
private
189  {
190  Set<RDFNode> nodes = new HashSet<RDFNode>();
191  StmtIterator it = r.listProperties(OWL.inverseOf);
192  while (it.hasNext()) {
193  RDFNode object = it.next().getObject();
194  if (!object.isResource()) continue;
195  StmtIterator it2 = object.asResource().listProperties(property);
196  while (it2.hasNext()) {
197  nodes.add(it2.next().getObject());
198  }
199  }
200  return nodes;
201  }

References VocabularyStore.ValueCache< K >.property.

Referenced by VocabularyStore.ValueCache< K >.pickBestFromModel().

◆ getValues()

Set<RDFNode> getValues ( Resource  r)
private
181  {
182  Set<RDFNode> nodes = new HashSet<RDFNode>();
183  StmtIterator it = r.listProperties(property);
184  while (it.hasNext()) {
185  nodes.add(it.next().getObject());
186  }
187  return nodes;
188  }

References VocabularyStore.ValueCache< K >.property.

Referenced by VocabularyStore.ValueCache< K >.pickBestFromModel().

◆ pickBestFromModel()

K pickBestFromModel ( Model  m,
String  iri 
)
private
176  {
177  Resource r = m.getResource(iri);
178  Set<RDFNode> nodes = inverse ? getInverseValues(r) : getValues(r);
179  return pickBestValue(nodes);
180  }
Set< RDFNode > getValues(Resource r)
Definition: VocabularyStore.java:181
Set< RDFNode > getInverseValues(Resource r)
Definition: VocabularyStore.java:189
abstract K pickBestValue(Set< RDFNode > candidates)

References VocabularyStore.ValueCache< K >.getInverseValues(), VocabularyStore.ValueCache< K >.getValues(), VocabularyStore.ValueCache< K >.inverse, and VocabularyStore.ValueCache< K >.pickBestValue().

Referenced by VocabularyStore.ValueCache< K >.get().

◆ pickBestValue()

abstract K pickBestValue ( Set< RDFNode >  candidates)
abstractpackage

Member Data Documentation

◆ cache

final Map<String, K> cache = new HashMap<String, K>()
private

◆ inverse

◆ property