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


Java Format.getPrettyFormat方法代码示例

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


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

示例1: doOutput

import org.jdom.output.Format; //导入方法依赖的package包/类
public void doOutput(List<StudentEntity> students){
	  	Element root = new Element("students");  
        Document document = new Document(root);  
        Iterator<StudentEntity> iter = students.iterator();
        while(iter.hasNext()){
        	StudentEntity student = iter.next();
        	Element studentEl = new Element("student");
        	studentEl.addContent(new Element("studentnumber").setText(student.getStudentNumber()));
        	studentEl.addContent(new Element("studentname").setText(student.getStudentName()));
        	studentEl.addContent(new Element("major").setText(student.getMajor()));
        	studentEl.addContent(new Element("grade").setText(student.getGrade()));
        	studentEl.addContent(new Element("classname").setText(student.getClassName()));
        	studentEl.addContent(new Element("gender").setText(student.getGender()));
        	root.addContent(studentEl);
        }
        try {
	        XMLOutputter out = new XMLOutputter();  
            Format f = Format.getPrettyFormat();  
            f.setEncoding("UTF-8");
            out.setFormat(f);  
            out.output(document, new FileOutputStream(outputFile)); 
        } catch (Exception e) {  
            e.printStackTrace();  
        }  
}
 
开发者ID:ousheobin,项目名称:My-Javaweb-Homework,代码行数:26,代码来源:XMLOutputUtil.java

示例2: 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

示例3: printXML

