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


Java OutputFormat.createCompactFormat方法代碼示例

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


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

示例1: convertToXML

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * convert definition to hibernate xml
 * 
 * @param descriptor
 * @return
 * @throws IOException
 */
protected String convertToXML(IStandalonePersistentBeanDescriptor descriptor) {
	Document doc = createDocument(descriptor);

	StringWriter sw = new StringWriter();
	XMLWriter writer = new XMLWriter(sw, OutputFormat.createCompactFormat());
	try {
		writer.write(doc);
	} catch (IOException e) {
		if (getLogger().isErrorEnabled()) {
			getLogger().error("Failed to cast xml document to string.", e);
		}
		throw new ResourceException("Failed to cast xml document to string.", e);
	}
	if (getLogger().isDebugEnabled()) {
		getLogger()
				.debug("Class [" + descriptor.getResourceClass().getName()
						+ "] has been configured into hibernate. XML as [" + sw.toString().replace("\n", "") + "].");
	}
	return sw.toString();
}
 
開發者ID:bradwoo8621,項目名稱:nest-old,代碼行數:28,代碼來源:HibernatePersistentConfigurationInitializer.java

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

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

示例4: nullSafeSet

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
    if (value == null) {
        ps.setNull(index, sqlTypes()[0]);
    } else {
        try {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            XMLWriter writer = new XMLWriter(bytes,OutputFormat.createCompactFormat());
            writer.write((Document)value);
            writer.flush(); writer.close();
            ps.setCharacterStream(index, new CharArrayReader(bytes.toString().toCharArray(),0,bytes.size()), bytes.size());
        } catch (IOException e) {
            throw new HibernateException(e.getMessage(),e);
        }
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:16,代碼來源:XmlClobType.java

示例5: nullSafeSet

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public void nullSafeSet(PreparedStatement ps, Object value, int index, SessionImplementor session) throws SQLException, HibernateException {
    if (value == null) {
        ps.setNull(index, sqlTypes()[0]);
    } else {
        try {
            ByteArrayOutputStream bytes = new ByteArrayOutputStream();
            XMLWriter writer = new XMLWriter(new GZIPOutputStream(bytes),OutputFormat.createCompactFormat());
            writer.write((Document)value);
            writer.flush(); writer.close();
            ps.setBinaryStream(index, new ByteArrayInputStream(bytes.toByteArray(),0,bytes.size()), bytes.size());
        } catch (IOException e) {
            throw new HibernateException(e.getMessage(),e);
        }
    }
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:16,代碼來源:XmlBlobType.java

示例6: setStudentsDocument

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public void setStudentsDocument(Document document) {
	try {
		if (document == null) {
			setStudents(null);
		} else {
			StringWriter string = new StringWriter();
			XMLWriter writer = new XMLWriter(string, OutputFormat.createCompactFormat());
			writer.write(document);
			writer.flush(); writer.close();
			setStudents(string.toString());
		}
	} catch (Exception e) {
		sLog.warn("Failed to store cached students for " + getCurriculum().getAbbv() + " " + getName() + ": " + e.getMessage(), e);
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:16,代碼來源:CurriculumClassification.java

示例7: setValue

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public void setValue(Document document) {
	try {
		if (document == null) {
			setData(null);
		} else {
			 ByteArrayOutputStream bytes = new ByteArrayOutputStream();
             XMLWriter writer = new XMLWriter(new GZIPOutputStream(bytes),OutputFormat.createCompactFormat());
             writer.write(document);
             writer.flush(); writer.close();
             setData(bytes.toByteArray());
		}
	} catch (IOException e) {
		throw new HibernateException(e.getMessage(),e);
	}
}
 
開發者ID:Jenner4S,項目名稱:unitimes,代碼行數:16,代碼來源:SolverInfo.java

示例8: getXMLOutputFormat

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
@Override
protected OutputFormat getXMLOutputFormat()
{
    String userAgent = m_request.getHeader("User-Agent");
    return ((null != userAgent) && userAgent.toLowerCase().startsWith("microsoft-webdav-miniredir/5.1.")) ? OutputFormat.createCompactFormat() : super.getXMLOutputFormat();

}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:8,代碼來源:PropFindMethod.java

示例9: save

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
@Override
protected void save(File outFolder, IDomain domain) throws Exception {
	String fileName = this.getSaveFilePath(outFolder.getPath(), domain);
	Document document = DocumentHelper.createDocument();
	// 領域模型
	Element domainElement = document.addElement("Domain");
	this.writeElement(domain, domainElement);
	// 模型
	for (IModel model : domain.getModels()) {
		Element modelElement = domainElement.addElement("Model");
		this.writeElement(model, modelElement);
		// 模型屬性
		for (IProperty property : model.getProperties()) {
			Element propertyElement = modelElement.addElement("Property");
			this.writeElement(property, propertyElement);
		}
	}
	// 業務對象
	for (IBusinessObject businessObject : domain.getBusinessObjects()) {
		Element boElement = domainElement.addElement("BusinessObject");
		this.writeElement(businessObject, boElement);
		for (IBusinessObjectItem boItem : businessObject.getRelatedBOs()) {
			Element biElement = boElement.addElement("RelatedBO");
			this.writeElement(boItem, biElement);
		}
	}
	OutputFormat xmlFormat = OutputFormat.createCompactFormat();
	xmlFormat.setEncoding(XML_FILE_ENCODING);
	xmlFormat.setNewlines(true);
	xmlFormat.setIndent(true);
	xmlFormat.setIndent("  ");
	XMLWriter writer = new XMLWriter(new FileWriter(fileName), xmlFormat);
	writer.write(document);
	writer.close();
}
 
開發者ID:color-coding,項目名稱:btulz.transforms,代碼行數:36,代碼來源:XmlTransformerDom4j.java

示例10: setUp

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
protected void setUp() throws Exception {
    super.setUp();

    Dom4JDriver driver = new Dom4JDriver();

    OutputFormat format = OutputFormat.createCompactFormat();
    format.setTrimText(false);
    format.setSuppressDeclaration(true);
    driver.setOutputFormat(format);

    out = new StringWriter();
    writer = driver.createWriter(out);
}
 
開發者ID:x-stream,項目名稱:xstream,代碼行數:14,代碼來源:Dom4JXmlWriterTest.java

示例11: test

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
@Test
public void test() throws IOException {
	Document doc = DocumentHelper.createDocument();
	doc.addDocType("hibernate-mapping", "-//Hibernate/Hibernate Mapping DTD 3.0//EN",
			"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd");

	StringWriter sw = new StringWriter();
	XMLWriter writer = new XMLWriter(sw, OutputFormat.createCompactFormat());
	writer.write(doc);
	System.out.println(sw.toString());
}
 
開發者ID:bradwoo8621,項目名稱:nest-old,代碼行數:12,代碼來源:TestDom4j.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: getSnipAsXml

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
public String getSnipAsXml(String name) {
  Snip snip = space.load(name);
  ByteArrayOutputStream out = new ByteArrayOutputStream();
  OutputFormat outputFormat = OutputFormat.createCompactFormat();
  outputFormat.setEncoding("UTF-8");
  try {
    XMLWriter writer = new XMLWriter(out, outputFormat);
    writer.write(SnipSerializer.getInstance().serialize(snip));
    writer.flush();
  } catch (IOException e) {
    e.printStackTrace();
  }
  return out.toString();
}
 
開發者ID:thinkberg,項目名稱:snipsnap,代碼行數:15,代碼來源:SnipSnapHandler.java

示例14: getXMLOutputFormat

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
/**
 * Returns the format required for an XML response. This may vary per method.
 */
protected OutputFormat getXMLOutputFormat()
{
    // Check if debug output or XML pretty printing is enabled
    return (XMLPrettyPrint || logger.isDebugEnabled()) ? OutputFormat.createPrettyPrint() : OutputFormat.createCompactFormat();
}
 
開發者ID:Alfresco,項目名稱:alfresco-remote-api,代碼行數:9,代碼來源:WebDAVMethod.java

示例15: createTrimedOutputFormat

import org.dom4j.io.OutputFormat; //導入方法依賴的package包/類
private static OutputFormat createTrimedOutputFormat(final String encoding) {
  final OutputFormat format = OutputFormat.createCompactFormat();
  format.setEncoding(encoding);
  return format;
}
 
開發者ID:AndreasWBartels,項目名稱:libraries,代碼行數:6,代碼來源:DocumentUtilities.java


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