|
|||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| AttributeToolkit.java | - | 0% | 0% | 0% |
|
||||||||||||||
| 1 | package net.sourceforge.pmd.util.viewer.model; | |
| 2 | ||
| 3 | ||
| 4 | import net.sourceforge.pmd.jaxen.Attribute; | |
| 5 | ||
| 6 | ||
| 7 | /** | |
| 8 | * A toolkit for vaious attribute translations | |
| 9 | * | |
| 10 | * @author Boris Gruschko ( boris at gruschko.org ) | |
| 11 | * @version $Id: AttributeToolkit.java,v 1.9 2006/10/20 02:40:14 hooperbloob Exp $ | |
| 12 | */ | |
| 13 | ||
| 14 | public class AttributeToolkit { | |
| 15 | ||
| 16 | /** | |
| 17 | * formats a value for its usage in XPath expressions | |
| 18 | * | |
| 19 | * @param attribute atribute which value should be formatted | |
| 20 | * @return formmated value | |
| 21 | */ | |
| 22 | 0 | public static String formatValueForXPath(Attribute attribute) { |
| 23 | 0 | return '\'' + attribute.getValue() + '\''; |
| 24 | } | |
| 25 | ||
| 26 | /** | |
| 27 | * constructs a predicate from the given attribute | |
| 28 | * | |
| 29 | * @param attribute attribute to be formatted as predicate | |
| 30 | * @return predicate | |
| 31 | */ | |
| 32 | 0 | public static String constructPredicate(Attribute attribute) { |
| 33 | 0 | return "[@" + attribute.getName() + '=' + |
| 34 | formatValueForXPath(attribute) + ']'; | |
| 35 | } | |
| 36 | } |
|
||||||||||