本文整理汇总了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();
}
}
示例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);
}
}
示例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();
}
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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;
}
示例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();
}
示例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;
}
示例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;
}
示例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);
}