return true;
} else {
return false;
}
}
CoreContainerPolicy cp = getContainerPolicy();
Object iterator = cp.iteratorFor(value);
if (null != iterator && cp.hasNext(iterator)) {
if(xPathFragment != null) {
XPathFragment groupingFragment = marshalRecord.openStartGroupingElements(namespaceResolver);
marshalRecord.closeStartGroupingElements(groupingFragment);
}
} else {
return marshalRecord.emptyCollection(xPathFragment, namespaceResolver, xmlChoiceCollectionMapping.getWrapperNullPolicy() != null);
}
if(marshalRecord.getMarshaller().isApplicationJSON()){
List<NodeValue> nodeValues = new ArrayList();
List<List> values = new ArrayList<List>();
NodeValue mixedNodeValue = null;
List mixedValues = null;
//sort the elements. Results will be a list of nodevalues and a corresponding list of
//collections associated with those nodevalues
while(cp.hasNext(iterator)) {
Object nextValue = xmlChoiceCollectionMapping.convertObjectValueToDataValue(cp.next(iterator, session), session, marshalRecord.getMarshaller());
NodeValue nodeValue = getNodeValueForValue(nextValue);
if(nodeValue != null){
if(nodeValue == this){
mixedNodeValue = this;
if(mixedValues == null){
mixedValues = new ArrayList();
}
mixedValues.add(nextValue);
}else{
int index = nodeValues.indexOf(nodeValue);
if(index > -1){
values.get(index).add(nextValue);
}else{
nodeValues.add(nodeValue);
List valuesList = new ArrayList();
valuesList.add(nextValue);
values.add(valuesList);
}
}
}
}
//always write out mixed values last so we can determine if the textWrapper key needs to be written.
if(mixedNodeValue != null){
nodeValues.add(mixedNodeValue);
values.add(mixedValues);
}
for(int i =0;i < nodeValues.size(); i++){
NodeValue associatedNodeValue = nodeValues.get(i);
List listValue = values.get(i);
XPathFragment frag = null;
if(associatedNodeValue == this){
frag = marshalRecord.getTextWrapperFragment();
}else{
frag = associatedNodeValue.getXPathNode().getXPathFragment();
if(frag != null){
frag = getOwningFragment(associatedNodeValue, frag);
associatedNodeValue = ((XMLChoiceCollectionMappingUnmarshalNodeValue)associatedNodeValue).getChoiceElementMarshalNodeValue();
}
}
if(frag != null || associatedNodeValue.isAnyMappingNodeValue()){
int valueSize = listValue.size();
marshalRecord.startCollection();
for(int j=0;j<valueSize; j++){
marshalSingleValueWithNodeValue(frag, marshalRecord, object, listValue.get(j), session, namespaceResolver, ObjectMarshalContext.getInstance(), associatedNodeValue);
}
marshalRecord.endCollection();
}
}
}
else{
while(cp.hasNext(iterator)) {
Object nextValue = cp.next(iterator, session);
marshalSingleValue(xPathFragment, marshalRecord, object, nextValue, session, namespaceResolver, ObjectMarshalContext.getInstance());
}
}
return true;
}