com.clarkparsia.pellet.datatypes.types.floating
Class RestrictedFloatingPointDatatype<T extends java.lang.Number & java.lang.Comparable<T>>

java.lang.Object
  extended by com.clarkparsia.pellet.datatypes.types.floating.RestrictedFloatingPointDatatype<T>
All Implemented Interfaces:
DataRange<T>, RestrictedDatatype<T>

public class RestrictedFloatingPointDatatype<T extends java.lang.Number & java.lang.Comparable<T>>
extends java.lang.Object
implements RestrictedDatatype<T>

Title: Restricted Float Datatype

Description: A subset of the value space of xsd:float.

Copyright: Copyright (c) 2009

Company: Clark & Parsia, LLC.

Author:
Mike Smith

Constructor Summary
RestrictedFloatingPointDatatype(Datatype<? extends T> datatype, FloatingPointType<T> type)
           
 
Method Summary
 RestrictedDatatype<T> applyConstrainingFacet(aterm.ATermAppl facet, java.lang.Object value)
          Apply a constraining facet to further restrict the value space
 boolean contains(java.lang.Object value)
          Check if a data range contains a particular value
 boolean containsAtLeast(int n)
          Check that a data range contains a minimum number of elements
 RestrictedDatatype<T> exclude(java.util.Collection<?> values)
          Exclude specific elements from the data range.
 Datatype<? extends T> getDatatype()
          Query for the base datatype of a restricted datatype.
 T getValue(int i)
          Return a value from an enumerable data range.
 RestrictedDatatype<T> intersect(RestrictedDatatype<?> other, boolean negated)
          Intersect this range with another range.
 boolean isEmpty()
          Convenience method equivalent to !containsAtLeast(0)
 boolean isEnumerable()
          Query if values in the data range can be enumerated.
 boolean isFinite()
          Query if there are a finite number of values in the data range.
 int size()
          Return the size of the data range.
 java.lang.String toString()
           
 RestrictedDatatype<T> union(RestrictedDatatype<?> other)
          Union this range with another range.
 java.util.Iterator<T> valueIterator()
          Get a (possibly infinite) iterator over values in the data range.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RestrictedFloatingPointDatatype

public RestrictedFloatingPointDatatype(Datatype<? extends T> datatype,
                                       FloatingPointType<T> type)
Method Detail

applyConstrainingFacet

public RestrictedDatatype<T> applyConstrainingFacet(aterm.ATermAppl facet,
                                                    java.lang.Object value)
Description copied from interface: RestrictedDatatype
Apply a constraining facet to further restrict the value space

Specified by:
applyConstrainingFacet in interface RestrictedDatatype<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
facet - the constraining facet name (typically a URI)
value - the value for the constraining facet. This is not necessarily in the value space of the base datatype (e.g., length facet values on string types are not)
Returns:
the further restricted value space

contains

public boolean contains(java.lang.Object value)
Description copied from interface: DataRange
Check if a data range contains a particular value

Specified by:
contains in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
value - the value to check
Returns:
true if the data range contains value, false else

containsAtLeast

public boolean containsAtLeast(int n)
Description copied from interface: DataRange
Check that a data range contains a minimum number of elements

Specified by:
containsAtLeast in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
n - the number of elements
Returns:
true if the data range contains n or more elements, false otherwise

exclude

public RestrictedDatatype<T> exclude(java.util.Collection<?> values)
Description copied from interface: RestrictedDatatype
Exclude specific elements from the data range. Used when a restricted data range is in a conjunction with a negative enumeration. Elements in values that are not contained in the restriction are ignored.

Specified by:
exclude in interface RestrictedDatatype<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
values - The values to exclude
Returns:
A new RestrictedDatatype

getDatatype

public Datatype<? extends T> getDatatype()
Description copied from interface: RestrictedDatatype
Query for the base datatype of a restricted datatype. This is not necessarily a primitive datatype.

Specified by:
getDatatype in interface RestrictedDatatype<T extends java.lang.Number & java.lang.Comparable<T>>
Returns:
the base datatype

getValue

public T getValue(int i)
Description copied from interface: DataRange
Return a value from an enumerable data range. Necessary to support LiteralValueBranch shiftTryNext

Specified by:
getValue in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
i - the index of the value in the data range
Returns:
the value

intersect

public RestrictedDatatype<T> intersect(RestrictedDatatype<?> other,
                                       boolean negated)
Description copied from interface: RestrictedDatatype
Intersect this range with another range. It must be the case that getDatatype().getPrimitiveDatatype().equals( other.getDatatype.getPrimiveDatatype()

Specified by:
intersect in interface RestrictedDatatype<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
other - restricted datatype to merge into this
negated - true if other is negated, false else
Returns:
a new RestrictedDatatype, representing the intersection of this and other

isEmpty

public boolean isEmpty()
Description copied from interface: DataRange
Convenience method equivalent to !containsAtLeast(0)

Specified by:
isEmpty in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Returns:
true if the data range contains no elements, false otherwise

isEnumerable

public boolean isEnumerable()
Description copied from interface: DataRange
Query if values in the data range can be enumerated.

Specified by:
isEnumerable in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Returns:
true if the data range is enumerable, false otherwise

isFinite

public boolean isFinite()
Description copied from interface: DataRange
Query if there are a finite number of values in the data range.

Specified by:
isFinite in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Returns:
true if the data range is finite, false otherwise

size

public int size()
Description copied from interface: DataRange
Return the size of the data range. Necessary to support LiteralValueBranch constructor

Specified by:
size in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Returns:
the size of the data range

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

union

public RestrictedDatatype<T> union(RestrictedDatatype<?> other)
Description copied from interface: RestrictedDatatype
Union this range with another range. It must be the case that getDatatype().getPrimitiveDatatype().equals( other.getDatatype.getPrimiveDatatype()

Specified by:
union in interface RestrictedDatatype<T extends java.lang.Number & java.lang.Comparable<T>>
Parameters:
other - restricted datatype to merge with this
Returns:
a new RestrictedDatatype, representing the intersection of this and other

valueIterator

public java.util.Iterator<T> valueIterator()
Description copied from interface: DataRange
Get a (possibly infinite) iterator over values in the data range.

Specified by:
valueIterator in interface DataRange<T extends java.lang.Number & java.lang.Comparable<T>>
Returns:
an Iterator


Copyright © 2004 Evren Sirin. All Rights Reserved.