'Sets the value of the object
:param value:
An integer, or a unicode string if _map is set
:raises:
ValueError - when an invalid value is passed'

def set(self, value):

    if isinstance(value, str_cls):
        if (self._map is None):
            raise ValueError(unwrap(u'\n                                                                                %s    value    is    a    unicode    string,    but    no    _map    provided\n                                                                                ', type_name(self)))
        if (value not in self._reverse_map):
            raise ValueError(unwrap(u'\n                                                                                %s    value,    %s,    is    not    present    in    the    _map\n                                                                                ', type_name(self), value))
        value = self._reverse_map[value]
    elif (not isinstance(value, int_types)):
        raise TypeError(unwrap(u'\n                                                                %s    value    must    be    an    integer    or    unicode    string    when    a    name_map\n                                                                is    provided,    not    %s\n                                                                ', type_name(self), type_name(value)))
    self._native = (self._map[value] if (self._map and (value in self._map)) else value)
    self.contents = int_to_bytes(value, signed=True)
    self._header = None
    if (self._trailer != ''):
        self._trailer = ''
