|
|||||||||||||||||||
| This license of Clover is provided to support the development of JBind only. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover. | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| EnumerationFacet.java | 100% | 100% | 100% | 100% |
|
||||||||||||||
| 1 |
/* |
|
| 2 |
* JBind |
|
| 3 |
* |
|
| 4 |
* Copyright (c) by Stefan Wachter. All rights reserved. |
|
| 5 |
* |
|
| 6 |
* Usage, modification, and redistribution is subject to license terms that are |
|
| 7 |
* available at 'http://www.jbind.org'. The JBind license is like the |
|
| 8 |
* 'Apache Software License V 1.1'. |
|
| 9 |
*/ |
|
| 10 |
package org.jbind.xml.schema.element; |
|
| 11 |
|
|
| 12 |
import org.jbind.xml.base.IAttribute; |
|
| 13 |
import org.jbind.xml.base.IBindingAttributes; |
|
| 14 |
import org.jbind.xml.core.constraint.ConstraintType; |
|
| 15 |
import org.jbind.xml.core.constraint.IConstraints; |
|
| 16 |
import org.jbind.xml.core.constraint.IEnumerationConstraint; |
|
| 17 |
import org.jbind.xml.core.data.IAnyTypeData; |
|
| 18 |
import org.jbind.xml.core.type.IAnyType; |
|
| 19 |
import org.jbind.xml.msg.IConstraintViolations; |
|
| 20 |
import org.jbind.xml.msg.XmlException; |
|
| 21 |
|
|
| 22 |
public class EnumerationFacet extends Facet {
|
|
| 23 |
|
|
| 24 | 179 |
public EnumerationFacet(CreationParams aCreationParams) {
|
| 25 | 179 |
super(aCreationParams, ConstraintType.ENUMERATION); |
| 26 |
} |
|
| 27 |
|
|
| 28 | 203 |
protected IAttribute doCreateAttribute(ACParams anACParams) throws XmlException {
|
| 29 | 203 |
IAttribute res = null; |
| 30 | 203 |
String upan = NameUtil.getBindingAttributeName(anACParams); |
| 31 | 203 |
if (IBindingAttributes.NAME.equals(upan)) {
|
| 32 | 8 |
res = new Attribute(anACParams); |
| 33 |
} else {
|
|
| 34 | 195 |
res = super.doCreateAttribute(anACParams); |
| 35 |
} |
|
| 36 | 203 |
return res; |
| 37 |
} |
|
| 38 |
|
|
| 39 | 179 |
public void doAddConstraint(IAnyType aType, IConstraints aConstraints, IConstraintViolations aViolations) throws XmlException {
|
| 40 | 179 |
IAnyTypeData anyData = createValueData(aType); |
| 41 | 179 |
IEnumerationConstraint ec = (IEnumerationConstraint)aConstraints.getConstraint(ConstraintType.ENUMERATION); |
| 42 | 179 |
if (null == ec) {
|
| 43 | 70 |
ec = ((ConstraintType.Enumeration)getConstraintType()).createConstraint(); |
| 44 | 70 |
aConstraints.add(ec, aViolations, this); |
| 45 |
} |
|
| 46 | 179 |
ec.addOption(anyData, this); |
| 47 |
} |
|
| 48 |
|
|
| 49 |
} |
|
| 50 |
|
|
||||||||||