org.jdom2.output.Format.getRawFormat()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(164)

本文整理了Java中org.jdom2.output.Format.getRawFormat()方法的一些代码示例,展示了Format.getRawFormat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format.getRawFormat()方法的具体详情如下:
包路径:org.jdom2.output.Format
类名称:Format
方法名:getRawFormat

Format.getRawFormat介绍

[英]Returns a new Format object that performs no whitespace changes, uses the UTF-8 encoding, doesn't expand empty elements, includes the declaration and encoding, and uses the default entity escape strategy. Tweaks can be made to the returned Format instance without affecting other instances.
[中]返回一个新的Format对象,该对象不执行空格更改,使用UTF-8编码,不展开空元素,包括声明和编码,并使用默认的实体转义策略。可以对返回的格式实例进行调整,而不会影响其他实例。

代码示例

代码示例来源:origin: org.jdom/jdom

  1. /**
  2. * Set the current {@link Format} to be used for output.
  3. *
  4. * @param format
  5. * the new Format
  6. */
  7. public void setFormat(Format format) {
  8. this.format = format == null ? Format.getRawFormat() : format;
  9. }

代码示例来源:origin: org.jdom/jdom

  1. /**
  2. * Set a new Format instance for this DOMOutputter
  3. *
  4. * @param format
  5. * the new Format instance to use (null implies the default)
  6. * @since JDOM2
  7. */
  8. public void setFormat(Format format) {
  9. this.format = format == null ? Format.getRawFormat() : format;
  10. }

代码示例来源:origin: org.jdom/jdom

  1. /**
  2. * The complete constructor for specifying a custom DOMAdaptor, Format, and
  3. * DOMOutputProcessor.
  4. *
  5. * @param adapter
  6. * The adapter to use to create the base Document instance (null
  7. * implies the default).
  8. * @param format
  9. * The output Format to use (null implies the default).
  10. * @param processor
  11. * The custom mechanism for doing the output (null implies the
  12. * default).
  13. * @since JDOM2
  14. */
  15. public DOMOutputter(DOMAdapter adapter, Format format,
  16. DOMOutputProcessor processor) {
  17. this.adapter = adapter == null ? DEFAULT_ADAPTER : adapter;
  18. this.format = format == null ? Format.getRawFormat() : format;
  19. this.processor = processor == null ? DEFAULT_PROCESSOR : processor;
  20. }

代码示例来源:origin: org.jdom/jdom

  1. LexicalHandler lexicalHandler) {
  2. this.processor = processor == null ? DEFAULT_PROCESSOR : processor;
  3. this.format = format == null ? Format.getRawFormat() : format;
  4. this.contentHandler = contentHandler;
  5. this.errorHandler = errorHandler;

代码示例来源:origin: org.jdom/jdom

  1. /**
  2. * This will create an <code>XMLOutputter</code> with the specified format
  3. * characteristics.
  4. * <p>
  5. * <b>Note:</b> the format object is cloned internally before use. If you
  6. * want to modify the Format after constructing the XMLOutputter you can
  7. * modify the Format instance {@link #getFormat()} returns.
  8. *
  9. * @param format
  10. * The Format instance to use. This instance will be cloned() and as
  11. * a consequence, changes made to the specified format instance
  12. * <b>will not</b> be reflected in this XMLOutputter. A null input
  13. * format indicates that XMLOutputter should use the default
  14. * {@link Format#getRawFormat()}
  15. * @param processor
  16. * The XMLOutputProcessor to delegate output to. If null the
  17. * XMLOutputter will use the default XMLOutputProcessor.
  18. */
  19. public XMLOutputter(Format format, XMLOutputProcessor processor) {
  20. myFormat = format == null ? Format.getRawFormat() : format.clone();
  21. myProcessor = processor == null ? DEFAULTPROCESSOR : processor;
  22. }

代码示例来源:origin: org.jdom/jdom

  1. /**
  2. * This will create an <code>StAXStreamOutputter</code> with the specified format
  3. * characteristics.
  4. * <p>
  5. * <b>Note:</b> the format object is cloned internally before use. If you
  6. * want to modify the Format after constructing the StAXStreamOutputter you can
  7. * modify the Format instance {@link #getFormat()} returns.
  8. *
  9. * @param format
  10. * The Format instance to use. This instance will be cloned() and as
  11. * a consequence, changes made to the specified format instance
  12. * <b>will not</b> be reflected in this StAXStreamOutputter. A null input
  13. * format indicates that StAXStreamOutputter should use the default
  14. * {@link Format#getRawFormat()}
  15. * @param processor
  16. * The XMLOutputProcessor to delegate output to. If null the
  17. * StAXStreamOutputter will use the default XMLOutputProcessor.
  18. */
  19. public StAXStreamOutputter(Format format, StAXStreamProcessor processor) {
  20. myFormat = format == null ? Format.getRawFormat() : format.clone();
  21. myProcessor = processor == null ? DEFAULTPROCESSOR : processor;
  22. }

代码示例来源:origin: org.jdom/jdom

  1. /**
  2. * This will create an <code>StAXStreamOutputter</code> with the specified format
  3. * characteristics.
  4. * <p>
  5. * <b>Note:</b> the format object is cloned internally before use. If you
  6. * want to modify the Format after constructing the StAXStreamOutputter you can
  7. * modify the Format instance {@link #getFormat()} returns.
  8. *
  9. * @param format
  10. * The Format instance to use. This instance will be cloned() and as
  11. * a consequence, changes made to the specified format instance
  12. * <b>will not</b> be reflected in this StAXStreamOutputter. A null input
  13. * format indicates that StAXStreamOutputter should use the default
  14. * {@link Format#getRawFormat()}
  15. * @param processor
  16. * The XMLOutputProcessor to delegate output to. If null the
  17. * StAXStreamOutputter will use the default XMLOutputProcessor.
  18. * @param eventfactory
  19. * The factory to use to create XMLEvent instances.
  20. */
  21. public StAXEventOutputter(Format format, StAXEventProcessor processor, XMLEventFactory eventfactory) {
  22. myFormat = format == null ? Format.getRawFormat() : format.clone();
  23. myProcessor = processor == null ? DEFAULTPROCESSOR : processor;
  24. myEventFactory = eventfactory == null ? DEFAULTEVENTFACTORY : eventfactory;
  25. }

代码示例来源:origin: usethesource/rascal

  1. public IString xmlRaw(IConstructor node) throws IOException {
  2. return xmlToString(node, Format.getRawFormat());
  3. }

代码示例来源:origin: com.sap.cloud.s4hana.plugins/usage-analytics

  1. void output( @Nonnull final Document document, @Nonnull final File outputFile )
  2. throws IOException
  3. {
  4. try( final FileOutputStream fileOutputStream = new FileOutputStream(outputFile) ) {
  5. new XMLOutputter(Format.getRawFormat()).output(document, fileOutputStream);
  6. }
  7. }
  8. }

