GeoPubby  Version 0.1.0.0
VocabularyStore Class Reference

A store for labels, descriptions and other metadata of classes and properties. More...

Collaboration diagram for VocabularyStore:

Classes

class  CachedPropertyCollection
 
class  I18nStringValueCache
 
class  IntegerValueCache
 
class  ValueCache
 

Public Member Functions

void setDataSource (DataSource dataSource)
 Needs to be set before the instance is used! This is to allow creation of the store before the dataset is fully assembled. More...
 
void setDefaultLanguage (String defaultLanguage)
 
Literal getLabel (String iri, boolean preferPlural)
 
Literal getLabel (String iri, boolean preferPlural, String language)
 
Literal getCachedLabel (String iri, boolean preferPlural)
 Returns a label, only taking into account previously cached values, without querying the data sources. More...
 
Literal getInverseLabel (String iri, boolean preferPlural)
 
Literal getInverseLabel (String iri, boolean preferPlural, String language)
 
Literal getDescription (String iri)
 
Literal getDescription (String iri, String language)
 
int getWeight (Property property, boolean forInverse)
 Returns the conf:weight of the property. More...
 
CachedPropertyCollection getHighIndegreeProperties ()
 
CachedPropertyCollection getHighOutdegreeProperties ()
 

Private Attributes

DataSource dataSource
 
String defaultLanguage = "en"
 
final I18nStringValueCache labels = new I18nStringValueCache(RDFS.label, false)
 
final I18nStringValueCache pluralLabels = new I18nStringValueCache(CONF.pluralLabel, false)
 
final I18nStringValueCache inverseLabels = new I18nStringValueCache(RDFS.label, true)
 
final I18nStringValueCache inversePluralLabels = new I18nStringValueCache(CONF.pluralLabel, true)
 
final I18nStringValueCache descriptions = new I18nStringValueCache(RDFS.comment, false)
 
final IntegerValueCache weights = new IntegerValueCache(CONF.weight, false)
 
final IntegerValueCache inverseWeights = new IntegerValueCache(CONF.weight, true)
 
final CachedPropertyCollection highIndegreeProperties = new CachedPropertyCollection(CONF.HighIndregreeProperty)
 
final CachedPropertyCollection highOutdegreeProperties = new CachedPropertyCollection(CONF.HighOutdregreeProperty)
 

Detailed Description

A store for labels, descriptions and other metadata of classes and properties.

Values are retrieved from a DataSource and cached.

Member Function Documentation

◆ getCachedLabel()

Literal getCachedLabel ( String  iri,
boolean  preferPlural 
)

Returns a label, only taking into account previously cached values, without querying the data sources.

Fast.

Parameters
iriIRI of the resource whose label to return
preferPluralReturn conf:pluralLabel if available
Returns
The best label found, or null if none
76  {
77  if (preferPlural) {
78  Literal pluralLabel = pluralLabels.getCached(iri, defaultLanguage);
79  return pluralLabel == null ? getCachedLabel(iri, false) : pluralLabel;
80  }
81  return labels.getCached(iri, defaultLanguage);
82  }
Literal getCachedLabel(String iri, boolean preferPlural)
Returns a label, only taking into account previously cached values, without querying the data sources...
Definition: VocabularyStore.java:76
final I18nStringValueCache pluralLabels
Definition: VocabularyStore.java:48
String defaultLanguage
Definition: VocabularyStore.java:33
final I18nStringValueCache labels
Definition: VocabularyStore.java:47
Literal getCached(String iri, String preferredLang)
Definition: VocabularyStore.java:230

References VocabularyStore.defaultLanguage, VocabularyStore.I18nStringValueCache.getCached(), VocabularyStore.labels, and VocabularyStore.pluralLabels.

Referenced by ResourceDescription.Value.getLabel().

◆ getDescription() [1/2]

Literal getDescription ( String  iri)
96  {
97  return getDescription(iri, defaultLanguage);
98  }
Literal getDescription(String iri)
Definition: VocabularyStore.java:96

References VocabularyStore.defaultLanguage.

Referenced by ResourceDescription.ResourceProperty.getDescription(), and ResourceDescription.Value.getDescription().

◆ getDescription() [2/2]

Literal getDescription ( String  iri,
String  language 
)
100  {
101  return descriptions.get(iri, language);
102  }
final I18nStringValueCache descriptions
Definition: VocabularyStore.java:51
Literal get(String iri, String preferredLang)
Definition: VocabularyStore.java:227

References VocabularyStore.descriptions, and VocabularyStore.I18nStringValueCache.get().

◆ getHighIndegreeProperties()

CachedPropertyCollection getHighIndegreeProperties ( )
119  {
120  return highIndegreeProperties;
121  }
final CachedPropertyCollection highIndegreeProperties
Definition: VocabularyStore.java:54

References VocabularyStore.highIndegreeProperties.

Referenced by Dataset.buildDataSource(), and ResourceDescription.learnHighDegreeProperties().