import org.jdom.output.Format; //导入方法依赖的package包/类
public static void printXML(Document doc){
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	XMLOutputter op = new XMLOutputter(format);
	if(doc == null){
		System.err.println("Null document");
	}
	else{
		try {
			op.output(doc, System.out);
		} catch (IOException e) {
			e.printStackTrace();
		}
		System.out.println();
	}
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:17,代码来源:XMLUtilities.java

示例4: 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

示例5: processFullCreoleXmlTree

import org.jdom.output.Format; //导入方法依赖的package包/类
private void processFullCreoleXmlTree(Plugin plugin,
    Document jdomDoc, CreoleAnnotationHandler annotationHandler)
    throws GateException, IOException, JDOMException {
  // now we can process any annotations on the new classes
  // and augment the XML definition
  annotationHandler.processAnnotations(jdomDoc);

  // debugging
  if(DEBUG) {
    XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
    xmlOut.output(jdomDoc, System.out);
  }

  // finally, parse the augmented definition with the normal parser
  DefaultHandler handler =
      new CreoleXmlHandler(this, plugin);
  SAXOutputter outputter =
      new SAXOutputter(handler, handler, handler, handler);
  outputter.output(jdomDoc);
  if(DEBUG) {
    Out.prln("done parsing " + plugin);
  }
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:24,代码来源:CreoleRegisterImpl.java

示例6: write

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Method write
 *
 * @param project
 * @param stream
 * @param document
 * @deprecated
 */
public void write( Model project, Document document, OutputStream stream )
    throws java.io.IOException
{
    updateModel( project, "project", new Counter( 0 ), document.getRootElement() );
    XMLOutputter outputter = new XMLOutputter();
    Format format = Format.getPrettyFormat();
    format.setIndent( "    " ).setLineSeparator( System.getProperty( "line.separator" ) );
    outputter.setFormat( format );
    outputter.output( document, stream );
}
 
开发者ID:javiersigler,项目名称:apache-maven-shade-plugin,代码行数:19,代码来源:MavenJDOMWriter.java

示例7: writeSettingsToFile

import org.jdom.output.Format; //导入方法依赖的package包/类
public void writeSettingsToFile(File f)
{
    Element component = new Element("component");
    component.setAttribute("name", Rearranger.COMPONENT_NAME);
    Element r = new Element(Rearranger.COMPONENT_NAME);
    component.getChildren().add(r);
    writeExternal(r);
    Format format = Format.getPrettyFormat();
    XMLOutputter outputter = new XMLOutputter(format);
    try
    {
        final FileOutputStream fileOutputStream = new FileOutputStream(f);
        outputter.output(component, fileOutputStream);
        fileOutputStream.close();
    }
    catch (IOException e)
    {
        throw new RuntimeException(e);
    }
}
 
开发者ID:DaveKriewall,项目名称:Rearranger,代码行数:21,代码来源:RearrangerSettings.java

示例8: saveXML

import org.jdom.output.Format; //导入方法依赖的package包/类
public void saveXML() throws IOException
{
	if(!gexManager.isConnected()) return;
	
	File finalFile = getFileForDb();
	if (finalFile.exists()) finalFile.delete();
	finalFile.createNewFile();
	
	OutputStream out = new FileOutputStream(finalFile);

	Document xmlDoc = new Document();
	Element root = new Element(ROOT_XML_ELEMENT);
	xmlDoc.setRootElement(root);

	root.addContent(colorSetMgr.getXML());

	Element vis = new Element(XML_ELEMENT);
	for(Visualization v : getVisualizations()) {
		vis.addContent(v.toXML());
	}
	root.addContent(vis);

	XMLOutputter xmlOut = new XMLOutputter(Format.getPrettyFormat());
	xmlOut.output(xmlDoc, out);
	out.close();

	Logger.log.info("Saved visualizations and color sets to xml: " + finalFile);
}
 
开发者ID:PathVisio,项目名称:pathvisio,代码行数:29,代码来源:VisualizationManager.java

示例9: 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

示例10: 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

示例11: getXMLCode

import org.jdom.output.Format; //导入方法依赖的package包/类
public String getXMLCode() throws IOException
{
    Format t_objFormat = Format.getPrettyFormat();
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    StringWriter t_objWriter = new StringWriter();
    t_objExportXML.output(this.m_objDocument, t_objWriter );
    return t_objWriter.toString();
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:9,代码来源:SugarExporterGlycoCT.java

示例12: export

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * @param t_objdb
 * @param string
 * @throws IOException 
 * @throws SQLException 
 */
public void export(DBInterface a_objDB, String a_strFileName) throws IOException, SQLException 
{
    this.m_objDB = a_objDB;
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("fragments");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    this.exportAX(t_objRoot);
    this.exportOthers(t_objRoot);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    FileWriter t_objWriter = new FileWriter(a_strFileName);
    t_objExportXML.output(t_objDocument, t_objWriter );
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:29,代码来源:GeneratorFragment.java

示例13: saveDOM

import org.jdom.output.Format; //导入方法依赖的package包/类
public void saveDOM(org.jdom.Document document, String filename) {
    File file = new java.io.File(filename);
    BufferedWriter out = null;
    try {
        out = new BufferedWriter(new FileWriter(file));
        XMLOutputter xout = new XMLOutputter(Format.getPrettyFormat());
        xout.output(document, out);

    } catch (IOException e) {
        System.out.println("Error in producing file: " + e.getMessage());
    }
}
 
开发者ID:dbunibas,项目名称:spicy,代码行数:13,代码来源:DAOXmlUtility.java

示例14: exportParameter

import org.jdom.output.Format; //导入方法依赖的package包/类
/** 
 * Exports a parameter object to an XML string
 * 
 * @param t_objSetting
 * @return XML-string
 * @throws IOException
 */
public String exportParameter(CalculationParameter t_objSetting) throws IOException
{
    // Erzeugung eines XML-Dokuments
    Document t_objDocument = new Document();
    // Erzeugung des Root-XML-Elements 
    Element t_objRoot = new Element("glycopeakfinder_calculation");
    Namespace xsiNS = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");        
    t_objRoot.addNamespaceDeclaration(xsiNS);
    t_objRoot.setAttribute(new Attribute("noNamespaceSchemaLocation",this.m_strFile, xsiNS));
    // write Settings to element
    this.exportParameter(t_objRoot, t_objSetting);
    // Und jetzt haengen wir noch das Root-Element an das Dokument
    t_objDocument.setRootElement(t_objRoot);
    // Damit das XML-Dokument schoen formattiert wird holen wir uns ein Format
    Format t_objFormat = Format.getPrettyFormat();
    t_objFormat.setEncoding("iso-8859-1");
    // Erzeugung eines XMLOutputters dem wir gleich unser Format mitgeben
    XMLOutputter t_objExportXML = new XMLOutputter(t_objFormat);
    // Schreiben der XML-Datei in einen String
    StringWriter t_objWriter = new StringWriter();
    t_objExportXML.output(t_objDocument, t_objWriter );
    return t_objWriter.toString();
}
 
开发者ID:glycoinfo,项目名称:eurocarbdb,代码行数:31,代码来源:CalcParameterXml.java

示例15: serializeAddROSpec

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * ORANGE: This method serializes a ADD_ROSPEC to an xml and writes it into a file.
 * @param addRoSpec containing the ADD_ROSPEC to be written into a file
 * @param pathName the file where to store
 * @throws IOException whenever an io problem occurs
 */
public static void serializeAddROSpec(ADD_ROSPEC addRoSpec, String pathName) throws IOException {
	try {
		Document document = addRoSpec.encodeXML();
		XMLOutputter outputter = new XMLOutputter(Format.getPrettyFormat());
		outputter.output(document, new FileOutputStream(pathName));
	} catch (InvalidLLRPMessageException e) {
		log.error("could not serialize AddROSpec:", e);
	}
}
 
开发者ID:Auto-ID-Lab-Japan,项目名称:fosstrak-fc,代码行数:16,代码来源:SerializerUtil.java


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