当前位置: 首页>>代码示例>>Java>>正文


Java KXmlSerializer.flush方法代码示例

本文整理汇总了Java中org.kxml2.io.KXmlSerializer.flush方法的典型用法代码示例。如果您正苦于以下问题:Java KXmlSerializer.flush方法的具体用法?Java KXmlSerializer.flush怎么用?Java KXmlSerializer.flush使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.kxml2.io.KXmlSerializer的用法示例。


在下文中一共展示了KXmlSerializer.flush方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: generateXmlManifestList

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public void generateXmlManifestList(PrintWriter output, CallingContext cc) throws IOException, ODKDatastoreException {
  Document d = new Document();
  d.setStandalone(true);
  d.setEncoding(HtmlConsts.UTF8_ENCODE);
  Element e = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.MANIFEST_TAG);
  e.setPrefix(null, XML_TAG_NAMESPACE);
  d.addChild(0, Node.ELEMENT, e);
  int idx = 0;
  e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);

  // build XML table of form information
  BinaryContentManipulator manifest = form.getManifestFileset();
  if ( manifest != null ) {
      int fileCount = manifest.getAttachmentCount(cc);
      for ( int i = 1 ; i <= fileCount ; ++i ) {
        idx = generateManifestXmlEntry(d, e, idx, form.getUri(), manifest, i, cc);
      }
  }

  KXmlSerializer serializer = new KXmlSerializer();
  serializer.setOutput(output);
  // setting the response content type emits the xml header.
  // just write the body here...
  d.writeChildren(serializer); 
  serializer.flush();
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:27,代码来源:XFormsManifestXmlTable.java

示例2: generateXmlListOfForms

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public void generateXmlListOfForms(PrintWriter output, CallingContext cc) throws IOException, ODKDatastoreException {
  Document d = new Document();
  d.setStandalone(true);
  d.setEncoding(HtmlConsts.UTF8_ENCODE);
  Element e = d.createElement(XML_TAG_NAMESPACE, XFormsTableConsts.XFORMS_TAG);
  e.setPrefix(null, XML_TAG_NAMESPACE);
  d.addChild(0, Node.ELEMENT, e);
  int idx = 0;
  e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);

  // build XML table of form information
  for (IForm form : forms) {
    if (!form.hasValidFormDefinition() || !form.getDownloadEnabled())
      continue;

    idx = generateFormXmlEntry(d, e, idx, form, cc);
  }

  KXmlSerializer serializer = new KXmlSerializer();
  serializer.setOutput(output);
  // setting the response content type emits the xml header.
  // just write the body here...
  d.writeChildren(serializer);
  serializer.flush();
}
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:26,代码来源:XFormsXmlTable.java

示例3: elementToString

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public static String elementToString(Element e){
	KXmlSerializer serializer = new KXmlSerializer();

	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	DataOutputStream dos = new DataOutputStream(bos);
	String s=null;
	try {
		serializer.setOutput(dos, null);
		e.write(serializer);
		serializer.flush();
		s = new String(bos.toByteArray(),"UTF-8");
		return s;
	}catch (UnsupportedEncodingException uce){
		uce.printStackTrace();
	} catch (Exception ex) {
		ex.printStackTrace();
		return null;
	}

	return null;

}
 
开发者ID:medic,项目名称:javarosa,代码行数:23,代码来源:XFormSerializer.java

