View Javadoc

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   * $Log: AttributeToolkit.java,v $
43   * Revision 1.1  2003/09/23 20:32:42  tomcopeland
44   * Added Boris Gruschko's new AST/XPath viewer
45   *
46   * Revision 1.1  2003/09/24 01:33:03  bgr
47   * moved to a new package
48   *
49   * Revision 1.1  2003/09/23 07:52:16  bgr
50   * menus added
51   *
52   */