本文整理汇总了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);
}
示例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);
}
}