Class EnhNode

  • All Implemented Interfaces:
    FrontsNode
    Direct Known Subclasses:
    LiteralImpl, ResourceImpl

    public class EnhNode
    extends Polymorphic<RDFNode>
    implements FrontsNode

    A specialisation of Polymorphic that models an extended node in a an extended graph. An extended node wraps a normal node, and adds additional convenience access or user affordances, though the state remains in the graph itself.

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      <T extends RDFNode>
      T
      as​(java.lang.Class<T> t)
      allow subclasses to implement RDFNode & its subinterface
      Node asNode()
      Answer the graph node that this enhanced node wraps
      <X extends RDFNode>
      boolean
      canAs​(java.lang.Class<X> t)
      API-level method for polymorphic testing
      boolean equals​(java.lang.Object o)
      An enhanced node is equal to another enhanced node n iff the underlying nodes are equal.
      EnhGraph getGraph()
      Answer the graph containing this node
      int hashCode()
      The hash code of an enhanced node is defined to be the same as the underlying node.
      boolean isAnon()
      An enhanced node is Anon[ymous] iff its underlying node is Blank.
      boolean isLiteral()
      An enhanced node is Literal iff its underlying node is too.
      boolean isResource()
      An enhanced node is a resource if it's node is a URI node, a blank node or a triple term.
      boolean isStmtResource()
      An enhanced node is a statement resource iff its underlying node is a triple term (RDF-star).
      boolean isURIResource()
      An enhanced node is a URI resource iff its underlying node is too.
      boolean isValid()
      answer true iff this enhanced node is still underpinned in the graph by triples appropriate to its type.
      <X extends RDFNode>
      X
      viewAs​(java.lang.Class<X> t)
      Answer a facet of this node, where that facet is denoted by the given type.
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • asNode

        public Node asNode()
        Answer the graph node that this enhanced node wraps
        Specified by:
        asNode in interface FrontsNode
        Returns:
        A plain node
      • getGraph

        public EnhGraph getGraph()
        Answer the graph containing this node
        Returns:
        An enhanced graph
      • isAnon

        public final boolean isAnon()
        An enhanced node is Anon[ymous] iff its underlying node is Blank.
      • isLiteral

        public final boolean isLiteral()
        An enhanced node is Literal iff its underlying node is too.
      • isURIResource

        public final boolean isURIResource()
        An enhanced node is a URI resource iff its underlying node is too.
      • isStmtResource

        public final boolean isStmtResource()
        An enhanced node is a statement resource iff its underlying node is a triple term (RDF-star).
      • isResource

        public final boolean isResource()
        An enhanced node is a resource if it's node is a URI node, a blank node or a triple term.
      • viewAs

        public <X extends RDFNode> X viewAs​(java.lang.Class<X> t)
        Answer a facet of this node, where that facet is denoted by the given type.
        Parameters:
        t - A type denoting the desired facet of the underlying node
        Returns:
        An enhanced nodet that corresponds to t; this may be this Java object, or a different object.
      • as

        public <T extends RDFNode> T as​(java.lang.Class<T> t)
        allow subclasses to implement RDFNode & its subinterface
      • canAs

        public <X extends RDFNode> boolean canAs​(java.lang.Class<X> t)
        API-level method for polymorphic testing
      • hashCode

        public final int hashCode()
        The hash code of an enhanced node is defined to be the same as the underlying node.
        Overrides:
        hashCode in class java.lang.Object
        Returns:
        The hashcode as an int
      • equals

        public final boolean equals​(java.lang.Object o)
        An enhanced node is equal to another enhanced node n iff the underlying nodes are equal. We generalise to allow the other object to be any class implementing asNode, because we allow other implemementations of Resource than EnhNodes, at least in principle. This is deemed to be a complete and correct interpretation of enhanced node equality, which is why this method has been marked final.
        Specified by:
        equals in class Polymorphic<RDFNode>
        Parameters:
        o - An object to test for equality with this node
        Returns:
        True if o is equal to this node.
      • isValid

        public boolean isValid()
        Description copied from class: Polymorphic
        answer true iff this enhanced node is still underpinned in the graph by triples appropriate to its type.
        Specified by:
        isValid in class Polymorphic<RDFNode>