gpt4 book ai didi

com.sun.xml.bind.v2.runtime.XMLSerializer.childAsXsiType()方法的使用及代码示例

转载 作者:知者 更新时间:2024-03-23 22:45:05 26 4
gpt4 key购买 nike

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

XMLSerializer.childAsXsiType介绍

[英]This method is called when a type child object is found.

This method produces events of the following form:

NSDECL* "endNamespaceDecls" ATTRIBUTE* "endAttributes" BODY

optionally including @xsi:type if necessary.
[中]

代码示例

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeItem(JaxBeanInfo expected, ItemT item, XMLSerializer w) throws SAXException, IOException, XMLStreamException {
    if(item==null) {
      w.writeXsiNilTrue();
    } else {
      w.childAsXsiType(item,fieldName,expected, false);
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void serializeBody(Object array, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  int len = Array.getLength(array);
  for( int i=0; i<len; i++ )  {
    Object item = Array.get(array,i);
    // TODO: check the namespace URI.
    target.startElement("","item",null,null);
    if(item==null) {
      target.writeXsiNilTrue();
    } else {
      target.childAsXsiType(item,"arrayItem",itemBeanInfo, false);
    }
    target.endElement();
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

public void marshal(T value, XMLSerializer out) throws IOException, SAXException, XMLStreamException {
  out.startElement(tagName,null);
  if(value==null) {
    out.writeXsiNilTrue();
  } else {
    out.childAsXsiType(value,null,bi,false);
  }
  out.endElement();
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

w.childAsXsiType(v,fieldName,w.grammar.getBeanInfo(Object.class), addNilDecl && nillable);
} else {
  w.startElement(tt.tagName,null);
  w.childAsXsiType(v,fieldName,tt.beanInfo, addNilDecl && nillable);

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

@Override
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
  ValueT v = acc.get(o);
  if(v!=null) {
    bareStartTag(w,tagName,v);
    for( Map.Entry e : (Set<Map.Entry>)v.entrySet() ) {
      bareStartTag(w,entryTag,null);
      Object key = e.getKey();
      if(key!=null) {
        w.startElement(keyTag,key);
        w.childAsXsiType(key,fieldName,keyBeanInfo, false);
        w.endElement();
      }
      Object value = e.getValue();
      if(value!=null) {
        w.startElement(valueTag,value);
        w.childAsXsiType(value,fieldName,valueBeanInfo, false);
        w.endElement();
      }
      w.endElement();
    }
    w.endElement();
  } else
  if(nillable) {
    w.startElement(tagName,null);
    w.writeXsiNilTrue();
    w.endElement();
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
} else {
  w.startElement(tt.tagName,null);

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

target.writeXsiNilTrue();
} else {
  target.childAsXsiType(value,"value",tbi, false);

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

@Override
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
  boolean hasValue = xacc.hasValue(o);
  Object obj = null;
  try {
    obj = acc.getUnadapted(o);
  } catch (AccessorException ae) {
    ; // noop
  }
  Class valueType = acc.getValueType();
  // check for different type than expected. If found, add xsi:type declaration
  if (xsiTypeNeeded(o, w, obj, valueType)) {
    w.startElement(tagName, outerPeer);
    w.childAsXsiType(obj, fieldName, w.grammar.getBeanInfo(valueType), false);
    w.endElement();
  } else {  // current type is expected
    if (hasValue) {
      xacc.writeLeafElement(w, tagName, o, fieldName);
    } else if (nillable) {
      w.startElement(tagName, null);
      w.writeXsiNilTrue();
      w.endElement();
    }
  }
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

serializer.writeXsiNilTrue();
else
  serializer.childAsXsiType(obj,"root",bi, false);

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

public void serializeItem(JaxBeanInfo expected, ItemT item, XMLSerializer w) throws SAXException, IOException, XMLStreamException {
    if(item==null) {
      w.writeXsiNilTrue();
    } else {
      w.childAsXsiType(item,fieldName,expected, false);
    }
  }
}

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

public void serializeBody(Object array, XMLSerializer target) throws SAXException, IOException, XMLStreamException {
  int len = Array.getLength(array);
  for( int i=0; i<len; i++ )  {
    Object item = Array.get(array,i);
    // TODO: check the namespace URI.
    target.startElement("","item",null,null);
    if(item==null) {
      target.writeXsiNilTrue();
    } else {
      target.childAsXsiType(item,"arrayItem",itemBeanInfo, false);
    }
    target.endElement();
  }
}

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

public void marshal(T value, XMLSerializer out) throws IOException, SAXException, XMLStreamException {
  out.startElement(tagName,null);
  if(value==null) {
    out.writeXsiNilTrue();
  } else {
    out.childAsXsiType(value,null,bi,false);
  }
  out.endElement();
}

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

w.childAsXsiType(v,fieldName,w.grammar.getBeanInfo(Object.class), addNilDecl && nillable);
} else {
  w.startElement(tt.tagName,null);
  w.childAsXsiType(v,fieldName,tt.beanInfo, addNilDecl && nillable);

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

@Override
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
  ValueT v = acc.get(o);
  if(v!=null) {
    bareStartTag(w,tagName,v);
    for( Map.Entry e : (Set<Map.Entry>)v.entrySet() ) {
      bareStartTag(w,entryTag,null);
      Object key = e.getKey();
      if(key!=null) {
        w.startElement(keyTag,key);
        w.childAsXsiType(key,fieldName,keyBeanInfo, false);
        w.endElement();
      }
      Object value = e.getValue();
      if(value!=null) {
        w.startElement(valueTag,value);
        w.childAsXsiType(value,fieldName,valueBeanInfo, false);
        w.endElement();
      }
      w.endElement();
    }
    w.endElement();
  } else
  if(nillable) {
    w.startElement(tagName,null);
    w.writeXsiNilTrue();
    w.endElement();
  }
}

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

w.childAsXsiType(item,fieldName,w.grammar.getBeanInfo(Object.class), false);
} else {
  w.startElement(tt.tagName,null);

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

target.writeXsiNilTrue();
} else {
  target.childAsXsiType(value,"value",tbi, false);

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

@Override
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
  boolean hasValue = xacc.hasValue(o);
  Object obj = null;
  try {
    obj = acc.getUnadapted(o);
  } catch (AccessorException ae) {
    ; // noop
  }
  Class valueType = acc.getValueType();
  // check for different type than expected. If found, add xsi:type declaration
  if (xsiTypeNeeded(o, w, obj, valueType)) {
    w.startElement(tagName, outerPeer);
    w.childAsXsiType(obj, fieldName, w.grammar.getBeanInfo(valueType), false);
    w.endElement();
  } else {  // current type is expected
    if (hasValue) {
      xacc.writeLeafElement(w, tagName, o, fieldName);
    } else if (nillable) {
      w.startElement(tagName, null);
      w.writeXsiNilTrue();
      w.endElement();
    }
  }
}

代码示例来源:origin: org.glassfish.jaxb/jaxb-runtime

serializer.writeXsiNilTrue();
else
  serializer.childAsXsiType(obj,"root",bi, false);

代码示例来源:origin: apache/servicemix-bundles

public void serializeItem(JaxBeanInfo expected, ItemT item, XMLSerializer w) throws SAXException, IOException, XMLStreamException {
    if(item==null) {
      w.writeXsiNilTrue();
    } else {
      w.childAsXsiType(item,fieldName,expected, false);
    }
  }
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.jaxb-impl

public void marshal(T value, XMLSerializer out) throws IOException, SAXException, XMLStreamException {
  out.startElement(tagName,null);
  if(value==null) {
    out.writeXsiNilTrue();
  } else {
    out.childAsXsiType(value,null,bi,false);
  }
  out.endElement();
}

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com