◆ getHighOutdegreeProperties()

CachedPropertyCollection getHighOutdegreeProperties ( )
123  {
125  }
final CachedPropertyCollection highOutdegreeProperties
Definition: VocabularyStore.java:55

References VocabularyStore.highOutdegreeProperties.

Referenced by Dataset.buildDataSource(), and ResourceDescription.learnHighDegreeProperties().

◆ getInverseLabel() [1/2]

Literal getInverseLabel ( String  iri,
boolean  preferPlural 
)
84  {
85  return getInverseLabel(iri, preferPlural, defaultLanguage);
86  }
Literal getInverseLabel(String iri, boolean preferPlural)
Definition: VocabularyStore.java:84

References VocabularyStore.defaultLanguage.

Referenced by ResourceDescription.ResourceProperty.getInverseLabel(), and VocabularyStore.getInverseLabel().

◆ getInverseLabel() [2/2]

Literal getInverseLabel ( String  iri,
boolean  preferPlural,
String  language 
)
88  {
89  if (preferPlural) {
90  Literal pluralLabel = inversePluralLabels.get(iri, language);
91  return pluralLabel == null ? getInverseLabel(iri, false, language) : pluralLabel;
92  }
93  return inverseLabels.get(iri, language);
94  }
final I18nStringValueCache inversePluralLabels
Definition: VocabularyStore.java:50
final I18nStringValueCache inverseLabels
Definition: VocabularyStore.java:49

References VocabularyStore.I18nStringValueCache.get(), VocabularyStore.getInverseLabel(), VocabularyStore.inverseLabels, and VocabularyStore.inversePluralLabels.

◆ getLabel() [1/2]

Literal getLabel ( String  iri,
boolean  preferPlural 
)
57  {
58  return getLabel(iri, preferPlural, defaultLanguage);
59  }
Literal getLabel(String iri, boolean preferPlural)
Definition: VocabularyStore.java:57

References VocabularyStore.defaultLanguage.

Referenced by ResourceDescription.Value.getLabel(), ResourceDescription.ResourceProperty.getLabel(), and VocabularyStore.getLabel().

◆ getLabel() [2/2]

Literal getLabel ( String  iri,
boolean  preferPlural,
String  language 
)
61  {
62  if (preferPlural) {
63  Literal pluralLabel = pluralLabels.get(iri, language);
64  return pluralLabel == null ? getLabel(iri, false, language) : pluralLabel;
65  }
66  return labels.get(iri, language);
67  }

References VocabularyStore.I18nStringValueCache.get(), VocabularyStore.getLabel(), VocabularyStore.labels, and VocabularyStore.pluralLabels.

◆ getWeight()

int getWeight ( Property  property,
boolean  forInverse 
)

Returns the conf:weight of the property.

The inverse's weight can be requested; if no inverse weight is specified then the "forward" weight is used.

Parameters
propertyThe property whose weight to return
forInverseIf true, look for the inverse's weight first
Returns
The conf:weight assigned to the property
113  {
114  Integer result = forInverse ? inverseWeights.get(property.getURI()) : null;
115  if (result == null) result = weights.get(property.getURI());
116  return result == null ? 0 : result.intValue();
117  }
final IntegerValueCache weights
Definition: VocabularyStore.java:52
final IntegerValueCache inverseWeights
Definition: VocabularyStore.java:53
K get(String iri)
Definition: VocabularyStore.java:162

References VocabularyStore.ValueCache< K >.get(), VocabularyStore.inverseWeights, and VocabularyStore.weights.

Referenced by ResourceDescription.ResourceProperty.compareTo().

◆ setDataSource()

void setDataSource ( DataSource  dataSource)

Needs to be set before the instance is used! This is to allow creation of the store before the dataset is fully assembled.

39  {
40  this.dataSource = dataSource;
41  }
DataSource dataSource
Definition: VocabularyStore.java:32

References VocabularyStore.dataSource.

Referenced by Configuration.Configuration().

◆ setDefaultLanguage()

void setDefaultLanguage ( String  defaultLanguage)

Member Data Documentation

◆ dataSource

◆ defaultLanguage

◆ descriptions

final I18nStringValueCache descriptions = new I18nStringValueCache(RDFS.comment, false)
private

◆ highIndegreeProperties

◆ highOutdegreeProperties

◆ inverseLabels

final I18nStringValueCache inverseLabels = new I18nStringValueCache(RDFS.label, true)
private

◆ inversePluralLabels

final I18nStringValueCache inversePluralLabels = new I18nStringValueCache(CONF.pluralLabel, true)
private

◆ inverseWeights

final IntegerValueCache inverseWeights = new IntegerValueCache(CONF.weight, true)
private

◆ labels

final I18nStringValueCache labels = new I18nStringValueCache(RDFS.label, false)
private

◆ pluralLabels

◆ weights

final IntegerValueCache weights = new IntegerValueCache(CONF.weight, false)
private