示例4: elementToString

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public static String elementToString(Element e) {
    KXmlSerializer serializer = new KXmlSerializer();

    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    DataOutputStream dos = new DataOutputStream(bos);
    String s;
    try {
        serializer.setOutput(dos, null);
        e.write(serializer);
        serializer.flush();
        s = new String(bos.toByteArray(), "UTF-8");
        return s;
    } catch (UnsupportedEncodingException uce) {
        uce.printStackTrace();
    } catch (Exception ex) {
        ex.printStackTrace();
        return null;
    }

    return null;
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:22,代码来源:XFormSerializer.java

示例5: emitXmlWrappedCsv

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
private void emitXmlWrappedCsv(List<Row> resultTable, List<String> headers) throws IOException {

    Document d = new Document();
    d.setStandalone(true);
    d.setEncoding(HtmlConsts.UTF8_ENCODE);
    Element e = d.createElement(XML_TAG_NAMESPACE, XML_TAG_ENTRIES);
    d.addChild(0, Node.ELEMENT, e);
    int idx = 0;
    e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    if (websafeCursorString != null) {
      Element cursor = d.createElement(XML_TAG_NAMESPACE, XML_TAG_CURSOR);
      e.addChild(idx++, Node.ELEMENT, cursor);
      cursor.addChild(0, Node.TEXT, websafeCursorString);
      e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    }
    Element header = d.createElement(XML_TAG_NAMESPACE, XML_TAG_HEADER);
    e.addChild(idx++, Node.ELEMENT, header);
    header.addChild(0, Node.TEXT, generateCommaSeperatedElements(headers));
    e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);

    Element resultRow;
    // generate rows
    for (Row row : resultTable) {
      resultRow = d.createElement(XML_TAG_NAMESPACE, XML_TAG_RESULT);
      e.addChild(idx++, Node.ELEMENT, resultRow);
      String csvRow = generateCommaSeperatedElements(row.getFormattedValues());
      resultRow.addChild(0, Node.TEXT, csvRow);
      e.addChild(idx++, Node.IGNORABLE_WHITESPACE, BasicConsts.NEW_LINE);
    }

    KXmlSerializer serializer = new KXmlSerializer();
    serializer.setOutput(output);
    // setting the response content type emits the xml header.
    // just write the body here...
    d.writeChildren(serializer);
    serializer.flush();
  }
 
开发者ID:opendatakit,项目名称:aggregate,代码行数:38,代码来源:FragmentedCsvFormatter.java

