public InputStream serialize()

in src/main/java/com/aliyun/mns/model/serialize/topic/SubscriptionSerializer.java [39:66]


    public InputStream serialize(SubscriptionMeta obj, String encoding) throws Exception {
        Document doc = getDocumentBuilder().newDocument();
        Element root = doc.createElementNS(DEFAULT_XML_NAMESPACE, SUBSCRIPTION_TAG);
        doc.appendChild(root);

        Element node = safeCreateContentElement(doc, NOTIFY_STRATEGY_TAG, obj.getNotifyStrategy(), null);
        if (node != null) {
            root.appendChild(node);
        }

        node = safeCreateContentElement(doc, ENDPOINT_TAG, obj.getEndpoint(), null);
        if (node != null) {
            root.appendChild(node);
        }

        node = safeCreateContentElement(doc, NOTIFY_CONTENT_FORMAT_TAG, obj.getNotifyContentFormat(), null);
        if (node != null) {
            root.appendChild(node);
        }

        node = safeCreateContentElement(doc, FILTER_TAG_TAG, obj.getFilterTag(), null);
        if (node != null) {
            root.appendChild(node);
        }

        String xml = XmlUtil.xmlNodeToString(doc, encoding);
        return new ByteArrayInputStream(xml.getBytes(encoding));
    }