|
|||||||||||||||||||
| 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 | |||||||||||||||
| IdRefsConstraint.java | 83,3% | 100% | 100% | 96% |
|
||||||||||||||
| 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.constraint; |
|
| 11 |
|
|
| 12 |
|
|
| 13 |
import java.util.ArrayList; |
|
| 14 |
import java.util.Collections; |
|
| 15 |
import java.util.Iterator; |
|
| 16 |
import java.util.List; |
|
| 17 |
|
|
| 18 |
import org.jbind.xml.base.IHasLocation; |
|
| 19 |
import org.jbind.xml.core.constraint.ConstraintType; |
|
| 20 |
import org.jbind.xml.core.content.IAttrRefOrDecl; |
|
| 21 |
import org.jbind.xml.core.data.IAnyListTypeData; |
|
| 22 |
import org.jbind.xml.core.data.IAnyTypeData; |
|
| 23 |
import org.jbind.xml.core.data.ISimpleData; |
|
| 24 |
import org.jbind.xml.schema.cmp.W3CTypes; |
|
| 25 |
|
|
| 26 |
public class IdRefsConstraint extends IdRefOrIdRefsConstraint {
|
|
| 27 |
|
|
| 28 | 6 |
public IdRefsConstraint(IAttrRefOrDecl aDecl, IHasLocation aHasLocation) {
|
| 29 | 6 |
super(aDecl, aHasLocation); |
| 30 |
} |
|
| 31 |
|
|
| 32 | 12 |
public boolean isSingleNotMultipleReference() {
|
| 33 | 12 |
return false; |
| 34 |
} |
|
| 35 |
|
|
| 36 | 6 |
public ConstraintType getConstraintType() {
|
| 37 | 6 |
return ConstraintType.ID_REFS; |
| 38 |
} |
|
| 39 |
|
|
| 40 | 5 |
protected Iterator iterKeys(IAnyTypeData aData) {
|
| 41 | 5 |
Iterator res = null; |
| 42 | 5 |
IAnyListTypeData ld = (IAnyListTypeData)getAddressedData(aData); |
| 43 | 5 |
if (null != ld) {
|
| 44 | 4 |
List l = new ArrayList(); |
| 45 | 4 |
for (Iterator i = ld.iterItems(); i.hasNext(); ) {
|
| 46 | 9 |
ISimpleData sd = (ISimpleData)i.next(); |
| 47 | 9 |
if (W3CTypes.idRef.isBaseType(sd.getType_())) {
|
| 48 | 9 |
Object key = sd.getCanonicalForm_(); |
| 49 | 9 |
l.add(key); |
| 50 |
} |
|
| 51 |
} |
|
| 52 | 4 |
res = l.iterator(); |
| 53 |
} else {
|
|
| 54 | 1 |
res = Collections.EMPTY_LIST.iterator(); |
| 55 |
} |
|
| 56 | 5 |
return res; |
| 57 |
} |
|
| 58 |
|
|
| 59 |
} |
|
| 60 |
|
|
||||||||||