當前位置: 首頁>>代碼示例>>Java>>正文


Java OutputFormat.setIndentSize方法代碼示例

本文整理匯總了Java中org.dom4j.io.OutputFormat.setIndentSize方法的典型用法代碼示例。如果您正苦於以下問題:Java OutputFormat.setIndentSize方法的具體用法?Java OutputFormat.setIndentSize怎麽用?Java OutputFormat.setIndentSize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.dom4j.io.OutputFormat的用法示例。


在下文中一共展示了OutputFormat.setIndentSize方法的13個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getWriter

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * Get the writer for the import file
 * 
 * @param destination	the destination XML import file
 * @return				the XML writer
 */
private XMLWriter getWriter(String destination)
{
	try
	{
		 // Define output format
        OutputFormat format = OutputFormat.createPrettyPrint();
        format.setNewLineAfterDeclaration(false);
        format.setIndentSize(INDENT_SIZE);
        format.setEncoding(this.fileEncoding);

        return new XMLWriter(new FileOutputStream(destination), format);
	}
       catch (Exception exception)
       {
       	throw new AlfrescoRuntimeException("Unable to create XML writer.", exception);
       }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:24,代碼來源:ImportFileUpdater.java

示例2: startTransferReport

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * Start the transfer report
 */
public void startTransferReport(String encoding, Writer writer)
{
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setNewLineAfterDeclaration(false);
    format.setIndentSize(3);
    format.setEncoding(encoding);
    
    try 
    {
    
    this.writer = new XMLWriter(writer, format);
    this.writer.startDocument();
    
    this.writer.startPrefixMapping(PREFIX, TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI);

    // Start Transfer Manifest  // uri, name, prefix
    this.writer.startElement(TransferDestinationReportModel.TRANSFER_REPORT_MODEL_1_0_URI, TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_REPORT,  PREFIX + ":" + TransferDestinationReportModel.LOCALNAME_TRANSFER_DEST_REPORT, EMPTY_ATTRIBUTES);
    
    } 
    catch (SAXException se)
    {
        se.printStackTrace();
    }
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:28,代碼來源:XMLTransferDestinationReportWriter.java

示例3: startTransferReport

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * Start the transfer report
 */
public void startTransferReport(String encoding, Writer writer) throws SAXException
{
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setNewLineAfterDeclaration(false);
    format.setIndentSize(3);
    format.setEncoding(encoding);
    
    this.writer = new XMLWriter(writer, format);
    this.writer.startDocument();
    
    this.writer.startPrefixMapping(PREFIX, TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI);

    // Start Transfer Manifest  // uri, name, prefix
    this.writer.startElement(TransferReportModel2.TRANSFER_REPORT_MODEL_2_0_URI, TransferReportModel.LOCALNAME_TRANSFER_REPORT,  PREFIX + ":" + TransferReportModel.LOCALNAME_TRANSFER_REPORT, EMPTY_ATTRIBUTES);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:19,代碼來源:XMLTransferReportWriter.java

示例4: formatXml

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * Returns the given xml document as nicely formated string.
 * 
 * @param node
 *            The xml document.
 * @return the formated xml as string.
 */
private static String formatXml(Node node) {
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setIndentSize(4);
    format.setTrimText(true);
    format.setExpandEmptyElements(true);
    
    StringWriter stringWriter = new StringWriter();
    XMLWriter xmlWriter = new XMLWriter(stringWriter, format);
    try {
        xmlWriter.write(node);
        xmlWriter.flush();
    } catch (IOException e) {
        // this should never happen
        throw new RuntimeException(e);
    }

    return stringWriter.getBuffer().toString();
}
 
開發者ID:kkrugler,項目名稱:yalder,代碼行數:26,代碼來源:WikipediaCrawlTool.java

示例5: write

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
protected void write(String resource, Document document) throws IOException, DocumentException {
	File file = null;
	if (iSource == null) {
		file = new File(getClass().getClassLoader().getResource(resource).getFile());
	} else {
		file = new File(iSource + File.separator + resource);
	}
	info("  -- writing " + file + " ...");
	FileOutputStream fos = new FileOutputStream(file);
	try {
		OutputFormat format = OutputFormat.createPrettyPrint();
		format.setIndentSize(4);
		format.setPadText(false);
		new MyXMLWriter(fos, format).write(document);
	} finally {
		fos.flush(); fos.close();
	}
}
 
開發者ID:UniTime,項目名稱:unitime,代碼行數:19,代碼來源:LowercaseTableNames.java

示例6: XMLTransferRequsiteWriter

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public XMLTransferRequsiteWriter(Writer out)
{
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setNewLineAfterDeclaration(false);
    format.setIndentSize(3);
    format.setEncoding("UTF-8");

    this.writer = new XMLWriter(out, format);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:10,代碼來源:XMLTransferRequsiteWriter.java

示例7: XMLWriter

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public XMLWriter(OutputStream outputStream, boolean prettyPrint, String encoding)
        throws UnsupportedEncodingException
{
    OutputFormat format = prettyPrint ? OutputFormat.createPrettyPrint() : OutputFormat.createCompactFormat();
    format.setNewLineAfterDeclaration(false);
    format.setIndentSize(3);
    format.setEncoding(encoding);
    output = outputStream;
    this.dom4jWriter = new org.dom4j.io.XMLWriter(outputStream, format);
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:11,代碼來源:XMLWriter.java

示例8: createXMLExporter

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
private XMLWriter createXMLExporter(Writer writer)
{
    // Define output format
    OutputFormat format = OutputFormat.createPrettyPrint();
    format.setNewLineAfterDeclaration(false);
    format.setIndentSize(3);
    format.setEncoding("UTF-8");

    // Construct an XML Exporter

    XMLWriter xmlWriter = new XMLWriter(writer, format);
    return xmlWriter;
}
 
開發者ID:Alfresco,項目名稱:alfresco-repository,代碼行數:14,代碼來源:ExportSourceImporter.java

示例9: xmlToString

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
private String xmlToString(Document xml) throws IOException {
    String lineSeparator = System.getProperty("line.separator");
    OutputFormat format = OutputFormat.createCompactFormat();
    format.setIndentSize(4);
    format.setNewlines(true);
    format.setLineSeparator(lineSeparator);
    format.setSuppressDeclaration(true);
    StringWriter result = new StringWriter();
    XMLWriter writer = new XMLWriter(result, format);
    writer.write(xml);
    return result.toString().replaceFirst(lineSeparator, "");
}
 
開發者ID:SimY4,項目名稱:xpath-to-xml,代碼行數:13,代碼來源:XmlBuilderTest.java

示例10: prettyXML

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * Pretty-Print XML.
 * 
 * @param xml The XML
 * @return A beautiful XML
 * @throws IOException
 * @throws DocumentException
 */
public static String prettyXML(final String xml) throws IOException, DocumentException {
  Document doc = DocumentHelper.parseText(xml);
  StringWriter sw = new StringWriter();
  OutputFormat format = OutputFormat.createPrettyPrint();
  format.setIndent(true);
  format.setIndentSize(3);
  XMLWriter xw = new XMLWriter(sw, format);
  xw.write(doc);
  return sw.toString();
}
 
開發者ID:mobileboxlab,項目名稱:appium-java-repl,代碼行數:19,代碼來源:Utils.java

示例11: toXml

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public static void toXml(Writer out, Document doc) throws Exception {
	OutputFormat outformat = OutputFormat.createPrettyPrint();
	outformat.setIndentSize(1);
	outformat.setIndent("\t");
	outformat.setEncoding(UTF_8.name());
	XMLWriter writer = new XMLWriter(out, outformat);
	writer.write(doc);
	writer.flush();
	out.flush();
	out.close();
}
 
開發者ID:apache,項目名稱:openmeetings,代碼行數:12,代碼來源:XmlExport.java

示例12: dumpConst

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * 轉儲常量數據
 * @return 常量數據,不支持的時候返回空
 */
public final byte[] dumpConst(HashMap<String, Object> data) {
    // pretty print
    OutputFormat of = null;
    if (ProgramOptions.getInstance().prettyIndent <= 0) {
        of= OutputFormat.createCompactFormat();
    } else {
        of = OutputFormat.createPrettyPrint();
        of.setIndentSize(ProgramOptions.getInstance().prettyIndent);
    }

    // build xml tree
    Document doc = DocumentHelper.createDocument();
    String encoding = SchemeConf.getInstance().getKey().getEncoding();
    if (null != encoding && false == encoding.isEmpty()) {
        doc.setXMLEncoding(encoding);
        of.setEncoding(encoding);
    }

    doc.setRootElement(DocumentHelper.createElement(ProgramOptions.getInstance().xmlRootName));
    doc.getRootElement().addComment("this file is generated by xresloader, please don't edit it.");

    writeData(doc.getRootElement(), data, "");

    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLWriter writer = new XMLWriter(bos, of);
        writer.write(doc);

        return bos.toByteArray();
    } catch(Exception e) {
        ProgramOptions.getLoger().error("write xml failed, %s", e.getMessage());
        return null;
    }
}
 
開發者ID:xresloader,項目名稱:xresloader,代碼行數:39,代碼來源:DataDstXml.java

示例13: build

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
@Override
public final byte[] build(DataDstImpl compiler) throws ConvException {
    // pretty print
    OutputFormat of = null;
    if (ProgramOptions.getInstance().prettyIndent <= 0) {
        of = OutputFormat.createCompactFormat();
    } else {
        of = OutputFormat.createPrettyPrint();
        of.setIndentSize(ProgramOptions.getInstance().prettyIndent);
    }

    // build data
    DataDstObject data_obj = build_data(compiler);

    // build xml tree
    Document doc = DocumentHelper.createDocument();
    String encoding = SchemeConf.getInstance().getKey().getEncoding();
    if (null != encoding && false == encoding.isEmpty()) {
        doc.setXMLEncoding(encoding);
        of.setEncoding(encoding);
    }

    doc.setRootElement(DocumentHelper.createElement(ProgramOptions.getInstance().xmlRootName));
    doc.getRootElement().addComment("this file is generated by xresloader, please don't edit it.");

    Element header = DocumentHelper.createElement("header");
    Element body = DocumentHelper.createElement("body");

    writeData(header, data_obj.header, header.getName());

    // body
    for(Map.Entry<String, List<Object> > item: data_obj.body.entrySet()) {
        for(Object obj: item.getValue()) {
            Element xml_item = DocumentHelper.createElement(item.getKey());

            writeData(xml_item, obj, item.getKey());

            body.add(xml_item);
        }
    }

    writeData(body, data_obj.body, body.getName());

    doc.getRootElement().add(header);
    doc.getRootElement().add(body);

    try {
        ByteArrayOutputStream bos = new ByteArrayOutputStream();
        XMLWriter writer = new XMLWriter(bos, of);
        writer.write(doc);

        return bos.toByteArray();
    } catch(Exception e) {
        ProgramOptions.getLoger().error("write xml failed, %s", e.getMessage());
        return null;
    }
}
 
開發者ID:xresloader,項目名稱:xresloader,代碼行數:58,代碼來源:DataDstXml.java


注:本文中的org.dom4j.io.OutputFormat.setIndentSize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。