ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject cvs commit: ant/src/main/org/apache/tools/ant ComponentHelper.java
Date Mon, 23 May 2005 19:27:30 GMT
mbenson     2005/05/23 12:27:30

  Modified:    src/main/org/apache/tools/ant ComponentHelper.java
  Log:
  add brief version of getElementName()
  
  Revision  Changes    Path
  1.55      +24 -6     ant/src/main/org/apache/tools/ant/ComponentHelper.java
  
  Index: ComponentHelper.java
  ===================================================================
  RCS file: /home/cvs/ant/src/main/org/apache/tools/ant/ComponentHelper.java,v
  retrieving revision 1.54
  retrieving revision 1.55
  diff -u -r1.54 -r1.55
  --- ComponentHelper.java	16 May 2005 12:11:44 -0000	1.54
  +++ ComponentHelper.java	23 May 2005 19:27:30 -0000	1.55
  @@ -555,24 +555,42 @@
        * @since Ant 1.6
        */
       public String getElementName(Object element) {
  +        return getElementName(element, false);
  +    }
  +
  +    /**
  +     * Returns a description of the type of the given element.
  +     * <p>
  +     * This is useful for logging purposes.
  +     *
  +     * @param element The element to describe.
  +     *                Must not be <code>null</code>.
  +     * @param brief   whether to use a brief description.
  +     * @return a description of the element type.
  +     *
  +     * @since Ant 1.7
  +     */
  +    public String getElementName(Object element, boolean brief) {
           //  PR: I do not know what to do if the object class
           //      has multiple defines
           //      but this is for logging only...
  +        String name = null;
           Class elementClass = element.getClass();
           for (Iterator i = antTypeTable.values().iterator(); i.hasNext();) {
               AntTypeDefinition def = (AntTypeDefinition) i.next();
               if (elementClass == def.getExposedClass(project)) {
  -                return "The <" + def.getName() + "> type";
  +                name = def.getName();
  +                return brief ? name : "The <" + name + "> type";
               }
           }
  -        return "Class " + elementClass.getName();
  +        name = elementClass.getName();
  +        return brief
  +            ? name.substring(name.lastIndexOf('.') + 1) : "Class " + name;
       }
   
  -
       /**
  -     * Check if definition is a valid definition - it
  -     * may be a definition of an optional task that
  -     * does not exist.
  +     * Check if definition is a valid definition--it may be a
  +     * definition of an optional task that does not exist.
        * @param def the definition to test.
        * @return true if exposed type of definition is present.
        */
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message