Skip to content

Commit

Permalink
Issue #25.
Browse files Browse the repository at this point in the history
  • Loading branch information
highsource committed Apr 11, 2015
1 parent bd6efa8 commit 1a0d87e
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,8 @@ protected void processWrappedElementPropertyInfo(
wrappedPropertyInfo.isCollection(),
wrappedPropertyInfo.getTypeInfo(),
wrappedPropertyInfo.getElementName(),
wrapperPropertyInfo.getElementName());
wrapperPropertyInfo.getWrapperElementName(),
wrappedPropertyInfo.isNillable());

rootClassInfo.addProperty(propertyInfo);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

import javax.xml.namespace.QName;

public interface MElementTypeInfo<T, C extends T> extends MTyped<T, C> {
public interface MElementTypeInfo<T, C extends T> extends MTyped<T, C>,
MNillable {

public QName getElementName();

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package org.jvnet.jaxb2_commons.xml.bind.model;

public interface MNillable {

public boolean isNillable();
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ public MTypeInfo<T, C> getTypeInfo() {
public QName getSubstitutionHead() {
return substitutionHead;
}

@Override
public boolean isNillable() {
return true;
}

public String toString() {
return MessageFormat.format("ElementInfo [{0}: {1}]", getElementName(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,17 @@ public class CMElementPropertyInfo<T, C extends T> extends CMPropertyInfo<T, C>
private final MTypeInfo<T, C> typeInfo;
private final QName elementName;
private final QName wrapperElementName;
private final boolean nillable;

public CMElementPropertyInfo(MPropertyInfoOrigin origin,
MClassInfo<T, C> classInfo, String privateName, boolean collection,
MTypeInfo<T, C> typeInfo, QName elementName,
QName wrapperElementName) {
QName wrapperElementName, boolean nillable) {
super(origin, classInfo, privateName, collection);
this.typeInfo = typeInfo;
this.elementName = elementName;
this.wrapperElementName = wrapperElementName;
this.nillable = nillable;
}

public MTypeInfo<T, C> getTypeInfo() {
Expand All @@ -36,6 +38,11 @@ public QName getElementName() {
public QName getWrapperElementName() {
return wrapperElementName;
}

@Override
public boolean isNillable() {
return nillable;
}

public <V> V acceptPropertyInfoVisitor(MPropertyInfoVisitor<T, C, V> visitor) {
return visitor.visitElementPropertyInfo(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ public boolean isDomAllowed() {
public boolean isTypedObjectAllowed() {
return typedObjectAllowed;
}

@Override
public boolean isNillable() {
return true;
}

public <V> V acceptPropertyInfoVisitor(MPropertyInfoVisitor<T, C, V> visitor) {
return visitor.visitElementRefPropertyInfo(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ public class CMElementTypeInfo<T, C extends T> implements MElementTypeInfo<T, C>

private final MTypeInfo<T, C> typeInfo;

public CMElementTypeInfo(QName elementName, MTypeInfo<T, C> typeInfo) {
private final boolean nillable;

public CMElementTypeInfo(QName elementName, MTypeInfo<T, C> typeInfo, boolean nillable) {
Validate.notNull(elementName);
Validate.notNull(typeInfo);
this.elementName = elementName;
this.typeInfo = typeInfo;
this.nillable = nillable;
}

public QName getElementName() {
Expand All @@ -26,7 +29,12 @@ public QName getElementName() {
public MTypeInfo<T, C> getTypeInfo() {
return typeInfo;
}


public boolean isNillable()
{
return this.nillable;
}

@Override
public String toString() {
return "Element [" + getElementName() + ":" + getTypeInfo() + "]";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,8 @@ protected MPropertyInfo<T, C> createElementPropertyInfo(
return new CMElementPropertyInfo<T, C>(
createPropertyInfoOrigin((PI) ep), classInfo, ep.getName(),
ep.isCollection() && !ep.isValueList(),
getTypeInfo(ep, typeRef), typeRef.getTagName(), ep.getXmlName());
getTypeInfo(ep, typeRef), typeRef.getTagName(),
ep.getXmlName(), typeRef.isNillable());
}

protected MPropertyInfo<T, C> createElementsPropertyInfo(
Expand All @@ -378,7 +379,7 @@ protected MPropertyInfo<T, C> createElementsPropertyInfo(
types.size());
for (TypeRef<T, C> typeRef : types) {
typedElements.add(new CMElementTypeInfo<T, C>(typeRef.getTagName(),
getTypeInfo(ep, typeRef)));
getTypeInfo(ep, typeRef), typeRef.isNillable()));
}
return new CMElementsPropertyInfo<T, C>(
createPropertyInfoOrigin((PI) ep), classInfo, ep.getName(),
Expand All @@ -404,7 +405,7 @@ protected MPropertyInfo<T, C> createElementRefPropertyInfo(

rp.isMixed(), rp.getWildcard() == null ? false
: rp.getWildcard().allowDom,
rp.getWildcard() == null ? false
rp.getWildcard() == null ? true
: rp.getWildcard().allowTypedObject);
}

Expand All @@ -413,14 +414,14 @@ protected MPropertyInfo<T, C> createElementRefsPropertyInfo(
final List<MElementTypeInfo<T, C>> typedElements = new ArrayList<MElementTypeInfo<T, C>>();
for (Element<T, C> element : rp.getElements()) {
typedElements.add(new CMElementTypeInfo<T, C>(element
.getElementName(), getTypeInfo(rp, element)));
.getElementName(), getTypeInfo(rp, element), true));
}
return new CMElementRefsPropertyInfo<T, C>(
createPropertyInfoOrigin((PI) rp), classInfo, rp.getName(),
rp.isCollection(), typedElements, rp.getXmlName(),
rp.isMixed(), rp.getWildcard() == null ? false
: rp.getWildcard().allowDom,
rp.getWildcard() == null ? false
rp.getWildcard() == null ? true
: rp.getWildcard().allowTypedObject);
}

Expand Down

0 comments on commit 1a0d87e

Please sign in to comment.