/**
   * Add an IN or OUT interface object
   *
   * @param inter a COPSInterface
   * @throws COPSException
   */
  public void add(COPSInterface inter) throws COPSException {
    if (!(inter.isInInterface() || inter.isOutInterface())) throw new COPSException("No Interface");

    // Message integrity object should be the very last one
    // If it is already added
    if (_integrity != null) throw new COPSException("Integrity should be the last one");

    if (inter.isInInterface()) {
      if (_inInterface != null) throw new COPSException("Object inInterface exits");

      if (inter.isIpv4Address()) {
        COPSIpv4InInterface inInter = (COPSIpv4InInterface) inter;
        _inInterface = inInter;
      } else {
        COPSIpv6InInterface inInter = (COPSIpv6InInterface) inter;
        _inInterface = inInter;
      }
    } else {
      if (_outInterface != null) throw new COPSException("Object outInterface exits");

      if (inter.isIpv4Address()) {
        COPSIpv4OutInterface outInter = (COPSIpv4OutInterface) inter;
        _outInterface = outInter;
      } else {
        COPSIpv6OutInterface outInter = (COPSIpv6OutInterface) inter;
        _outInterface = outInter;
      }
    }
    setMsgLength();
  }