View Javadoc
1 /* 2 * Copyright (c) 2002-2003 The XDoclet Team. 3 * All rights reserved. 4 */ 5 package xdoclet.util.predicates; 6 7 import xjavadoc.XProgramElement; 8 import xjavadoc.predicates.ProgramElementPredicate; 9 10 /*** 11 * 12 * @author <a href="mailto:aslak.hellesoy at bekk.no">Aslak Hellesøy</a> 13 * @version $Revision: 1.5 $ 14 */ 15 public class HasClassTag extends ProgramElementPredicate { 16 private String _tagName; 17 private String _attributeName; 18 private String _attributeValue; 19 20 public HasClassTag() { 21 } 22 23 public HasClassTag(String tagName) { 24 setTagName(tagName); 25 } 26 27 /*** 28 * Constructs a new HasClassTag. 29 * 30 * @param tagName 31 * @param attributeName 32 * @param attributeValue 33 */ 34 public HasClassTag(String tagName, String attributeName, String attributeValue) { 35 setTagName(tagName); 36 setAttributeName(attributeName); 37 setAttributeValue(attributeValue); 38 } 39 40 public void setTagName(String tagName) { 41 _tagName = tagName; 42 } 43 44 public void setAttributeName(String attributeName) { 45 _attributeName = attributeName; 46 } 47 48 public void setAttributeValue(String attributeValue) { 49 _attributeValue = attributeValue; 50 } 51 52 protected boolean evaluate(XProgramElement programElement) { 53 assert programElement != null; 54 55 boolean result = false; 56 57 if (_tagName == null) { 58 throw new IllegalStateException("tagName must be specified for has-class-tag"); 59 } 60 61 if ((_attributeName == null) && (_attributeValue == null)) { 62 // just see if the tag is there 63 result = programElement.getDoc().hasTag(_tagName); 64 } else if ((_attributeName != null) && (_attributeValue != null)) { 65 // see if the tag attribute is there with the right value 66 return _attributeValue.equals(programElement.getDoc().getTagAttributeValue(_tagName, _attributeName)); 67 68 /* 69 for( Iterator tags = programElement.getDoc().getTags(_tagName).iterator(); tags.hasNext(); ) { 70 XTag tag = (XTag) tags.next(); 71 if( _attributeValue.equals(tag.getAttributeValue(_attributeName)) ) { 72 result = true; 73 break; 74 } 75 } 76 */ 77 } else { 78 throw new IllegalStateException( 79 "Both or none of _attributeName and _attributeValue must be specified for has-class-tag"); 80 } 81 82 return result; 83 } 84 }

This page was automatically generated by Maven