org.exolab.castor.xml.Marshaller.setProperty()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.1k)|赞(0)|评价(0)|浏览(235)

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

Marshaller.setProperty介绍

[英]Sets a custom value of a given Castor XML-specific property.
[中]设置给定Castor XML特定属性的自定义值。

代码示例

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-atom

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the document.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/atom"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. //serializer.getMarshaller().setNamespaceMapping("", "http://www.w3.org/2005/Atom");
  10. serializer.marshal(_feed, writer, false); // May throw Exception.
  11. String enc = encoding;
  12. if (enc == null)
  13. {
  14. enc = "UTF-8";
  15. }
  16. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  17. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  18. out.flush(); // May throw IOException.
  19. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-asx

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the ASX playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/playlist/asx"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. serializer.marshal(this, writer, false); // May throw Exception.
  10. String enc = encoding;
  11. if (enc == null)
  12. {
  13. enc = "UTF-8"; // FIXME US-ASCII?
  14. }
  15. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  16. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  17. out.flush(); // May throw IOException.
  18. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-b4s

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the B4S playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/playlist/b4s"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. serializer.marshal(this, writer, false); // May throw Exception.
  10. String enc = encoding;
  11. if (enc == null)
  12. {
  13. enc = "UTF-8";
  14. }
  15. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  16. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  17. out.flush(); // May throw IOException.
  18. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-smil

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the SMIL playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/playlist/smil"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. serializer.marshal(this, writer, false); // May throw Exception.
  10. String enc = encoding;
  11. if (enc == null)
  12. {
  13. enc = "UTF-8";
  14. }
  15. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  16. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  17. out.flush(); // May throw IOException.
  18. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-hypetape

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping(
  7. "chameleon/playlist/hypetape"); // May throw Exception.
  8. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  9. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  10. serializer.marshal(this, writer, false); // May throw Exception.
  11. String enc = encoding;
  12. if (enc == null)
  13. {
  14. enc = "UTF-8";
  15. }
  16. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  17. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  18. out.flush(); // May throw IOException.
  19. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-plist

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the PLIST playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/plist"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. serializer.marshal(_plist, writer, false); // May throw Exception.
  10. String enc = encoding;
  11. if (enc == null)
  12. {
  13. enc = "UTF-8";
  14. }
  15. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  16. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  17. out.flush(); // May throw IOException.
  18. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-wpl

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the SMIL playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/playlist/wpl"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. serializer.marshal(this, writer, false); // May throw Exception.
  10. String enc = encoding;
  11. if (enc == null)
  12. {
  13. enc = "UTF-8";
  14. }
  15. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  16. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  17. out.flush(); // May throw IOException.
  18. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-xspf

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the playlist.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/playlist/xspf"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. serializer.marshal(this, writer, false); // May throw Exception.
  10. String enc = encoding;
  11. if (enc == null)
  12. {
  13. enc = "UTF-8";
  14. }
  15. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  16. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  17. out.flush(); // May throw IOException.
  18. }

代码示例来源:origin: com.github.muff1nman.chameleon/playlist-rss

  1. @Override
  2. public void writeTo(final OutputStream out, final String encoding) throws Exception
  3. {
  4. // Marshal the RSS document.
  5. final StringWriter writer = new StringWriter();
  6. final XmlSerializer serializer = XmlSerializer.getMapping("chameleon/rss"); // May throw Exception.
  7. // Specifies whether XML documents (as generated at marshalling) should use indentation or not. Default is false.
  8. serializer.getMarshaller().setProperty("org.exolab.castor.indent", "true");
  9. //serializer.getMarshaller().setNamespaceMapping("", "http://purl.org/rss/1.0/modules/content/");
  10. serializer.getMarshaller().setNamespaceMapping("media", "http://search.yahoo.com/mrss/");
  11. serializer.marshal(_rss, writer, false); // May throw Exception.
  12. String enc = encoding;
  13. if (enc == null)
  14. {
  15. enc = "UTF-8";
  16. }
  17. final byte[] bytes = writer.toString().getBytes(enc); // May throw UnsupportedEncodingException.
  18. out.write(bytes); // Throws NullPointerException if out is null. May throw IOException.
  19. out.flush(); // May throw IOException.
  20. }

相关文章