當前位置: 首頁>>代碼示例>>Java>>正文


Java MultiMessagePayload類代碼示例

本文整理匯總了Java中org.javarosa.core.services.transport.payload.MultiMessagePayload的典型用法代碼示例。如果您正苦於以下問題:Java MultiMessagePayload類的具體用法?Java MultiMessagePayload怎麽用?Java MultiMessagePayload使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


MultiMessagePayload類屬於org.javarosa.core.services.transport.payload包,在下文中一共展示了MultiMessagePayload類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: XFormAnswerDataSerializer

import org.javarosa.core.services.transport.payload.MultiMessagePayload; //導入依賴的package包/類
public IDataPayload createSerializedPayload	(FormInstance model, IDataReference ref) throws IOException {
	init();
	rootRef = FormInstance.unpackReference(ref);
	if(this.serializer == null) {
		this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
	}
	model.accept(this);
	if(theXmlDoc != null) {
		//TODO: Did this strip necessary data?
		byte[] form = XFormSerializer.getUtfBytes(theXmlDoc);
		if(dataPointers.size() == 0) {
			return new ByteArrayPayload(form, null, IDataPayload.PAYLOAD_TYPE_XML);
		}
		MultiMessagePayload payload = new MultiMessagePayload();
		payload.addPayload(new ByteArrayPayload(form, "xml_submission_file", IDataPayload.PAYLOAD_TYPE_XML));
          for (IDataPointer pointer : dataPointers) {
			payload.addPayload(new DataPointerPayload(pointer));
		}
		return payload;
	}
	else {
		return null;
	}
}
 
開發者ID:medic,項目名稱:javarosa,代碼行數:25,代碼來源:XFormSerializingVisitor.java

示例2: visit

import org.javarosa.core.services.transport.payload.MultiMessagePayload; //導入依賴的package包/類
public IDataPayload visit(MultiMessagePayload payload) {
    MultiMessagePayload ret = new MultiMessagePayload();
    if(top) {
        //TODO: Create a reasonable divider, and
        divider = "7_Clj7N9Heh_NJsJunQMlTQoHRzO0-0vA]";
        contentType = "multipart/form-data; boundary=" + divider + "";
    }
    HttpHeaderAppendingVisitor newVis = new HttpHeaderAppendingVisitor(divider);
    Enumeration en = payload.getPayloads().elements();
    while(en.hasMoreElements()) {
        IDataPayload child = (IDataPayload)en.nextElement();
        ret.addPayload((IDataPayload)child.accept(newVis));
    }
    HttpTransportHeader footer = new HttpTransportHeader();
    footer.addHeader("\r\n--", divider + "--");
    ret.addPayload(footer);
    return ret;
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:19,代碼來源:HttpHeaderAppendingVisitor.java

示例3: createSerializedPayload

import org.javarosa.core.services.transport.payload.MultiMessagePayload; //導入依賴的package包/類
@Override
public IDataPayload createSerializedPayload(FormInstance model, XPathReference ref) throws IOException {
    init();
    rootRef = FormInstance.unpackReference(ref);
    if (this.serializer == null) {
        this.setAnswerDataSerializer(new XFormAnswerDataSerializer());
    }
    model.accept(this);
    if (theXmlDoc != null) {
        //TODO: Did this strip necessary data?
        byte[] form = XFormSerializer.getUtfBytesFromDocument(theXmlDoc);
        if (dataPointers.size() == 0) {
            return new ByteArrayPayload(form, null, IDataPayload.PAYLOAD_TYPE_XML);
        }
        MultiMessagePayload payload = new MultiMessagePayload();
        payload.addPayload(new ByteArrayPayload(form, "xml_submission_file", IDataPayload.PAYLOAD_TYPE_XML));
        Enumeration en = dataPointers.elements();
        while (en.hasMoreElements()) {
            IDataPointer pointer = (IDataPointer)en.nextElement();
            payload.addPayload(new DataPointerPayload(pointer));
        }
        return payload;
    } else {
        return null;
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:27,代碼來源:XFormSerializingVisitor.java

示例4: visitIndividual

import org.javarosa.core.services.transport.payload.MultiMessagePayload; //導入依賴的package包/類
private IDataPayload visitIndividual(IDataPayload payload) {
    if(divider != null) {
        MultiMessagePayload message = new MultiMessagePayload();
        HttpTransportHeader divHeader = new HttpTransportHeader();
        if(first) {
            divHeader.addHeader("--", divider);
            first = false;
        } else {
            divHeader.addHeader("\r\n--", divider);
        }
        HttpTransportHeader header = new HttpTransportHeader();
        switch(payload.getPayloadType()) {
        case IDataPayload.PAYLOAD_TYPE_JPG:
            if(payload.getPayloadId() != null) {
                header.addHeader("Content-Disposition: ", "form-data; name=\"" + payload.getPayloadId() + "\"; filename=\"" + payload.getPayloadId() + "\"");
            }
            header.addHeader("Content-Type: ", getContentTypeFromId(payload.getPayloadType()));
            header.addHeader("Content-Transfer-Encoding: ", "binary");
            break;
        default:
            if(payload.getPayloadId() != null) {
                header.addHeader("Content-Disposition: ", "form-data; name=\"" + payload.getPayloadId() + "\"; filename=\"" + payload.getPayloadId() + "\"");
            }
            header.addHeader("Content-Type: ", getContentTypeFromId(payload.getPayloadType()));
            header.addHeader("Content-Transfer-Encoding: ", "binary");
        }

        HttpTransportHeader finalheader = new HttpTransportHeader();
        finalheader.addHeaderNoNewline("\r\n", "");

        message.addPayload(divHeader);
        message.addPayload(header);
        message.addPayload(finalheader);
        message.addPayload(payload);
        return message;
    }
    else {
        contentType = getContentTypeFromId(payload.getPayloadType());
        return payload;
    }
}
 
開發者ID:dimagi,項目名稱:commcare-j2me,代碼行數:42,代碼來源:HttpHeaderAppendingVisitor.java


注:本文中的org.javarosa.core.services.transport.payload.MultiMessagePayload類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。