src/share/jaxws_classes/com/sun/xml/internal/bind/v2/runtime/property/ListElementProperty.java
Print this page
*** 1,7 ****
/*
! * Copyright (c) 1997, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 41,51 ****
--- 41,53 ----
import com.sun.xml.internal.bind.v2.runtime.XMLSerializer;
import com.sun.xml.internal.bind.v2.runtime.reflect.ListTransducedAccessorImpl;
import com.sun.xml.internal.bind.v2.runtime.reflect.TransducedAccessor;
import com.sun.xml.internal.bind.v2.runtime.reflect.Accessor;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.ChildLoader;
+ import com.sun.xml.internal.bind.v2.runtime.unmarshaller.DefaultValueLoaderDecorator;
import com.sun.xml.internal.bind.v2.runtime.unmarshaller.LeafPropertyLoader;
+ import com.sun.xml.internal.bind.v2.runtime.unmarshaller.Loader;
import org.xml.sax.SAXException;
/**
* {@link Property} implementation for {@link ElementPropertyInfo} whose
*** 54,63 ****
--- 56,67 ----
* @author Kohsuke Kawaguchi
*/
final class ListElementProperty<BeanT,ListT,ItemT> extends ArrayProperty<BeanT,ListT,ItemT> {
private final Name tagName;
+ private final String defaultValue;
+
/**
* Converts all the values to a list and back.
*/
private final TransducedAccessor<BeanT> xacc;
*** 67,76 ****
--- 71,81 ----
assert prop.isValueList();
assert prop.getTypes().size()==1; // required by the contract of isValueList
RuntimeTypeRef ref = prop.getTypes().get(0);
tagName = grammar.nameBuilder.createElementName(ref.getTagName());
+ defaultValue = ref.getDefaultValue();
// transducer for each item
Transducer xducer = ref.getTransducer();
// transduced accessor for the whole thing
xacc = new ListTransducedAccessorImpl(xducer,acc,lister);
*** 79,89 ****
public PropertyKind getKind() {
return PropertyKind.ELEMENT;
}
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) {
! handlers.put(tagName, new ChildLoader(new LeafPropertyLoader(xacc),null));
}
@Override
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
ListT list = acc.get(o);
--- 84,96 ----
public PropertyKind getKind() {
return PropertyKind.ELEMENT;
}
public void buildChildElementUnmarshallers(UnmarshallerChain chain, QNameMap<ChildLoader> handlers) {
! Loader l = new LeafPropertyLoader(xacc);
! l = new DefaultValueLoaderDecorator(l, defaultValue);
! handlers.put(tagName, new ChildLoader(l,null));
}
@Override
public void serializeBody(BeanT o, XMLSerializer w, Object outerPeer) throws SAXException, AccessorException, IOException, XMLStreamException {
ListT list = acc.get(o);