當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。