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


Java Format.setTextMode方法代码示例

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


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

示例1: writeToXml

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Writes the JDOM document to the outputstream specified
 * @param out	the outputstream to which the JDOM document should be writed
 * @param validate if true, validate the dom structure before writing. If there is a validation error,
 * 		or the xsd is not in the classpath, an exception will be thrown.
 * @throws ConverterException
 */
public void writeToXml(Pathway pwy, OutputStream out, boolean validate) throws ConverterException {
	Document doc = createJdom(pwy);
	
	//Validate the JDOM document
	if (validate) validateDocument(doc);
	//			Get the XML code
	XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
	Format f = xmlcode.getFormat();
	f.setEncoding("UTF-8");
	f.setTextMode(Format.TextMode.PRESERVE);
	xmlcode.setFormat(f);

	try
	{
		//Send XML code to the outputstream
		xmlcode.output(doc, out);
	}
	catch (IOException ie)
	{
		throw new ConverterException(ie);
	}
}
 
开发者ID:PathVisio,项目名称:pathvisio,代码行数:30,代码来源:GpmlFormat2010a.java

示例2: write

import org.jdom.output.Format; //导入方法依赖的package包/类
static void write(File file) throws FileNotFoundException, IOException{
	Document document = new Document();
	Element root = new Element("document");
	root.setAttribute("version", Main.VERSION_ID);
	for(Blueprint bp : Main.blueprints){
		
		Element blueprint = writeGraphEditor(bp);
		
		for(VFunction f : bp.getFunctions()){
			blueprint.addContent(writeGraphEditor(f.getEditor()));
		}
		
		root.addContent(blueprint);
	}
	document.setRootElement(root);
	XMLOutputter output = new XMLOutputter();
	Format format = Format.getPrettyFormat();//getRawFormat();
	format.setOmitDeclaration(true);
	format.setOmitEncoding(true);
	format.setTextMode(TextMode.PRESERVE);
	output.setFormat(format);
	output.output(document, new FileOutputStream(file));
}
 
开发者ID:QuinnFreedman,项目名称:THINK-VPL,代码行数:24,代码来源:SaveFileIO.java

示例3: flush

import org.jdom.output.Format; //导入方法依赖的package包/类
public void flush() throws IOException
{
	XMLOutputter xmlcode = new XMLOutputter(Format.getPrettyFormat());
	Format f = xmlcode.getFormat();
	f.setEncoding("ISO-8859-1");
	f.setTextMode(Format.TextMode.PRESERVE);
	f.setLineSeparator(System.getProperty("line.separator"));
	xmlcode.setFormat(f);

	//Open a filewriter
	PrintWriter writer = new PrintWriter(out);
	xmlcode.output(doc, writer);
	out.flush();
}
 
开发者ID:PathVisio,项目名称:pathvisio,代码行数:15,代码来源:DgpmlOutputter.java

示例4: export

import org.jdom.output.Format; //导入方法依赖的package包/类
public byte[] export(ExportDataSet dataSet) {
    if (dataSet == null) {
        throw new IllegalArgumentException("Xml Exporter cannot handle NULL data.");
    }
    Element rootElement = new Element(DATA_ELEMENT, WORKFLOW_NAMESPACE);
    rootElement.addNamespaceDeclaration(SCHEMA_NAMESPACE);
    rootElement.setAttribute(SCHEMA_LOCATION_ATTR, WORKFLOW_SCHEMA_LOCATION, SCHEMA_NAMESPACE);
    Document document = new Document(rootElement);
    boolean shouldPrettyPrint = true;
    for (XmlExporter exporter : xmlImpexRegistry.getExporters()) {
    	Element exportedElement = exporter.export(dataSet);
    	if (exportedElement != null) {
    		if (!exporter.supportPrettyPrint()) {
    			shouldPrettyPrint = false;
    		}
    		appendIfNotEmpty(rootElement, exportedElement);
    	}
    }

    // TODO: KULRICE-4420 - this needs cleanup
    Format f;
    if (!shouldPrettyPrint) {
        f = Format.getRawFormat();
        f.setExpandEmptyElements(false);
        f.setTextMode(Format.TextMode.PRESERVE);
    } else {
        f = Format.getPrettyFormat();
    }
    XMLOutputter outputer = new XMLOutputter(f);
    StringWriter writer = new StringWriter();
    try {
        outputer.output(document, writer);
    } catch (IOException e) {
        throw new WorkflowRuntimeException("Could not write XML data export.", e);
    }
    return writer.toString().getBytes();
}
 
开发者ID:kuali,项目名称:kc-rice,代码行数:38,代码来源:XmlExporterServiceImpl.java


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