GeoPubby  Version 0.1.0.0
ResourceDescription.Value Class Reference
Inheritance diagram for ResourceDescription.Value:
Collaboration diagram for ResourceDescription.Value:

Public Member Functions

 Value (RDFNode valueNode, Property predicate, VocabularyStore vocabularyStore)
 
Node getNode ()
 
String getBrowsableURL ()
 
boolean hasPrefix ()
 
String getPrefix ()
 
String getLocalName ()
 
String getLabel ()
 
String getDescription ()
 
String getDatatypeLabel ()
 
String getDatatypeURI ()
 
boolean isType ()
 
int compareTo (Value other)
 

Private Attributes

final RDFNode node
 
URIPrefixer prefixer
 
Property predicate
 
VocabularyStore vocabularyStore
 

Constructor & Destructor Documentation

◆ Value()

Value ( RDFNode  valueNode,
Property  predicate,
VocabularyStore  vocabularyStore 
)
634  {
635  this.node = valueNode;
636  this.predicate = predicate;
638  if (valueNode.isURIResource()) {
639  prefixer = new URIPrefixer((Resource) valueNode.as(Resource.class), getPrefixes());
640  }
641  }
PrefixMapping getPrefixes()
Returns a prefix mapping containing all prefixes from the input model and from the configuration,...
Definition: ResourceDescription.java:419
Property predicate
Definition: ResourceDescription.java:632
final RDFNode node
Definition: ResourceDescription.java:630
VocabularyStore vocabularyStore
Definition: ResourceDescription.java:633
URIPrefixer prefixer
Definition: ResourceDescription.java:631

References ResourceDescription.getPrefixes(), ResourceDescription.Value.predicate, ResourceDescription.Value.prefixer, and ResourceDescription.Value.vocabularyStore.

Referenced by ResourceDescription.Value.compareTo().

Member Function Documentation

◆ compareTo()

int compareTo ( Value  other)
716  {
717  if (!(other instanceof Value)) {
718  return 0;
719  }
720  Value otherValue = (Value) other;
721  if (getNode().isURI() && otherValue.getNode().isURI()) {
722  return getNode().getURI().compareTo(otherValue.getNode().getURI());
723  }
724  if (getNode().isURI()) {
725  return 1;
726  }
727  if (otherValue.getNode().isURI()) {
728  return -1;
729  }
730  if (getNode().isBlank() && otherValue.getNode().isBlank()) {
731  return getNode().getBlankNodeLabel().compareTo(otherValue.getNode().getBlankNodeLabel());
732  }
733  if (getNode().isBlank()) {
734  return 1;
735  }
736  if (otherValue.getNode().isBlank()) {
737  return -1;
738  }
739  // TODO Typed literals, language literals
740  return getNode().getLiteralLexicalForm().compareTo(otherValue.getNode().getLiteralLexicalForm());
741  }
Value(RDFNode valueNode, Property predicate, VocabularyStore vocabularyStore)
Definition: ResourceDescription.java:634
Node getNode()
Definition: ResourceDescription.java:642

References ResourceDescription.Value.getNode(), and ResourceDescription.Value.Value().

◆ getBrowsableURL()

String getBrowsableURL ( )
645  {
646  if (!node.isURIResource()) return null;
647  HypermediaControls controls = HypermediaControls.createFromIRI(
648  node.asResource().getURI(), config);
649  if (controls == null) return node.asResource().getURI();
650  return controls.getPageURL();
651  }
final Configuration config
Definition: ResourceDescription.java:55

References ResourceDescription.config, HypermediaControls.createFromIRI(), HypermediaControls.getPageURL(), and ResourceDescription.Value.node.

◆ getDatatypeLabel()

String getDatatypeLabel ( )
693  {
694  if (!node.isLiteral()) return null;
695  String uri = ((Literal) node.as(Literal.class)).getDatatypeURI();
696  if (uri == null) return null;
697  URIPrefixer datatypePrefixer = new URIPrefixer(uri, getPrefixes());
698  if (datatypePrefixer.hasPrefix()) {
699  return datatypePrefixer.toTurtle();
700  } else {
701  return "?:" + datatypePrefixer.getLocalName();
702  }
703  }
String getDatatypeURI()
Definition: ResourceDescription.java:705

