code: @Override
      public Document readXML() {
          int len = readInteger();
          if (len == 1) {
              // Empty string, should not happen
              return null;
          }
          if ((len & 1) == 0) {
              // Reference
              return (Document) getReference(len >> 1);
          }
          len >>= 1;
          int limit = buf.limit();
          final ByteBuffer strBuf = buf.buf();
          strBuf.limit(strBuf.position() + len);
          final String xmlString = AMF.CHARSET.decode(strBuf).toString();
          buf.limit(limit); // Reset the limit
          Document doc = null;
          try {
              doc = XMLUtils.stringToDoc(xmlString);
          } catch (IOException ioex) {
              log.error("IOException converting xml to dom", ioex);
          }
          storeReference(doc);
          return doc;
      }
docs: {@inheritDoc}