代码示例来源:origin: com.xebialabs.cloud/overcast

  1. public static String documentToRawString(Document xml) throws IOException {
  2. return documentToString(xml, Format.getRawFormat().setOmitDeclaration(true)).trim();
  3. }

代码示例来源:origin: org.openfuxml/ofx-wiki

  1. public static synchronized void writeXml(String dirName, String fileName, String content)
  2. {
  3. logger.debug("Writing Xml to "+dirName+"/"+fileName);
  4. try
  5. {
  6. Reader sr = new StringReader(content);
  7. Document doc = new SAXBuilder().build(sr);
  8. XMLOutputter xmlOut = new XMLOutputter(Format.getRawFormat() );
  9. File f = new File(dirName+"/"+fileName);
  10. OutputStream os = new FileOutputStream(f);
  11. OutputStreamWriter osw = new OutputStreamWriter(os,"UTF-8");
  12. xmlOut.output( doc, osw );
  13. osw.close();os.close();
  14. }
  15. catch (JDOMException e) {logger.error("",e);}
  16. catch (IOException e) {logger.error("",e);}
  17. }

代码示例来源:origin: org.openfuxml/ofx-util

  1. public void createIds(File srcFile, File dstFile) throws OfxInternalProcessingException
  2. {
  3. if(srcFile==null){throw new OfxInternalProcessingException("FileNoteFound: "+srcFile.getAbsolutePath());}
  4. doc = JDomUtil.load(srcFile);
  5. if(doc==null){throw new OfxInternalProcessingException("FileNoteFound: "+srcFile.getAbsolutePath());}
  6. try
  7. {
  8. idCreator();
  9. JDomUtil.save(doc, dstFile, Format.getRawFormat());
  10. }
  11. catch (JDOMException e)
  12. {
  13. logger.error("",e);
  14. }
  15. }

代码示例来源:origin: org.apache.maven.plugins/maven-shade-plugin

  1. /**
  2. * Method write
  3. *
  4. * @param project
  5. * @param writer
  6. * @param document
  7. */
  8. public void write( Model project, Document document, OutputStreamWriter writer )
  9. throws java.io.IOException
  10. {
  11. Format format = Format.getRawFormat();
  12. format.setEncoding( writer.getEncoding() ).setLineSeparator( System.getProperty( "line.separator" ) );
  13. write( project, document, writer, format );
  14. } // -- void write(Model, Document, OutputStreamWriter)

