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


Java OutputNode.setReference方法代码示例

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


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

示例1: writeSection

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * This <code>writeSection</code> method is used to perform serialization 
 * of the given source object. Serialization is performed by appending
 * elements and attributes from the source object to the provided XML
 * element object. How the objects contacts are serialized is 
 * determined by the XML schema class that the source object is an
 * instance of. If a required contact is null an exception is thrown.
 * 
 * @param source this is the source object to be serialized
 * @param node the XML element the object is to be serialized to
 * @param section this is the section that defines the XML structure
 */
private void writeSection(OutputNode node, Object source, Section section) throws Exception {
   NamespaceMap scope = node.getNamespaces();
   String prefix = section.getPrefix();

   if(prefix != null) {
      String reference = scope.getReference(prefix);
      
      if(reference == null) {     
         throw new ElementException("Namespace prefix '%s' in %s is not in scope", prefix, type);
      } else {
         node.setReference(reference);  
      }
   }
   writeAttributes(node, source, section);
   writeElements(node, source, section);
   writeText(node, source, section);
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:30,代码来源:Composite.java

示例2: namespace

import org.simpleframework.xml.stream.OutputNode; //导入方法依赖的package包/类
/**
 * This is use to apply the <code>Namespace</code> annotations on
 * the node. If there is no namespace then this will return and
 * the node will be left unchanged. If however the namespace is 
 * not null then the reference is applied to the specified node.
 * 
 * @param node this is the node to apply the namespace to
 */
private void namespace(OutputNode node) {
   if(primary != null) {
      String reference = primary.reference();
      
      node.setReference(reference);
   }
}
 
开发者ID:ngallagher,项目名称:simplexml,代码行数:16,代码来源:NamespaceDecorator.java


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