1 package net.sourceforge.pmd.util.viewer.model;
2
3 import net.sourceforge.pmd.jaxen.Attribute;
4
5
6 /***
7 * A toolkit for vaious attribute translations
8 *
9 * @author Boris Gruschko ( boris at gruschko.org )
10 * @version $Id: AttributeToolkit.java,v 1.1 2003/09/23 20:32:42 tomcopeland Exp $
11 */
12 public class AttributeToolkit
13 {
14 /***
15 * formats a value for it's usage in XPath expressions
16 *
17 * @param attribute atribute which value should be formatted
18 *
19 * @return formmated value
20 */
21 public static String formatValueForXPath( Attribute attribute )
22 {
23 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 *
31 * @return predicate
32 */
33 public static String constructPredicate( Attribute attribute )
34 {
35 return "[@" + attribute.getName( ) + "=" +
36 formatValueForXPath( attribute ) + "]";
37 }
38 }
39
40
41
42
43
44
45
46
47
48
49
50
51
52