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


Java Format.setIndent方法代码示例

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


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

示例1: printXML

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

示例2: writeToFile

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Save a xml document in a file
 * @param fname the name of the file to be created
 * @param doc the xml document
 */
public static void writeToFile(String fname, Document doc){
	try{
		FileOutputStream out = new FileOutputStream(fname);
		
		Format format = Format.getPrettyFormat();
		format.setIndent("	");
		format.setEncoding("ISO-8859-1");
		XMLOutputter op = new XMLOutputter(format);
		op.output(doc,out);
		out.flush();
		out.close();
	}
	catch (IOException e){
		System.err.println(e);
	}
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:22,代码来源:XMLUtilities.java

示例3: createXML

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Write an XML file containing the interpretation of an expression
 * @param e		: expression which interpretation is to be saved
 * @param file	: path to the file to be created
 */
public static void createXML(Expression e, String file)
{
	// Create the main node (root) of the XML
	Element el = new Element("expression");
	el.setAttribute(new Attribute("width", e.getDimension().width+""));		// Save the width ...
	el.setAttribute(new Attribute("height", e.getDimension().height+""));	// ... and the height.
	el.addContent(createSymbolNode(e.findLeftMost()));						// Add the expression interpretation
	
	// Create the document
	Document doc = new Document(el);
	try {
		// Write the file
	    XMLOutputter outputter = new XMLOutputter();
	    Format f = outputter.getFormat();		// Set the format
	    f.setIndent("     "); 					//	- indent
	    f.setLineSeparator("\r\n"); 			//  - new lines
	    outputter.setFormat(f);
	    outputter.output(doc, new FileWriter(new File(FileManager.get().getWorkspace()+file)));
	} catch (IOException e1) {
	    e1.printStackTrace();
	}
}
 
开发者ID:tbluche,项目名称:MERStructure,代码行数:28,代码来源:XMLCreator.java

示例4: listOfSymbolXML

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Write an XML file containing a list of symbols
 * @param vc	: list of symbols
 * @param file	: path to the file
 */
public static void listOfSymbolXML(Vector<Context> vc, String file)
{
	// XML node with the list of symbols
	Element e = listOfSymbols(vc);
	
	// Creation of the XML document
	Document doc = new Document(e);
	
	// Write the file
	try {
	    XMLOutputter outputter = new XMLOutputter();
	    Format f = outputter.getFormat();
	    f.setIndent("     "); 
	    f.setLineSeparator("\r\n"); 
	    outputter.setFormat(f);
	    outputter.output(doc, new FileWriter(new File(FileManager.get().getWorkspace()+file)));
	} catch (IOException e1) {
	    e1.printStackTrace();
	}
}
 
开发者ID:tbluche,项目名称:MERStructure,代码行数:26,代码来源:XMLCreator.java

示例5: listsOfSymbolXML

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Create an XML file containing the list of symbols for several expressions.
 * @param ve	: list of expressions	
 * @param file	: file to save
 */
public static void listsOfSymbolXML(Vector<Expression> ve, String file) {
	Element root = new Element("expressions");
	
	for (Expression e: ve)
		root.addContent(listOfSymbols(e.getSymbols()));
	
	Document doc = new Document(root);
	try {
	    XMLOutputter outputter = new XMLOutputter();
	    Format f = outputter.getFormat();
	    f.setIndent("  "); // use two space indent
	    f.setLineSeparator("\r\n"); 
	    outputter.setFormat(f);
	    outputter.output(doc, new FileWriter(new File(FileManager.get().getWorkspace()+file)));
	} catch (IOException e1) {
	    e1.printStackTrace();
	}
	
}
 
开发者ID:tbluche,项目名称:MERStructure,代码行数:25,代码来源:XMLCreator.java

示例6: NewPluginWizard

import org.jdom.output.Format; //导入方法依赖的package包/类
public NewPluginWizard()
{
	fFirstPage = new NewJPFPluginWizardPageOne();
	fSecondPage = new NewJavaProjectWizardPageTwo(fFirstPage);
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	format.setOmitEncoding(true);
	format.setOmitDeclaration(true);
	format.setLineSeparator("\n");
	format.setEncoding("UTF-8");
	xmlOut = new XMLOutputter(format);
}
 
开发者ID:equella,项目名称:Equella,代码行数:13,代码来源:NewPluginWizard.java

示例7: createPrettyFormat

import org.jdom.output.Format; //导入方法依赖的package包/类
private Format createPrettyFormat() {
    final Format prettyFormat = Format.getPrettyFormat();
    prettyFormat.setExpandEmptyElements(expandEmptyElements);
    prettyFormat.setEncoding(encoding);
    prettyFormat.setLineSeparator("\n");
    prettyFormat.setIndent(indentCharacters);
    return prettyFormat;
}
 
开发者ID:Ekryd,项目名称:sortpom,代码行数:9,代码来源:XmlOutputGenerator.java

示例8: makeFileFromRoot

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Records an XML file containing the data described
 * in the specified element. That element is considered
 * as the root of the new document.
 *  
 * @param dataFile
 * 		XML file to be created.
 * @param schemaFile
 * 		Associated schema file.
 * @param root
 * 		Root element of the XML file.
 * 
 * @throws IOException
 * 		Problem while creating the XML file.
 */
public static void makeFileFromRoot(File dataFile, File schemaFile, Element root) throws IOException
{	// open file stream
	FileOutputStream out = new FileOutputStream(dataFile);
	BufferedOutputStream outBuf = new BufferedOutputStream(out);
	// create document
	Document document = new Document(root);
	// schema
	String schemaPath = schemaFile.getPath();
	File racine = new File(FilePaths.getResourcesPath());
	File tempFile = new File(dataFile.getPath());
	while(!tempFile.equals(racine))
	{	tempFile = tempFile.getParentFile();
		schemaPath = ".."+File.separator+schemaPath;
	}
	// Namespace sch = Namespace.getNamespace("xsi","http://www.w3.org/2001/XMLSchema-instance");
    Namespace sch = Namespace.getNamespace("xsi",XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
	root.addNamespaceDeclaration(sch);
	root.setAttribute("noNamespaceSchemaLocation",schemaPath,sch);
	// define output format
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	// create outputter
	XMLOutputter outputter = new XMLOutputter(format);
	// write in the stream
    outputter.output(document,outBuf);       
    // close the stream
    outBuf.close();
}
 
开发者ID:vlabatut,项目名称:totalboumboum,代码行数:44,代码来源:XmlTools.java

示例9: getFormat

import org.jdom.output.Format; //导入方法依赖的package包/类
public static Format getFormat(String indent, boolean newlines) {
    Format format = Format.getPrettyFormat();
    format.setIndent(indent);
    if (newlines) {
        format.setLineSeparator("\n"); //$NON-NLS-1$
    } else {
        format.setLineSeparator(""); //$NON-NLS-1$
    }
    return format;
}
 
开发者ID:kenweezy,项目名称:teiid,代码行数:11,代码来源:JdomHelper.java

示例10: toString

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
    * This method returns an Element as a string
    * @param element
    * @return
    */
public static String toString(Element element){
       String content = "";
	Format format = Format.getPrettyFormat();
	format.setIndent("\t");
	XMLOutputter op = new XMLOutputter(format);
	if(element == null){
		System.err.println("Null element");
	}
	else{
		content = op.outputString(element);
	}
       return content;
}
 
开发者ID:tvaquero,项目名称:itsimple,代码行数:19,代码来源:XMLUtilities.java

示例11: writeXML

import org.jdom.output.Format; //导入方法依赖的package包/类
/**
 * Serializes the database to the output stream.
 *
 * @param outputStream the output
 * @param encoding the encoding to use
 * @param indent the indent
 * @param lineSeparator the lineSeparator
 * @throws IOException in case the xml could not be written
 */
public void writeXML(OutputStream outputStream, String encoding, String indent, String lineSeparator)
throws IOException {
  XMLOutputter outputter = new XMLOutputter();
  Format format = Format.getPrettyFormat();
  format.setEncoding(encoding);
  format.setIndent(indent);
  format.setLineSeparator(lineSeparator);
  outputter.setFormat(format);
  outputter.output(getDocument(), outputStream);
}
 
开发者ID:netceteragroup,项目名称:trema-core,代码行数:20,代码来源:XMLDatabase.java


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