References ResourceDescription.Value.getDatatypeURI(), URIPrefixer.getLocalName(), ResourceDescription.getPrefixes(), URIPrefixer.hasPrefix(), ResourceDescription.Value.node, and URIPrefixer.toTurtle().

◆ getDatatypeURI()

String getDatatypeURI ( )
705  {
706  if (!node.isLiteral()) return null;
707  String uri = ((Literal) node.as(Literal.class)).getDatatypeURI();
708  if (uri == null) return null;
709  return uri;
710  }

References ResourceDescription.Value.node.

Referenced by ResourceDescription.Value.getDatatypeLabel().

◆ getDescription()

String getDescription ( )
690  {
691  return vocabularyStore.getDescription(node.asNode().getURI()).getLexicalForm();
692  }
Literal getDescription(String iri)
Definition: VocabularyStore.java:96

References VocabularyStore.getDescription(), ResourceDescription.Value.node, and ResourceDescription.Value.vocabularyStore.

◆ getLabel()

String getLabel ( )
667  {
668  System.out.println("Getting label for "+node.toString());
669  if (!node.isResource()) return null;
670  System.out.println(node.toString()+" is a resource!");
671  Literal result = null;
672  if (node.isURIResource()) {
673  if (predicate.equals(RDF.type)) {
674  // Look up class labels in vocabulary store
675  result = vocabularyStore.getLabel(node.asNode().getURI(), false);
676  } else if (node.isURIResource()) {
677  // If it's not a class, see if we happen to have a label cached
678  result = vocabularyStore.getCachedLabel(node.asResource().getURI(), false);
679  //System.out.println("HasCachedLabel? "+result.toString());
680  }
681  }
682  if (result == null) {
683  // Use any label that may be included in the description model
684  result = new ResourceDescription(node.asResource(), model, config).getLabel();
685  //System.out.println("Resource has label? "+result.toString());
686  }
687  if (result == null) return null;
688  return toTitleCase(result.getLexicalForm(), result.getLanguage());
689  }
String toTitleCase(String s, String lang)
Converts a string to Title Case.
Definition: ResourceDescription.java:762
final Model model
Definition: ResourceDescription.java:53
ResourceDescription(HypermediaControls controller, Model model, Configuration config)
Constructor for this class.
Definition: ResourceDescription.java:76
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
Literal getLabel(String iri, boolean preferPlural)
Definition: VocabularyStore.java:57

References ResourceDescription.config, VocabularyStore.getCachedLabel(), VocabularyStore.getLabel(), ResourceDescription.model, ResourceDescription.Value.node, ResourceDescription.Value.predicate, ResourceDescription.ResourceDescription(), ResourceDescription.toTitleCase(), and ResourceDescription.Value.vocabularyStore.

◆ getLocalName()

String getLocalName ( )
661  {
662  if (prefixer == null) {
663  return null;
664  }
665  return prefixer.getLocalName();
666  }
String getLocalName()
Definition: URIPrefixer.java:49

References URIPrefixer.getLocalName(), and ResourceDescription.Value.prefixer.

◆ getNode()

Node getNode ( )
642  {
643  return node.asNode();
644  }

References ResourceDescription.Value.node.

Referenced by ResourceDescription.Value.compareTo().

◆ getPrefix()

String getPrefix ( )
655  {
656  if (prefixer == null) {
657  return null;
658  }
659  return prefixer.getPrefix();
660  }
String getPrefix()
Definition: URIPrefixer.java:45

References URIPrefixer.getPrefix(), and ResourceDescription.Value.prefixer.

◆ hasPrefix()

boolean hasPrefix ( )
652  {
653  return prefixer != null && prefixer.hasPrefix();
654  }
boolean hasPrefix()
Definition: URIPrefixer.java:41

References URIPrefixer.hasPrefix(), and ResourceDescription.Value.prefixer.

◆ isType()

boolean isType ( )
712  {
713  return predicate.equals(RDF.type);
714  }

References ResourceDescription.Value.predicate.

Member Data Documentation

◆ node

◆ predicate

◆ prefixer

◆ vocabularyStore