当前位置: 首页>>代码示例>>Java>>正文


Java Format.getCompactFormat方法代码示例

本文整理汇总了Java中org.jdom2.output.Format.getCompactFormat方法的典型用法代码示例。如果您正苦于以下问题:Java Format.getCompactFormat方法的具体用法?Java Format.getCompactFormat怎么用?Java Format.getCompactFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom2.output.Format的用法示例。


在下文中一共展示了Format.getCompactFormat方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createXml

import org.jdom2.output.Format; //导入方法依赖的package包/类
private void createXml(ISendMessageCallback callback) {

        Document generatedXml = new Document();
        Stack<DocElement> parentStack = new Stack<DocElement>();
        ArrayList<String> outboundPayload = new ArrayList<String>();

        for (Message msg : messagesToProcess) {
            processMsgEntities(parentStack, msg, generatedXml);
        }
        XMLOutputter xmlOutputter = new XMLOutputter();
        Format format = null;
        if (xmlFormat.equals(COMPACT_FORMAT)) {
            format = Format.getCompactFormat();
        } else if (xmlFormat.equals(RAW_FORMAT)) {
            format = Format.getRawFormat();
        } else {
            format = Format.getPrettyFormat();
        }
        xmlOutputter.setFormat(format);
        outboundPayload.add(xmlOutputter.outputString(generatedXml));
        callback.sendTextMessage(null, outboundPayload);
    }
 
开发者ID:JumpMind,项目名称:metl,代码行数:23,代码来源:XmlFormatter.java

示例2: canonicalElement

import org.jdom2.output.Format; //导入方法依赖的package包/类
private static Element canonicalElement(Parent e) throws IOException, SAXParseException {
    XMLOutputter xout = new XMLOutputter(Format.getCompactFormat());
    MCRByteArrayOutputStream bout = new MCRByteArrayOutputStream();
    if (e instanceof Element) {
        xout.output((Element) e, bout);
    } else {
        xout.output((Document) e, bout);
    }
    Document xml = MCRXMLParserFactory.getNonValidatingParser()
        .parseXML(new MCRByteContent(bout.getBuffer(), 0, bout.size()));
    return xml.getRootElement();
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:13,代码来源:MCRXMLHelper.java

示例3: documentToStringDump

import org.jdom2.output.Format; //导入方法依赖的package包/类
/****************************************************************************/

    public static String documentToStringDump(Document doc) {
        if (doc == null) return null;
        XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
        return out.outputString(doc);
    }
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:8,代码来源:JDOMUtil.java

示例4: elementToStringDump

import org.jdom2.output.Format; //导入方法依赖的package包/类
/****************************************************************************/

    public static String elementToStringDump(Element e) {
        if (e == null) return null ;
        XMLOutputter out = new XMLOutputter(Format.getCompactFormat());
        return out.outputString(e);
    }
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:8,代码来源:JDOMUtil.java

示例5: getTransformedXml

import org.jdom2.output.Format; //导入方法依赖的package包/类
public static String getTransformedXml(String inputXml, String stylesheetXml, String xmlFormat, boolean omitXmlDeclaration) {
    StringWriter writer = new StringWriter();
    SAXBuilder builder = new SAXBuilder();
    builder.setXMLReaderFactory(XMLReaders.NONVALIDATING);
    builder.setFeature("http://xml.org/sax/features/validation", false);
    try {
        Document inputDoc = builder.build(new StringReader(inputXml));
        StringReader reader = new StringReader(stylesheetXml);
        XSLTransformer transformer = new XSLTransformer(reader);
        Document outputDoc = transformer.transform(inputDoc);
        XMLOutputter xmlOutput = new XMLOutputter();
        Format format = null;
        if (xmlFormat.equals(COMPACT_FORMAT)) {
            format = Format.getCompactFormat();
        } else if (xmlFormat.equals(RAW_FORMAT)) {
            format = Format.getRawFormat();
        } else {
            format = Format.getPrettyFormat();
        }
        
        format.setOmitDeclaration(omitXmlDeclaration);
        xmlOutput.setFormat(format);
        xmlOutput.output(outputDoc, writer);
        writer.close();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
    return writer.toString();
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:30,代码来源:XsltProcessor.java

示例6: getFormat

import org.jdom2.output.Format; //导入方法依赖的package包/类
private Format getFormat(final boolean prettyPrint, final boolean showXmlDeclaration) {
    final Format format = prettyPrint ? Format.getPrettyFormat().setIndent(INDENT) : Format.getCompactFormat();
    return format.setOmitDeclaration(!showXmlDeclaration)
            .setEncoding(UTF_8_ENCODING)
            .setLineSeparator(NEW_LINE);
}
 
开发者ID:CloudSlang,项目名称:cs-actions,代码行数:7,代码来源:ConvertJsonToXmlService.java

示例7: outputString

import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
 * Creates a String with the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is
 * the responsibility of the developer to ensure that if the String is written to a character
 * stream the stream charset is the same as the feed encoding property.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 *
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must
 *            match the type given to the FeedOuptut constructor.
 * @param prettyPrint pretty-print XML (true) oder collapsed
 * @return a String with the XML representation for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
 *             don't match.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public String outputString(final WireFeed feed, final boolean prettyPrint) throws IllegalArgumentException, FeedException {
    final Document doc = outputJDom(feed);
    final String encoding = feed.getEncoding();
    Format format;
    if (prettyPrint) {
        format = Format.getPrettyFormat();
    } else {
        format = Format.getCompactFormat();
    }
    if (encoding != null) {
        format.setEncoding(encoding);
    }
    final XMLOutputter outputter = new XMLOutputter(format);
    return outputter.outputString(doc);
}
 
开发者ID:rometools,项目名称:rome,代码行数:35,代码来源:WireFeedOutput.java

示例8: output

import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
 * Writes to an Writer the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is
 * the responsibility of the developer to ensure the Writer instance is using the same charset
 * encoding.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 *
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must
 *            match the type given to the FeedOuptut constructor.
 * @param writer Writer to write the XML representation for the given WireFeed.
 * @param prettyPrint pretty-print XML (true) oder collapsed
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed
 *             don't match.
 * @throws IOException thrown if there was some problem writing to the Writer.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public void output(final WireFeed feed, final Writer writer, final boolean prettyPrint) throws IllegalArgumentException, IOException, FeedException {
    final Document doc = outputJDom(feed);
    final String encoding = feed.getEncoding();
    Format format;
    if (prettyPrint) {
        format = Format.getPrettyFormat();
    } else {
        format = Format.getCompactFormat();
    }
    if (encoding != null) {
        format.setEncoding(encoding);
    }
    final XMLOutputter outputter = new XMLOutputter(format);
    outputter.output(doc, writer);
}
 
开发者ID:rometools,项目名称:rome,代码行数:36,代码来源:WireFeedOutput.java

示例9: outputString

import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
 * Creates a String with the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
 * of the developer to ensure that if the String is written to a character stream the stream charset is the same as
 * the feed encoding property.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @param prettyPrint pretty-print XML (true) oder collapsed
 * @return a String with the XML representation for the given WireFeed.
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public String outputString(WireFeed feed, boolean prettyPrint) throws IllegalArgumentException,FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
    if (encoding!=null) {
        format.setEncoding(encoding);
    }
    XMLOutputter outputter = new XMLOutputter(format);
    return outputter.outputString(doc);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:28,代码来源:WireFeedOutput.java

示例10: output

import org.jdom2.output.Format; //导入方法依赖的package包/类
/**
 * Writes to an Writer the XML representation for the given WireFeed.
 * <p>
 * If the feed encoding is not NULL, it will be used in the XML prolog encoding attribute. It is the responsibility
 * of the developer to ensure the Writer instance is using the same charset encoding.
 * <p>
 * NOTE: This method delages to the 'Document WireFeedOutput#outputJDom(WireFeed)'.
 * <p>
 * @param feed Abstract feed to create XML representation from. The type of the WireFeed must match
 *        the type given to the FeedOuptut constructor.
 * @param writer Writer to write the XML representation for the given WireFeed.
 * @param prettyPrint pretty-print XML (true) oder collapsed
 * @throws IllegalArgumentException thrown if the feed type of the WireFeedOutput and WireFeed don't match.
 * @throws IOException thrown if there was some problem writing to the Writer.
 * @throws FeedException thrown if the XML representation for the feed could not be created.
 *
 */
public void output(WireFeed feed,Writer writer,boolean prettyPrint) throws IllegalArgumentException,IOException, FeedException {
    Document doc = outputJDom(feed);
    String encoding = feed.getEncoding();
    Format format = prettyPrint ? Format.getPrettyFormat() : Format.getCompactFormat();
    if (encoding!=null) {
        format.setEncoding(encoding);
    }
    XMLOutputter outputter = new XMLOutputter(format);
    outputter.output(doc,writer);
}
 
开发者ID:apache,项目名称:marmotta,代码行数:28,代码来源:WireFeedOutput.java


注:本文中的org.jdom2.output.Format.getCompactFormat方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。