Author: swd847
Date: 2010-07-18 01:06:33 -0400 (Sun, 18 Jul 2010)
New Revision: 13426
Added:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/GenericBeanXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/KeyXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParameterXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParametersXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ReplacesXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
Log:
add stricter validation to the xml
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/AnnotationXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -25,9 +25,11 @@
import java.util.Map;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public class AnnotationXmlItem extends AbstractXmlItem
{
- private final HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+ private final HashSet<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
public AnnotationXmlItem(XmlItem parent, Class<?> c, String innerText,
Map<String, String> attributes, String document, int lineno)
{
@@ -39,10 +41,10 @@
attributes.put("value", innerText);
}
}
- allowed.add(XmlItemType.ANNOTATION);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ClassXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -37,6 +37,7 @@
import org.jboss.seam.xml.core.BeanResult;
import org.jboss.seam.xml.core.BeanResultType;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
import org.jboss.weld.extensions.annotated.AnnotatedTypeBuilder;
import org.jboss.weld.extensions.util.Reflections;
@@ -44,18 +45,20 @@
public class ClassXmlItem extends AbstractXmlItem
{
- HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+ HashSet<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
public ClassXmlItem(XmlItem parent, Class<?> c, Map<String, String>
attributes, String document, int lineno)
{
super(XmlItemType.CLASS, parent, c, null, attributes, document, lineno);
- allowed.add(XmlItemType.ANNOTATION);
- allowed.add(XmlItemType.FIELD);
- allowed.add(XmlItemType.METHOD);
- allowed.add(XmlItemType.PARAMETERS);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.FIELD, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.METHOD, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.PARAMETERS, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.REPLACE, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.MODIFIES, null, null));
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/EntryXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,12 +24,13 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
public class EntryXmlItem extends AbstractXmlItem
{
- final Set<XmlItemType> allowed = new HashSet<XmlItemType>();
+ final Set<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
XmlItem key;
XmlItem value;
@@ -37,11 +38,11 @@
public EntryXmlItem(XmlItem parent, String document, int lineno)
{
super(XmlItemType.ENTRY, parent, null, null, null, document, lineno);
- allowed.add(XmlItemType.VALUE);
- allowed.add(XmlItemType.KEY);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.VALUE, 1, 1));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.KEY, 1, 1));
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/FieldXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -38,6 +38,7 @@
import org.jboss.seam.xml.fieldset.MapFieldSet;
import org.jboss.seam.xml.fieldset.MethodFieldSetter;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
public class FieldXmlItem extends AbstractXmlItem implements FieldValueXmlItem
@@ -46,7 +47,7 @@
FieldValueSetter fieldSetter;
FieldValueObject fieldValue;
Field field;
- HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+ HashSet<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
public FieldXmlItem(XmlItem parent, Field c, String innerText, String document, int
lineno)
{
@@ -57,8 +58,9 @@
{
fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter,
innerText);
}
- allowed.add(XmlItemType.ANNOTATION);
- allowed.add(XmlItemType.VALUE);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.VALUE, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ENTRY, null, null));
}
public Field getField()
@@ -138,7 +140,7 @@
return true;
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/GenericBeanXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/GenericBeanXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/GenericBeanXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -25,6 +25,7 @@
import java.util.Map;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
public class GenericBeanXmlItem extends AbstractXmlItem
@@ -45,9 +46,9 @@
}
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
- return Collections.singleton(XmlItemType.CLASS);
+ return Collections.singleton(TypeOccuranceInformation.of(XmlItemType.CLASS, 1,
null));
}
public Class<?> getClass(String className, String document, int lineno)
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/KeyXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/KeyXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/KeyXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.Collections;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public class KeyXmlItem extends AbstractXmlItem
{
@@ -32,7 +34,7 @@
super(XmlItemType.KEY, parent, null, innerText, null, document, lineno);
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return Collections.emptySet();
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/MethodXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -27,6 +27,7 @@
import java.util.List;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
public class MethodXmlItem extends AbstractXmlItem
@@ -35,14 +36,14 @@
private String methodName;
Method method;
- HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+ HashSet<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
public MethodXmlItem(XmlItem parent, String methodName, String document, int lineno)
{
super(XmlItemType.METHOD, parent, parent.getJavaClass(), null, null, document,
lineno);
- allowed.add(XmlItemType.ANNOTATION);
- allowed.add(XmlItemType.PARAMETERS);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.PARAMETERS, null, 1));
// methods are lazily resolved once we know the parameter types
this.methodName = methodName;
@@ -122,7 +123,7 @@
return method;
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModelBuilder.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -42,6 +42,7 @@
import org.jboss.seam.xml.parser.namespace.CompositeNamespaceElementResolver;
import org.jboss.seam.xml.parser.namespace.NamespaceElementResolver;
import org.jboss.seam.xml.parser.namespace.RootNamespaceElementResolver;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
/**
@@ -109,7 +110,7 @@
@SuppressWarnings("unchecked")
private void addNodeToResult(XmlResult ret, XmlItem xmlItem)
{
-
+ validateXmlItem(xmlItem);
if (xmlItem.getType() == XmlItemType.CLASS || xmlItem.getType() ==
XmlItemType.ANNOTATION)
{
ResultType resultType = getItemType(xmlItem);
@@ -305,15 +306,53 @@
public void validateXmlItem(XmlItem item)
{
- Set<XmlItemType> allowed = item.getAllowedItem();
+ Set<TypeOccuranceInformation> allowed = item.getAllowedItem();
+ Map<XmlItemType, Integer> counts = new HashMap<XmlItemType,
Integer>();
for (XmlItem i : item.getChildren())
{
- if (!allowed.contains(item.getType()))
+ boolean found = false;
+ for (TypeOccuranceInformation type : allowed)
{
+ if (type.getType() == i.getType())
+ {
+ found = true;
+ if (counts.containsKey(i.getType()))
+ {
+ counts.put(i.getType(), counts.get(i.getType()) + 1);
+ }
+ else
+ {
+ counts.put(i.getType(), 1);
+ }
+ }
+ }
+ if (!found)
+ {
throw new XmlConfigurationException("Item " + item.getType() +
" is not allowed to contain " + i.getType(), item.getDocument(),
item.getLineno());
}
validateXmlItem(i);
}
+ for (TypeOccuranceInformation type : allowed)
+ {
+ Integer count = counts.get(type.getType());
+ if (type.getMaxOccurances() != null)
+ {
+ if (count != null)
+ {
+ if (count > type.getMaxOccurances())
+ {
+ throw new XmlConfigurationException("Item " + item.getType()
+ " has " + count + "children of type " + type.getType() + " when
it should have at most " + type.getMaxOccurances(), item.getDocument(),
item.getLineno());
+ }
+ }
+ }
+ if (type.getMinOccurances() != null)
+ {
+ if (count == null || count < type.getMinOccurances())
+ {
+ throw new XmlConfigurationException("Item " + item.getType() +
" has " + count + "children of type " + type.getType() + " when
it should have at least " + type.getMaxOccurances(), item.getDocument(),
item.getLineno());
+
+ }
+ }
+ }
}
-
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ModifiesXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.Collections;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public class ModifiesXmlItem extends AbstractXmlItem
{
@@ -33,7 +35,7 @@
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return Collections.emptySet();
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParameterXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParameterXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParameterXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.HashSet;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
/**
* represents a parameter of a constructor or method
*
@@ -32,15 +34,17 @@
*/
public class ParameterXmlItem extends AbstractXmlItem
{
- HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+ HashSet<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
public ParameterXmlItem(XmlItem parent, Class<?> c, String document, int
lineno)
{
super(XmlItemType.PARAMETER, parent, c, null, null, document, lineno);
- allowed.add(XmlItemType.ANNOTATION);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ANNOTATION, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.CLASS, null, 1));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ARRAY, null, 1));
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParametersXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParametersXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ParametersXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.Collections;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public class ParametersXmlItem extends AbstractXmlItem
{
@@ -33,9 +35,9 @@
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
- return Collections.singleton(XmlItemType.PARAMETER);
+ return Collections.singleton(TypeOccuranceInformation.of(XmlItemType.PARAMETER, 1,
null));
}
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/PropertyXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -36,6 +36,7 @@
import org.jboss.seam.xml.fieldset.MapFieldSet;
import org.jboss.seam.xml.fieldset.MethodFieldSetter;
import org.jboss.seam.xml.fieldset.SimpleFieldValue;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
public class PropertyXmlItem extends AbstractXmlItem implements FieldValueXmlItem
@@ -45,7 +46,7 @@
FieldValueObject fieldValue;
String name;
Class<?> type;
- HashSet<XmlItemType> allowed = new HashSet<XmlItemType>();
+ HashSet<TypeOccuranceInformation> allowed = new
HashSet<TypeOccuranceInformation>();
public PropertyXmlItem(XmlItem parent, String name, Method setter, String innerText,
String document, int lineno)
{
@@ -57,7 +58,8 @@
{
fieldValue = new SimpleFieldValue(parent.getJavaClass(), fieldSetter,
innerText);
}
- allowed.add(XmlItemType.VALUE);
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.VALUE, null, null));
+ allowed.add(TypeOccuranceInformation.of(XmlItemType.ENTRY, null, null));
}
public FieldValueObject getFieldValue()
@@ -132,7 +134,7 @@
return true;
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return allowed;
}
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ReplacesXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ReplacesXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ReplacesXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.Collections;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public class ReplacesXmlItem extends AbstractXmlItem
{
@@ -33,7 +35,7 @@
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
return Collections.emptySet();
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/ValueXmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.Collections;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public class ValueXmlItem extends AbstractXmlItem
{
@@ -32,8 +34,9 @@
super(XmlItemType.VALUE, parent, null, innerText, null, document, lineno);
}
- public Set<XmlItemType> getAllowedItem()
+ public Set<TypeOccuranceInformation> getAllowedItem()
{
- return Collections.emptySet();
+ return Collections.singleton(TypeOccuranceInformation.of(XmlItemType.CLASS, null,
1));
}
+
}
Modified: modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java
===================================================================
--- modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java 2010-07-18
04:28:50 UTC (rev 13425)
+++ modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/model/XmlItem.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -24,6 +24,8 @@
import java.util.List;
import java.util.Set;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
+
public interface XmlItem
{
@@ -47,7 +49,7 @@
*/
public boolean resolveChildren();
- public Set<XmlItemType> getAllowedItem();
+ public Set<TypeOccuranceInformation> getAllowedItem();
int getLineno();
Modified:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java 2010-07-18
04:28:50 UTC (rev 13425)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/parser/namespace/PackageNamespaceElementResolver.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -37,6 +37,7 @@
import org.jboss.seam.xml.model.XmlItem;
import org.jboss.seam.xml.model.XmlItemType;
import org.jboss.seam.xml.parser.SaxNode;
+import org.jboss.seam.xml.util.TypeOccuranceInformation;
import org.jboss.seam.xml.util.XmlConfigurationException;
import org.jboss.weld.extensions.util.Reflections;
@@ -101,7 +102,7 @@
if (parent != null)
{
// if the item can be a method of a FIELD
- if (parent.getAllowedItem().contains(XmlItemType.METHOD) ||
parent.getAllowedItem().contains(XmlItemType.FIELD))
+ if (TypeOccuranceInformation.isTypeInSet(parent.getAllowedItem(),
XmlItemType.METHOD) || TypeOccuranceInformation.isTypeInSet(parent.getAllowedItem(),
XmlItemType.FIELD))
{
return resolveMethodOrField(name, parent, node.getInnerText(),
node.getDocument(), node.getLineNo());
}
Added:
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java
===================================================================
---
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java
(rev 0)
+++
modules/xml/trunk/impl/src/main/java/org/jboss/seam/xml/util/TypeOccuranceInformation.java 2010-07-18
05:06:33 UTC (rev 13426)
@@ -0,0 +1,51 @@
+package org.jboss.seam.xml.util;
+
+import java.util.Set;
+
+import org.jboss.seam.xml.model.XmlItemType;
+
+public class TypeOccuranceInformation
+{
+ private final XmlItemType type;
+ private final Integer minOccurances;
+ private final Integer maxOccurances;
+
+ public TypeOccuranceInformation(XmlItemType type, Integer minOccurances, Integer
maxOccurances)
+ {
+ this.type = type;
+ this.minOccurances = minOccurances;
+ this.maxOccurances = maxOccurances;
+ }
+
+ public XmlItemType getType()
+ {
+ return type;
+ }
+
+ public Integer getMinOccurances()
+ {
+ return minOccurances;
+ }
+
+ public Integer getMaxOccurances()
+ {
+ return maxOccurances;
+ }
+
+ public static TypeOccuranceInformation of(XmlItemType type, Integer min, Integer max)
+ {
+ return new TypeOccuranceInformation(type, min, min);
+ }
+
+ public static boolean isTypeInSet(Set<TypeOccuranceInformation> set, XmlItemType
type)
+ {
+ for (TypeOccuranceInformation i : set)
+ {
+ if (i.getType() == type)
+ {
+ return true;
+ }
+ }
+ return false;
+ }
+}