代码示例来源:origin: org.mycore/oaipmh-dataprovider

  1. @Override
  2. public String toString(Format format) {
  3. try {
  4. Element e = marshal();
  5. XMLOutputter out = new XMLOutputter(Format.formatted.equals(format) ? org.jdom2.output.Format.getPrettyFormat() : org.jdom2.output.Format.getRawFormat());
  6. StringWriter writer = new StringWriter();
  7. out.output(e, writer);
  8. return writer.toString();
  9. } catch (Exception exc) {
  10. throw new OAIImplementationException(exc);
  11. }
  12. }

代码示例来源:origin: org.openfuxml/ofx-wiki

  1. public synchronized static StringBuffer toString(Wikiinjection injection)
  2. {
  3. StringBufferOutputStream sbos = new StringBufferOutputStream();
  4. try
  5. {
  6. Element element = toElement(injection, Wikiinjection.class);
  7. XMLOutputter xmlOut = new XMLOutputter(Format.getRawFormat() );
  8. xmlOut.output(element, sbos);
  9. }
  10. catch (IOException e) {logger.error("",e);}
  11. return sbos.getStringBuffer();
  12. }

代码示例来源:origin: org.openfuxml/ofx-wiki

  1. public void process() throws OfxInternalProcessingException, OfxConfigurationException
  2. {
  3. File fTemplateDir = getDir(WikiProcessor.WikiDir.wikiTemplate);
  4. for(File fTemplate : fTemplateDir.listFiles())
  5. {
  6. try
  7. {
  8. Template template = (Template)JaxbUtil.loadJAXB(fTemplate.getAbsolutePath(), Template.class);
  9. File fOfxTemplate = new File(getDir(WikiProcessor.WikiDir.ofxTemplate),template.getId()+".xml");
  10. Document doc = processTemplate(template);
  11. JDomUtil.save(doc, fOfxTemplate, Format.getRawFormat());
  12. }
  13. catch (FileNotFoundException e)
  14. {
  15. throw new OfxInternalProcessingException(e.getMessage());
  16. }
  17. }
  18. }

代码示例来源:origin: org.openfuxml/ofx-wiki

  1. public void processPage(Page page) throws OfxAuthoringException, OfxInternalProcessingException
  2. {
  3. checkPageConfig(page);
  4. try
  5. {
  6. String srcName = page.getFile()+"."+WikiProcessor.WikiFileExtension.xhtml;
  7. String dstName = page.getFile()+"."+WikiProcessor.WikiFileExtension.xml;
  8. String txtMarkup = StringIO.loadTxt(srcDir, srcName);
  9. String result = process(txtMarkup, page.getName());
  10. File fDst = new File(dstDir, dstName);
  11. Document doc = JDomUtil.txtToDoc(result);
  12. doc = checkTransparent(doc, page.getSection());
  13. logger.warn("Content Trimmer deactivated here");
  14. // doc = ofxContentTrimmer.trim(doc);
  15. JDomUtil.save(doc, fDst, Format.getRawFormat());
  16. }
  17. catch (IOException e) {logger.error("",e);}
  18. catch (ParserConfigurationException e) {logger.error("",e);}
  19. catch (XMLStreamException e) {logger.error("",e);}
  20. catch (SAXException e) {logger.error("",e);}
  21. catch (JDOMException e) {logger.error("",e);}
  22. }

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public String getString()
  5. throws IOException
  6. {
  7. m_document.setContext( m_context );
  8. CustomXMLOutputProcessor processor = new CustomXMLOutputProcessor();
  9. XMLOutputter output = new XMLOutputter(processor);
  10. StringWriter out = new StringWriter();
  11. Format fmt = Format.getRawFormat();
  12. fmt.setExpandEmptyElements( false );
  13. fmt.setLineSeparator( LINEBREAK );
  14. output.setFormat( fmt );
  15. output.outputElementContent( m_document.getRootElement(), out );
  16. String result = out.toString();
  17. return result;
  18. }
  19. }

代码示例来源:origin: org.apache.jspwiki/jspwiki-main

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public String getString()
  5. throws IOException
  6. {
  7. Element rootElement = m_document.getRootElement();
  8. processChildren( rootElement );
  9. m_document.setContext( m_context );
  10. XMLOutputter output = new XMLOutputter();
  11. StringWriter out = new StringWriter();
  12. Format fmt = Format.getRawFormat();
  13. fmt.setExpandEmptyElements( false );
  14. fmt.setLineSeparator( LINEBREAK );
  15. output.setFormat( fmt );
  16. output.outputElementContent( m_document.getRootElement(), out );
  17. return out.toString();
  18. }
  19. }

代码示例来源:origin: com.atlassian.maven.plugins/maven-jgitflow-plugin

  1. Format format = Format.getRawFormat();
  2. format.setLineSeparator( ls );
  3. XMLOutputter out = new XMLOutputter( format );

相关文章