# Path: tmapi/constants.py
# XSD_ANY_URI = XSD + 'anyURI'
# 
# XSD_FLOAT = XSD + 'float'
# 
# XSD_INT = XSD + 'int'
# 
# XSD_LONG = XSD + 'long'
# 
# XSD_STRING = XSD + 'string'
# 
# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


from django.db import models
from tmapi.constants import XSD_ANY_URI, XSD_FLOAT, XSD_INT, XSD_LONG, \
    XSD_STRING
from tmapi.exceptions import ModelConstraintException
from locator import Locator
from reifiable import Reifiable
from scoped import Scoped





class DatatypeAware (Reifiable, Scoped):

    """Common base interface for `Occurrence`s and `Variant`s."""
    
    datatype = models.CharField(max_length=512, blank=True)
    value = models.TextField()

    class Meta:
        abstract = True
        app_label = 'tmapi'

    def get_datatype (self):
        """Returns the `Locator` identifying the datatype of the value.

        :rtype: `Locator`

        """
        return Locator(self.datatype)
        
    def get_value (self):
        """Returns the lexical representation of the value."""
        datatype = self.datatype
        value = self.value
        if datatype == XSD_FLOAT:
            value = float(value)

# Path: tmapi/constants.py
# XSD_ANY_URI = XSD + 'anyURI'
# 
# XSD_FLOAT = XSD + 'float'
# 
# XSD_INT = XSD + 'int'
# 
# XSD_LONG = XSD + 'long'
# 
# XSD_STRING = XSD + 'string'
# 
# Path: tmapi/exceptions.py
# class ModelConstraintException (TMAPIRuntimeException):
# 
#     """This exception is used to report Topic Maps - Data Model
#     constraint violations."""
# 
#     def __init__ (self, reporter, message):
#         """Creates a new ModelConstraintException with the specified
#         message.
# 
#         :param reporter: the construct which has thrown this exception
#         :type reporter: `Construct`
#         :param message: the detail message
#         :type message: string
# 
#         """
#         self._reporter = reporter
#         self._message = message
#     
#     def get_reporter (self):
#         """Return the `Construct` which has thrown the exception.
# 
#         :rtype: `Construct`
# 
#         """
#         return self._reporter


# Path: tmapi/models/datatype_aware.py
from django.db import models
from tmapi.constants import XSD_ANY_URI, XSD_FLOAT, XSD_INT, XSD_LONG, \
    XSD_STRING
from tmapi.exceptions import ModelConstraintException
from locator import Locator
from reifiable import Reifiable
from scoped import Scoped






class DatatypeAware (Reifiable, Scoped):

    """Common base interface for `Occurrence`s and `Variant`s."""
    
    datatype = models.CharField(max_length=512, blank=True)
    value = models.TextField()

    class Meta:
        abstract = True
        app_label = 'tmapi'

    def get_datatype (self):
        """Returns the `Locator` identifying the datatype of the value.

        :rtype: `Locator`

        """
        return Locator(self.datatype)
        
    def get_value (self):
        """Returns the lexical representation of the value."""
        datatype = self.datatype
        value = self.value
        if datatype == XSD_FLOAT:
            value = float(value)

        elif datatype == XSD_INT: