本文整理汇总了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;
}
}
示例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;
}
示例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;
}
}
示例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;
}
}