示例6: getStream

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public static ByteArrayOutputStream getStream(Document doc) {
	KXmlSerializer serializer = new KXmlSerializer();
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	DataOutputStream dos = new DataOutputStream(bos);
	try {
		serializer.setOutput(dos, null);
		doc.write(serializer);
		serializer.flush();
		return bos;
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:15,代码来源:XFormSerializer.java

示例7: getUtfBytes

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public static byte[] getUtfBytes(Document doc) {
	KXmlSerializer serializer = new KXmlSerializer();
	ByteArrayOutputStream bos = new ByteArrayOutputStream();
	try {
		Writer osw = new OutputStreamWriter(bos, "UTF-8");
		serializer.setOutput(osw);
		doc.write(serializer);
		serializer.flush();
		return bos.toByteArray();
	} catch (Exception e) {
		e.printStackTrace();
		return null;
	}
}
 
开发者ID:medic,项目名称:javarosa,代码行数:15,代码来源:XFormSerializer.java

示例8: soap

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
public Vector<?> soap(HttpServletRequest req) throws JSONException,
		IOException {
	JSONObject json = new JSONObject(IO.read(req));
	// TODO: Route to SOAP ...
	String action = req.getAttribute(Route.ACTION).toString();
	if (action == null) {
		throw new JSONException("Missing SOAP action.");
	}
	final Route route = router.route(action);
	if (route == null) {
		throw new JSONException("Not support action:" + action);
	}
	final SoapObject so = new SoapObject(route.getNameSpace(),
			route.getAction());

	Envelope envelope = createEnvelope(so, IO.toElement(json, route.getNameSpace(),
			route.getAction()));
	KXmlSerializer xmlWriter = new KXmlSerializer();
	ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
	xmlWriter.setOutput(outputStream, "UTF-8");
	envelope.write(xmlWriter);
	xmlWriter.flush();
	Logger.getLogger(Soaper.class.getName()).info(outputStream.toString());
	
	HttpTransportSE ht = getHttpTransportSE(route.getSoapUrl());
	try {
		ht.call(so.getName(), envelope);
		Vector<?> ro = (Vector<?>) envelope.getResponse();
		return ro;
	} catch (HttpResponseException | XmlPullParserException | SoapFault e) {
		throw new JSONException(e);
	}
}
 
开发者ID:cheeray,项目名称:ws-bridge,代码行数:34,代码来源:Soaper.java

示例9: processSchema

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
private static void processSchema(FormDef form) {
    Document schemaDoc = InstanceSchema.generateInstanceSchema(form);
    KXmlSerializer serializer = new KXmlSerializer();
    try {
        serializer.setOutput(System.out, null);
        schemaDoc.write(serializer);
        serializer.flush();
    } catch (IOException e) {
        e.printStackTrace();
    }
}
 
开发者ID:dimagi,项目名称:commcare-j2me,代码行数:12,代码来源:Harness.java

示例10: writeSubmissionManifest

import org.kxml2.io.KXmlSerializer; //导入方法依赖的package包/类
private static void writeSubmissionManifest(
	EncryptedFormInformation formInfo,
	File submissionXml, List<File> mediaFiles) throws EncryptionException {

Document d = new Document();
d.setStandalone(true);
d.setEncoding(UTF_8);
Element e = d.createElement(XML_ENCRYPTED_TAG_NAMESPACE, DATA);
e.setPrefix(null, XML_ENCRYPTED_TAG_NAMESPACE);
e.setAttribute(null, ID, formInfo.formId);
if ( formInfo.formVersion != null ) {
	e.setAttribute(null, VERSION, formInfo.formVersion);
}
e.setAttribute(null,  ENCRYPTED, "yes");
d.addChild(0, Node.ELEMENT, e);

int idx = 0;
Element c;
c = d.createElement(XML_ENCRYPTED_TAG_NAMESPACE, BASE64_ENCRYPTED_KEY);
c.addChild(0, Node.TEXT, formInfo.base64RsaEncryptedSymmetricKey);
e.addChild(idx++, Node.ELEMENT, c);

c = d.createElement(XML_OPENROSA_NAMESPACE, META);
c.setPrefix("orx", XML_OPENROSA_NAMESPACE);
{
	Element instanceTag = d.createElement(XML_OPENROSA_NAMESPACE, INSTANCE_ID);
	instanceTag.addChild(0, Node.TEXT, formInfo.instanceMetadata.instanceId);
	c.addChild(0, Node.ELEMENT, instanceTag);
}
e.addChild(idx++, Node.ELEMENT, c);
e.addChild(idx++, Node.IGNORABLE_WHITESPACE, NEW_LINE);

      if (mediaFiles != null) {
          for (File file : mediaFiles) {
              c = d.createElement(XML_ENCRYPTED_TAG_NAMESPACE, MEDIA);
              Element fileTag = d.createElement(XML_ENCRYPTED_TAG_NAMESPACE, FILE);
              fileTag.addChild(0, Node.TEXT, file.getName() + ".enc");
              c.addChild(0, Node.ELEMENT, fileTag);
              e.addChild(idx++, Node.ELEMENT, c);
              e.addChild(idx++, Node.IGNORABLE_WHITESPACE, NEW_LINE);
          }
      }

c = d.createElement(XML_ENCRYPTED_TAG_NAMESPACE, ENCRYPTED_XML_FILE);
c.addChild(0, Node.TEXT, submissionXml.getName() + ".enc");
e.addChild(idx++, Node.ELEMENT, c);

c = d.createElement(XML_ENCRYPTED_TAG_NAMESPACE, BASE64_ENCRYPTED_ELEMENT_SIGNATURE);
c.addChild(0, Node.TEXT, formInfo.getBase64EncryptedElementSignature());
e.addChild(idx++, Node.ELEMENT, c);

FileOutputStream fout = null;
      OutputStreamWriter writer = null;
      try {
          fout = new FileOutputStream(submissionXml);
          writer = new OutputStreamWriter(fout, UTF_8);

          KXmlSerializer serializer = new KXmlSerializer();
	serializer.setOutput(writer);
	// setting the response content type emits the xml header.
	// just write the body here...
	d.writeChildren(serializer);
	serializer.flush();
	writer.flush();
          fout.getChannel().force(true);
	writer.close();
} catch (Exception ex) {
	ex.printStackTrace();
          String msg = "Error writing submission.xml for encrypted submission: "
                  + submissionXml.getParentFile().getName();
          Log.e(t, msg);
	throw new EncryptionException(msg, ex);
} finally {
          IOUtils.closeQuietly(writer);
          IOUtils.closeQuietly(fout);
      }
  }
 
开发者ID:Last-Mile-Health,项目名称:ODK-Liberia,代码行数:78,代码来源:EncryptionUtils.java


注:本文中的org.kxml2.io.KXmlSerializer.flush方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。