|
|||||||||||||||||||
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 | |||||||||||||||
IdOrIdsConstraint.java | 75% | 80% | 100% | 81,8% |
|
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 |
import java.util.Iterator; |
|
13 |
|
|
14 |
import org.jbind.xml.base.IHasLocation; |
|
15 |
import org.jbind.xml.base.IRefs; |
|
16 |
import org.jbind.xml.core.content.IAttrRefOrDecl; |
|
17 |
import org.jbind.xml.core.data.IAnyTypeData; |
|
18 |
import org.jbind.xml.core.data.IDataContext; |
|
19 |
import org.jbind.xml.msg.IConstraintViolations; |
|
20 |
import org.jbind.xml.msg.XmlMessages; |
|
21 |
|
|
22 |
public abstract class IdOrIdsConstraint extends IdentityConstraint { |
|
23 |
|
|
24 | 8 |
public IdOrIdsConstraint(IAttrRefOrDecl aDecl, IHasLocation aHasLocation) { |
25 | 8 |
super(aDecl, aHasLocation); |
26 |
} |
|
27 |
|
|
28 | 6 |
public final void globalCheck(IDataContext aContext, IAnyTypeData aData, IAnyTypeData anEnclosingData, IConstraintViolations aViolations) { |
29 | 6 |
for (Iterator i = iterKeys(aData); i.hasNext(); ) { |
30 | 5 |
Object key = i.next(); |
31 | 5 |
if (null != aContext.setIndexedData(IRefs.ID_INDEX, key, aData)) { |
32 | 0 |
aViolations.add(XmlMessages.idAttributeNotUnique(getAttributeRef(), key, aData.getImpl_())); |
33 |
} |
|
34 |
} |
|
35 |
} |
|
36 |
|
|
37 |
protected abstract Iterator iterKeys(IAnyTypeData aData); |
|
38 |
} |
|
39 |
|
|