ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r494952 - in /ant/core/trunk/src/main/org/apache/tools/ant: ComponentHelper.java Project.java
Date Wed, 10 Jan 2007 19:46:48 GMT
Author: mbenson
Date: Wed Jan 10 11:46:47 2007
New Revision: 494952

URL: http://svn.apache.org/viewvc?view=rev&rev=494952
Log:
move and publish public static Project getProject(Object)

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
    ant/core/trunk/src/main/org/apache/tools/ant/Project.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java?view=diff&rev=494952&r1=494951&r2=494952
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/ComponentHelper.java Wed Jan 10 11:46:47
2007
@@ -579,7 +579,7 @@
      */
     public static String getElementName(Project p, Object o, boolean brief) {
         if (p == null) {
-            p = getProject(o);
+            p = Project.getProject(o);
         }
         return p == null ? getUnmappedElementName(o.getClass(), brief)
                 : getComponentHelper(p).getElementName(o, brief);
@@ -591,21 +591,6 @@
             return name.substring(name.lastIndexOf('.') + 1);
         }
         return c.toString();
-    }
-
-    private static Project getProject(Object o) {
-        if (o instanceof ProjectComponent) {
-            return ((ProjectComponent) o).getProject();
-        }
-        try {
-            Method m = o.getClass().getMethod("getProject", (Class[]) null);
-            if (Project.class == m.getReturnType()) {
-                return (Project) m.invoke(o, (Object[]) null);
-            }
-        } catch (Exception e) {
-            //too bad
-        }
-        return null;
     }
 
     /**

Modified: ant/core/trunk/src/main/org/apache/tools/ant/Project.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/Project.java?view=diff&rev=494952&r1=494951&r2=494952
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/Project.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/Project.java Wed Jan 10 11:46:47 2007
@@ -1652,6 +1652,26 @@
     }
 
     /**
+     * Get the Project instance associated with the specified object.
+     * @return Project instance, if any.
+     * @since Ant 1.7.1
+     */
+    public static Project getProject(Object o) {
+        if (o instanceof ProjectComponent) {
+            return ((ProjectComponent) o).getProject();
+        }
+        try {
+            Method m = o.getClass().getMethod("getProject", (Class[]) null);
+            if (Project.class == m.getReturnType()) {
+                return (Project) m.invoke(o, (Object[]) null);
+            }
+        } catch (Exception e) {
+            //too bad
+        }
+        return null;
+    }
+
+    /**
      * Topologically sort a set of targets.  Equivalent to calling
      * <code>topoSort(new String[] {root}, targets, true)</code>.
      *



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


Mime
View raw message