Class RestrictionImpl

All Implemented Interfaces:
FrontsNode, OntClass, OntResource, Restriction, RDFNode, Resource
Direct Known Subclasses:
AllValuesFromRestrictionImpl, CardinalityRestrictionImpl, HasValueRestrictionImpl, MaxCardinalityRestrictionImpl, MinCardinalityRestrictionImpl, QualifiedRestrictionImpl, SomeValuesFromRestrictionImpl

public class RestrictionImpl extends OntClassImpl implements Restriction

Implementation of the ontology abstraction representing restrictions.

  • Field Details

    • factory

      public static Implementation factory
      A factory for generating Restriction facets from nodes in enhanced graphs. Note: should not be invoked directly by user code: use as() instead.
  • Constructor Details

    • RestrictionImpl

      public RestrictionImpl(Node n, EnhGraph g)

      Construct a restriction node represented by the given node in the given graph.

      Parameters:
      n - The node that represents the resource
      g - The enh graph that contains n
  • Method Details

    • setOnProperty

      public void setOnProperty(Property prop)

      Assert that the property that this restriction applies to is the given property. Any existing statements for onProperty will be removed.

      Specified by:
      setOnProperty in interface Restriction
      Parameters:
      prop - The property that this restriction applies to
      Throws:
      ProfileException - If the Profile.ON_PROPERTY() property is not supported in the current language profile.
    • getOnProperty

      public OntProperty getOnProperty()

      Answer the property that this property restriction applies to. If there is more than one such resource, an arbitrary selection is made (though well-defined property restrictions should not have more than one onProperty statement.

      Specified by:
      getOnProperty in interface Restriction
      Returns:
      The property that this property restriction applies to
      Throws:
      ProfileException - If the Profile.ON_PROPERTY() property is not supported in the current language profile.
    • onProperty

      public boolean onProperty(Property prop)

      Answer true if this restriction is a property restriction on the given property.

      Specified by:
      onProperty in interface Restriction
      Parameters:
      prop - A property to test against
      Returns:
      True if this restriction is a restriction on prop
      Throws:
      ProfileException - If the Profile.ON_PROPERTY() property is not supported in the current language profile.
    • removeOnProperty

      public void removeOnProperty(Property prop)

      Remove the given property as the property that this restriction applies to. If this statement is not true of the current model, nothing happens.

      Specified by:
      removeOnProperty in interface Restriction
      Parameters:
      prop - The property to be removed as a the property that this restriction applies to
    • asAllValuesFromRestriction

      public AllValuesFromRestriction asAllValuesFromRestriction()

      Answer a view of this restriction as an all values from expression

      Specified by:
      asAllValuesFromRestriction in interface Restriction
      Returns:
      This class, but viewed as an AllValuesFromRestriction node
      Throws:
      ConversionException - if the class cannot be converted to an all values from restriction given the lanuage profile and the current state of the underlying model.
    • asSomeValuesFromRestriction

      public SomeValuesFromRestriction asSomeValuesFromRestriction()

      Answer a view of this restriction as a some values from expression

      Specified by:
      asSomeValuesFromRestriction in interface Restriction
      Returns:
      This class, but viewed as a SomeValuesFromRestriction node
      Throws:
      ConversionException - if the class cannot be converted to an all values from restriction given the lanuage profile and the current state of the underlying model.
    • asHasValueRestriction

      public HasValueRestriction asHasValueRestriction()

      Answer a view of this restriction as a has value expression

      Specified by:
      asHasValueRestriction in interface Restriction
      Returns:
      This class, but viewed as a HasValueRestriction node
      Throws:
      ConversionException - if the class cannot be converted to a has value restriction given the lanuage profile and the current state of the underlying model.
    • asCardinalityRestriction

      public CardinalityRestriction asCardinalityRestriction()

      Answer a view of this restriction as a cardinality restriction class expression

      Specified by:
      asCardinalityRestriction in interface Restriction
      Returns:
      This class, but viewed as a CardinalityRestriction node
      Throws:
      ConversionException - if the class cannot be converted to a cardinality restriction given the lanuage profile and the current state of the underlying model.
    • asMinCardinalityRestriction

      public MinCardinalityRestriction asMinCardinalityRestriction()

      Answer a view of this restriction as a min cardinality restriction class expression

      Specified by:
      asMinCardinalityRestriction in interface Restriction
      Returns:
      This class, but viewed as a MinCardinalityRestriction node
      Throws:
      ConversionException - if the class cannot be converted to a min cardinality restriction given the lanuage profile and the current state of the underlying model.
    • asMaxCardinalityRestriction

      public MaxCardinalityRestriction asMaxCardinalityRestriction()

      Answer a view of this restriction as a max cardinality restriction class expression

      Specified by:
      asMaxCardinalityRestriction in interface Restriction
      Returns:
      This class, but viewed as a MaxCardinalityRestriction node
      Throws:
      ConversionException - if the class cannot be converted to a max cardinality restriction given the lanuage profile and the current state of the underlying model.
    • isAllValuesFromRestriction

      public boolean isAllValuesFromRestriction()

      Answer true if this restriction is an all values from restriction

      Specified by:
      isAllValuesFromRestriction in interface Restriction
      Returns:
      True if this is an allValuesFrom property restriction
      Throws:
      ProfileException - if Profile.ALL_VALUES_FROM() is not supported in the current profile
    • isSomeValuesFromRestriction

      public boolean isSomeValuesFromRestriction()

      Answer true if this restriction is a some values from restriction

      Specified by:
      isSomeValuesFromRestriction in interface Restriction
      Returns:
      True if this is a someValuesFrom property restriction
      Throws:
      ProfileException - if Profile.SOME_VALUES_FROM() is not supported in the current profile
    • isHasValueRestriction

      public boolean isHasValueRestriction()

      Answer true if this restriction is a has value restriction

      Specified by:
      isHasValueRestriction in interface Restriction
      Returns:
      True if this is a hasValue property restriction
      Throws:
      ProfileException - if Profile.HAS_VALUE() is not supported in the current profile
    • isCardinalityRestriction

      public boolean isCardinalityRestriction()

      Answer true if this restriction is a cardinality restriction (ie is a property restriction constructed with an owl:cardinality operator, or similar). This is not a test for a restriction that tests cardinalities in general.

      Specified by:
      isCardinalityRestriction in interface Restriction
      Returns:
      True if this is a cardinality property restriction
      Throws:
      ProfileException - if Profile.CARDINALITY() is not supported in the current profile
    • isMinCardinalityRestriction

      public boolean isMinCardinalityRestriction()

      Answer true if this restriction is a min cardinality restriction (ie is a property restriction constructed with an owl:minCardinality operator, or similar). This is not a test for a restriction that tests cardinalities in general.

      Specified by:
      isMinCardinalityRestriction in interface Restriction
      Returns:
      True if this is a minCardinality property restriction
      Throws:
      ProfileException - if Profile.MIN_CARDINALITY() is not supported in the current profile
    • isMaxCardinalityRestriction

      public boolean isMaxCardinalityRestriction()

      Answer true if this restriction is a max cardinality restriction (ie is a property restriction constructed with an owl:maxCardinality operator, or similar). This is not a test for a restriction that tests cardinalities in general.

      Specified by:
      isMaxCardinalityRestriction in interface Restriction
      Returns:
      True if this is a maxCardinality property restriction
      Throws:
      ProfileException - if Profile.MAX_CARDINALITY() is not supported in the current profile
    • convertToAllValuesFromRestriction

      public AllValuesFromRestriction convertToAllValuesFromRestriction(Resource cls)

      Convert this restriction to an all values from class expression.

      Specified by:
      convertToAllValuesFromRestriction in interface Restriction
      Parameters:
      cls - The class to which all values of the restricted property must belong, to be in the extension of this restriction
      Returns:
      This class, but converted to a AllValuesFromRestriction class expression
      Throws:
      ProfileException - if Profile.ALL_VALUES_FROM() is not supported in the current profile
    • convertToSomeValuesFromRestriction

      public SomeValuesFromRestriction convertToSomeValuesFromRestriction(Resource cls)

      Convert this restriction to a some values from class expression

      Specified by:
      convertToSomeValuesFromRestriction in interface Restriction
      Parameters:
      cls - The class to which at least one value of the restricted property must belong, to be in the extension of this restriction
      Returns:
      This class, but converted to a SomeValuesFromRestriction node
      Throws:
      ProfileException - if Profile.SOME_VALUES_FROM() is not supported in the current profile
    • convertToHasValueRestriction

      public HasValueRestriction convertToHasValueRestriction(RDFNode value)

      Convert this restriction to a has value class expression

      Specified by:
      convertToHasValueRestriction in interface Restriction
      Parameters:
      value - The value which the restricted property must have, for resource to be in the extension of this restriction
      Returns:
      This class, but converted to a HasValueRestriction
      Throws:
      ProfileException - if Profile.HAS_VALUE() is not supported in the current profile
    • convertToCardinalityRestriction

      public CardinalityRestriction convertToCardinalityRestriction(int cardinality)

      Convert this restriction to a cardinality restriction class expression

      Specified by:
      convertToCardinalityRestriction in interface Restriction
      Parameters:
      cardinality - The exact cardinality for the restricted property
      Returns:
      This class, but converted to a CardinalityRestriction node
      Throws:
      ProfileException - if Profile.CARDINALITY() is not supported in the current profile
    • convertToMinCardinalityRestriction

      public MinCardinalityRestriction convertToMinCardinalityRestriction(int cardinality)

      Convert this restriction to a min cardinality restriction class expression

      Specified by:
      convertToMinCardinalityRestriction in interface Restriction
      Parameters:
      cardinality - The minimum cardinality for the restricted property
      Returns:
      This class, but converted to a MinCardinalityRestriction node
      Throws:
      ProfileException - if Profile.MIN_CARDINALITY() is not supported in the current profile
    • convertToMaxCardinalityRestriction

      public MaxCardinalityRestriction convertToMaxCardinalityRestriction(int cardinality)

      Convert this restriction to a max cardinality restriction class expression

      Specified by:
      convertToMaxCardinalityRestriction in interface Restriction
      Parameters:
      cardinality - The maximum cardinality for the restricted property
      Returns:
      This class, but converted to a MaxCardinalityRestriction node
      Throws:
      ProfileException - if Profile.MAX_CARDINALITY() is not supported in the current profile