code: public void encode(DataItem dataItem) throws CborException {
          if (dataItem == null) {
              dataItem = SimpleValue.NULL;
          }
  
          if (dataItem.hasTag()) {
              Tag tagDi = dataItem.getTag();
              tagEncoder.encode(tagDi);
          }
  
          switch (dataItem.getMajorType()) {
          case UNSIGNED_INTEGER:
              unsignedIntegerEncoder.encode((UnsignedInteger) dataItem);
              break;
          case NEGATIVE_INTEGER:
              negativeIntegerEncoder.encode((NegativeInteger) dataItem);
              break;
          case BYTE_STRING:
              byteStringEncoder.encode((ByteString) dataItem);
              break;
          case UNICODE_STRING:
              unicodeStringEncoder.encode((UnicodeString) dataItem);
              break;
          case ARRAY:
              arrayEncoder.encode((Array) dataItem);
              break;
          case MAP:
              mapEncoder.encode((Map) dataItem);
              break;
          case SPECIAL:
              specialEncoder.encode((Special) dataItem);
              break;
          case TAG:
              tagEncoder.encode((Tag) dataItem);
              break;
          default:
              throw new CborException("Unknown major type");
          }
      }
docs: Encode a single {@link DataItem}.
  
  @param dataItem
  the {@link DataItem} to encode. If null, encoder encodes a
  {@link SimpleValue} NULL value.
  @throws CborException
  if {@link DataItem} could not be encoded or there was an
  problem with the {@link OutputStream}.