当前位置: 首页>>代码示例>>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;未经允许,请勿转载。