Jaxx-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
October 2010
- 3 participants
- 24 discussions
26 Oct '10
Author: echatellier
Date: 2010-10-26 10:27:03 +0200 (Tue, 26 Oct 2010)
New Revision: 2115
Url: http://nuiton.org/repositories/revision/jaxx/2115
Log:
Add new fatal scope icon
Added:
trunk/jaxx-runtime/src/main/resources/icons/fatal.png
Added: trunk/jaxx-runtime/src/main/resources/icons/fatal.png
===================================================================
(Binary files differ)
Property changes on: trunk/jaxx-runtime/src/main/resources/icons/fatal.png
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
1
0
r2114 - in trunk: . jaxx-compiler jaxx-runtime jaxx-widgets maven-jaxx-plugin
by sletellier@users.nuiton.org 21 Oct '10
by sletellier@users.nuiton.org 21 Oct '10
21 Oct '10
Author: sletellier
Date: 2010-10-21 11:40:02 +0200 (Thu, 21 Oct 2010)
New Revision: 2114
Url: http://nuiton.org/repositories/revision/jaxx/2114
Log:
[maven-release-plugin] prepare for next development iteration
Modified:
trunk/jaxx-compiler/pom.xml
trunk/jaxx-runtime/pom.xml
trunk/jaxx-widgets/pom.xml
trunk/maven-jaxx-plugin/pom.xml
trunk/pom.xml
Modified: trunk/jaxx-compiler/pom.xml
===================================================================
--- trunk/jaxx-compiler/pom.xml 2010-10-21 09:39:55 UTC (rev 2113)
+++ trunk/jaxx-compiler/pom.xml 2010-10-21 09:40:02 UTC (rev 2114)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3</version>
+ <version>2.2.4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2010-10-21 09:39:55 UTC (rev 2113)
+++ trunk/jaxx-runtime/pom.xml 2010-10-21 09:40:02 UTC (rev 2114)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3</version>
+ <version>2.2.4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2010-10-21 09:39:55 UTC (rev 2113)
+++ trunk/jaxx-widgets/pom.xml 2010-10-21 09:40:02 UTC (rev 2114)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3</version>
+ <version>2.2.4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- trunk/maven-jaxx-plugin/pom.xml 2010-10-21 09:39:55 UTC (rev 2113)
+++ trunk/maven-jaxx-plugin/pom.xml 2010-10-21 09:40:02 UTC (rev 2114)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3</version>
+ <version>2.2.4-SNAPSHOT</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-21 09:39:55 UTC (rev 2113)
+++ trunk/pom.xml 2010-10-21 09:40:02 UTC (rev 2114)
@@ -38,7 +38,7 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>2.2.3</version>
+ <version>2.2.4-SNAPSHOT</version>
<modules>
<module>jaxx-runtime</module>
@@ -533,9 +533,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.2.3</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.2.3</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/jaxx/tags/jaxx-2.2.3</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/jaxx/trunk</url>
</scm>
<profiles>
1
0
Author: sletellier
Date: 2010-10-21 11:39:55 +0200 (Thu, 21 Oct 2010)
New Revision: 2113
Url: http://nuiton.org/repositories/revision/jaxx/2113
Log:
[maven-release-plugin] copy for tag jaxx-2.2.3
Added:
tags/jaxx-2.2.3/
1
0
r2112 - in trunk: . jaxx-compiler jaxx-runtime jaxx-widgets maven-jaxx-plugin
by sletellier@users.nuiton.org 21 Oct '10
by sletellier@users.nuiton.org 21 Oct '10
21 Oct '10
Author: sletellier
Date: 2010-10-21 11:39:53 +0200 (Thu, 21 Oct 2010)
New Revision: 2112
Url: http://nuiton.org/repositories/revision/jaxx/2112
Log:
[maven-release-plugin] prepare release jaxx-2.2.3
Modified:
trunk/jaxx-compiler/pom.xml
trunk/jaxx-runtime/pom.xml
trunk/jaxx-widgets/pom.xml
trunk/maven-jaxx-plugin/pom.xml
trunk/pom.xml
Modified: trunk/jaxx-compiler/pom.xml
===================================================================
--- trunk/jaxx-compiler/pom.xml 2010-10-21 09:34:23 UTC (rev 2111)
+++ trunk/jaxx-compiler/pom.xml 2010-10-21 09:39:53 UTC (rev 2112)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3-SNAPSHOT</version>
+ <version>2.2.3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2010-10-21 09:34:23 UTC (rev 2111)
+++ trunk/jaxx-runtime/pom.xml 2010-10-21 09:39:53 UTC (rev 2112)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3-SNAPSHOT</version>
+ <version>2.2.3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2010-10-21 09:34:23 UTC (rev 2111)
+++ trunk/jaxx-widgets/pom.xml 2010-10-21 09:39:53 UTC (rev 2112)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3-SNAPSHOT</version>
+ <version>2.2.3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/maven-jaxx-plugin/pom.xml
===================================================================
--- trunk/maven-jaxx-plugin/pom.xml 2010-10-21 09:34:23 UTC (rev 2111)
+++ trunk/maven-jaxx-plugin/pom.xml 2010-10-21 09:39:53 UTC (rev 2112)
@@ -35,7 +35,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>jaxx</artifactId>
- <version>2.2.3-SNAPSHOT</version>
+ <version>2.2.3</version>
</parent>
<groupId>org.nuiton.jaxx</groupId>
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-21 09:34:23 UTC (rev 2111)
+++ trunk/pom.xml 2010-10-21 09:39:53 UTC (rev 2112)
@@ -38,7 +38,7 @@
</parent>
<artifactId>jaxx</artifactId>
- <version>2.2.3-SNAPSHOT</version>
+ <version>2.2.3</version>
<modules>
<module>jaxx-runtime</module>
@@ -533,9 +533,9 @@
<!-- Source control management. -->
<scm>
- <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</connection>
- <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/trunk</developerConnection>
- <url>http://www.nuiton.org/repositories/browse/jaxx/trunk</url>
+ <connection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.2.3</connection>
+ <developerConnection>scm:svn:http://svn.nuiton.org/svn/jaxx/tags/jaxx-2.2.3</developerConnection>
+ <url>http://www.nuiton.org/repositories/browse/jaxx/tags/jaxx-2.2.3</url>
</scm>
<profiles>
1
0
r2111 - trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable
by sletellier@users.nuiton.org 21 Oct '10
by sletellier@users.nuiton.org 21 Oct '10
21 Oct '10
Author: sletellier
Date: 2010-10-21 11:34:23 +0200 (Thu, 21 Oct 2010)
New Revision: 2111
Url: http://nuiton.org/repositories/revision/jaxx/2111
Log:
Fix remove fire
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableBridge.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableBridge.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableBridge.java 2010-10-17 01:38:04 UTC (rev 2110)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableBridge.java 2010-10-21 09:34:23 UTC (rev 2111)
@@ -131,7 +131,10 @@
throw new IllegalArgumentException("Node " + node + " is not in tree");
}
parent.remove(node);
- model.getModelSupport().fireChildRemoved(getTreePath(parent), index, node);
+
+// It's not enought to fire model support...
+// model.getModelSupport().fireChildRemoved(path, index, node);
+ model.getModelSupport().fireTreeStructureChanged(getTreePath(parent));
}
@Override
1
0
Author: tchemit
Date: 2010-10-17 03:38:04 +0200 (Sun, 17 Oct 2010)
New Revision: 2110
Url: http://nuiton.org/repositories/revision/jaxx/2110
Log:
Update mavenpom4redmineAndCentral to 2.3.2.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-13 15:21:24 UTC (rev 2109)
+++ trunk/pom.xml 2010-10-17 01:38:04 UTC (rev 2110)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.3.1</version>
+ <version>2.3.2</version>
</parent>
<artifactId>jaxx</artifactId>
1
0
r2109 - in trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav: . tree treetable
by sletellier@users.nuiton.org 13 Oct '10
by sletellier@users.nuiton.org 13 Oct '10
13 Oct '10
Author: sletellier
Date: 2010-10-13 17:21:24 +0200 (Wed, 13 Oct 2010)
New Revision: 2109
Url: http://nuiton.org/repositories/revision/jaxx/2109
Log:
Add method to get child with node id
Modified:
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavHelper.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavNode.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/tree/NavTreeNode.java
trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableNode.java
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavHelper.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavHelper.java 2010-10-08 23:50:22 UTC (rev 2108)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavHelper.java 2010-10-13 15:21:24 UTC (rev 2109)
@@ -874,6 +874,24 @@
}
/**
+ * Finds a node from the given root {@code node}, and return child searched
+ *
+ * @param node the starting node
+ * @param id of child searched
+ * @return the find node or {@code null} if no node matchs.
+ */
+ public N getChild(N node, String id) {
+ if (!checkModel()) {
+
+ // no model
+ return null;
+ }
+ N result = node.getChild(id, getBridge(), getDataProvider());
+
+ return result;
+ }
+
+ /**
* Checks if internal model was created.
*
* @return {@code true} if model was created, {@code false} otherwise.
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavNode.java 2010-10-08 23:50:22 UTC (rev 2108)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/NavNode.java 2010-10-13 15:21:24 UTC (rev 2109)
@@ -131,7 +131,7 @@
* <p/>
* If node is NOT {@code loaded}, then first loads it (method
* {@link #populateChilds(NavBridge , NavDataProvider)}) then do search
- * on direct childs of the node.
+ * on direct childs of the node recursivly.
*
* @param id the id of the researched node
* @param bridge model owner of nodes
@@ -143,6 +143,22 @@
NavDataProvider provider);
/**
+ * Given an {@code id}, obtain the child with matching id.
+ * <p/>
+ * If node is NOT {@code loaded}, then first loads it (method
+ * {@link #populateChilds(NavBridge , NavDataProvider)}) then return
+ * on direct childs of the node.
+ *
+ * @param id the id of the researched node
+ * @param bridge model owner of nodes
+ * @param provider data provider
+ * @return the found node or {@code null} if not found
+ */
+ N getChild(String id ,
+ NavBridge<M, N> model,
+ NavDataProvider provider);
+
+ /**
* Changes the {@link #isDirty} state.
* <p/>
* As a side effect, when a renderer will use this node, it will force to
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/tree/NavTreeNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/tree/NavTreeNode.java 2010-10-08 23:50:22 UTC (rev 2108)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/tree/NavTreeNode.java 2010-10-13 15:21:24 UTC (rev 2109)
@@ -188,6 +188,42 @@
}
@Override
+ public N getChild(String id ,
+ NavBridge<DefaultTreeModel, N> model,
+ NavDataProvider provider) {
+
+ if (id == null) {
+
+ // id null ? donc rien a faire
+ return null;
+ }
+
+ if (!isLoaded()) {
+
+ // il faut charger les fils du noeud pour effectuer la recherche
+ populateChilds(model, provider);
+ }
+
+ if (isLeaf()) {
+
+ // au final le noeud est une feuille, donc ne convient pas
+ return null;
+ }
+
+ // on recherche dans les fils
+ Enumeration<N> enumeration = children();
+ while (enumeration.hasMoreElements()) {
+ N child = enumeration.nextElement();
+ if (id.equals(child.getId())) {
+ return child;
+ }
+ }
+
+ // aucun des noeud fils ne convient
+ return null;
+ }
+
+ @Override
public void setDirty(boolean dirty) {
this.dirty = dirty;
}
Modified: trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableNode.java
===================================================================
--- trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableNode.java 2010-10-08 23:50:22 UTC (rev 2108)
+++ trunk/jaxx-runtime/src/main/java/jaxx/runtime/swing/nav/treetable/NavTreeTableNode.java 2010-10-13 15:21:24 UTC (rev 2109)
@@ -196,6 +196,42 @@
}
@Override
+ public N getChild(String id ,
+ NavBridge<NavTreeTableModel, N> model,
+ NavDataProvider provider) {
+
+ if (id == null) {
+
+ // id null ? donc rien a faire
+ return null;
+ }
+
+ if (!isLoaded()) {
+
+ // il faut charger les fils du noeud pour effectuer la recherche
+ populateChilds(model, provider);
+ }
+
+ if (isLeaf()) {
+
+ // au final le noeud est une feuille, donc ne convient pas
+ return null;
+ }
+
+ // on recherche dans les fils
+ Enumeration<N> enumeration = children();
+ while (enumeration.hasMoreElements()) {
+ N node = enumeration.nextElement();
+ if (id.equals(node.getId())) {
+ return node;
+ }
+ }
+
+ // aucun des noeud fils ne convient
+ return null;
+ }
+
+ @Override
public void setDirty(boolean dirty) {
this.dirty = dirty;
}
1
0
Author: tchemit
Date: 2010-10-09 01:50:22 +0200 (Sat, 09 Oct 2010)
New Revision: 2108
Url: http://nuiton.org/repositories/revision/jaxx/2108
Log:
Update mavenpom4redmineAndCentral to 2.3.1.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-05 08:55:56 UTC (rev 2107)
+++ trunk/pom.xml 2010-10-08 23:50:22 UTC (rev 2108)
@@ -34,7 +34,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmineAndCentral</artifactId>
- <version>2.3</version>
+ <version>2.3.1</version>
</parent>
<artifactId>jaxx</artifactId>
1
0
r2107 - in trunk/jaxx-compiler/src: main/java/jaxx/compiler/reflect test/java/jaxx/compiler/reflect test/java/jaxx/compiler/reflect/resolvers
by tchemit@users.nuiton.org 05 Oct '10
by tchemit@users.nuiton.org 05 Oct '10
05 Oct '10
Author: tchemit
Date: 2010-10-05 10:55:56 +0200 (Tue, 05 Oct 2010)
New Revision: 2107
Url: http://nuiton.org/repositories/revision/jaxx/2107
Log:
Evolution #915: Remove deprecated api from 2.0.2 (JavaFileParser and ClassDescriptorLoader)
Removed:
trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java
trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java
trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/JavaFileParserTest.java
Modified:
trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/resolvers/ClassDescriptorResolverFromJavaFileTest.java
Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2010-10-05 08:37:01 UTC (rev 2106)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2010-10-05 08:55:56 UTC (rev 2107)
@@ -1,648 +0,0 @@
-/*
- * #%L
- * JAXX :: Compiler
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package jaxx.compiler.reflect;
-
-import jaxx.compiler.CompilerException;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXEngine;
-import jaxx.compiler.JAXXFactory;
-import jaxx.compiler.SymbolTable;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXObjectDescriptor;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.net.URL;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-/**
- * Mirrors the class <code>java.lang.ClassLoader</code>. JAXX uses <code>ClassDescriptor</code> instead of <code>Class</code>
- * almost everywhere so that it can handle circular dependencies (there can't be a <code>Class</code> object for an uncompiled
- * JAXX or Java source file, and a compiler must be allow references to symbols in uncompiled source files in order to handle
- * circular dependencies).
- *
- * @deprecated since 2.0.2, prefer use the more efficient {@link ClassDescriptorHelper}.
- */
-@Deprecated
-public class ClassDescriptorLoader {
-
- /** Logger */
- private static final Log log = LogFactory.getLog(ClassDescriptorLoader.class);
-
- private static Map<String, ClassDescriptor> descriptors =
- new HashMap<String, ClassDescriptor>();
-
- private ClassDescriptorLoader() {
- // on instance
- }
-
- public static ClassDescriptor getClassDescriptor(
- String className) throws ClassNotFoundException {
-
- ClassDescriptor descriptor = getClassDescriptor(
- className,
- Thread.currentThread().getContextClassLoader()
- );
- return descriptor;
- }
-
- public static ClassDescriptor getClassDescriptor(
- String className,
- ClassLoader classLoader) throws ClassNotFoundException {
-
- ClassDescriptor result = descriptors.get(className);
- if (result != null) {
- return result;
- }
-
- JAXXEngine engine = JAXXFactory.isEngineRegistred() ?
- JAXXFactory.getEngine() : null;
-
- if (engine != null) {
-
- SymbolTable symbolTable = engine.getSymbolTable(className);
-
- if (symbolTable != null) {
-
- log.info("<<< from symbol table [" + className + "]");
-
- JAXXCompiler compiler = engine.getJAXXCompiler(className);
-
- result = createClassDescriptorFromSymbolTable(
- compiler,
- className,
- classLoader
- );
- descriptors.put(className, result);
- return result;
- }
- }
-
- // the class is not in this compile set, try to have it from java
- // sources or classes.
-
- if (classLoader == null) {
- classLoader = ClassDescriptorLoader.class.getClassLoader();
- }
-
- String relativePath = className.replaceAll("\\.", "/");
- String relativePathPattern = ".*";// + className + ".*"; // used to ensure that the located resource has the right character cases
-
- // find the most recently updated source for the class -- Java source, JAXX source, or compiled class file
- long javaLastModified = -1;
- URL javaFile = classLoader.getResource(relativePath + ".java");
- if (javaFile != null &&
- javaFile.toString().startsWith("file:") &&
- javaFile.toString().matches(relativePathPattern)) {
- javaLastModified = JAXXCompiler.URLtoFile(javaFile).lastModified();
- log.info("[" + className + "] javaFile lastModified " + javaLastModified);
- }
-
- long classLastModified = -1;
- URL classFile = classLoader.getResource(relativePath + ".class");
- if (classFile != null &&
- classFile.toString().startsWith("file:") &&
- classFile.toString().matches(relativePathPattern)) {
- classLastModified = JAXXCompiler.URLtoFile(classFile).lastModified();
- log.info("[" + className + "] class lastModified " + classLastModified);
- }
-
- long jaxxLastModified = -1;
- URL jaxxFile = classLoader.getResource(relativePath + ".jaxx");
- if (jaxxFile != null &&
- jaxxFile.toString().startsWith("file:") &&
- jaxxFile.toString().matches(relativePathPattern)) {
- File jaxxFilePath = JAXXCompiler.URLtoFile(jaxxFile);
- jaxxLastModified = jaxxFilePath.lastModified();
- String simplePath = jaxxFilePath.getPath();
- simplePath = simplePath.substring(0, simplePath.length() - ".jaxx".length());
- File cssFilePath = new File(simplePath + ".css");
- if (cssFilePath.exists()) {
- jaxxLastModified = Math.max(jaxxLastModified, cssFilePath.lastModified());
- }
- File scriptFilePath = new File(simplePath + ".script");
- if (scriptFilePath.exists()) {
- jaxxLastModified = Math.max(jaxxLastModified, scriptFilePath.lastModified());
- }
- log.info("[" + className + "] jaxxFile lastModified " + jaxxLastModified);
- }
-
- if (classLastModified != -1) {
-
- // there is a class
-
- if (classLastModified >= javaLastModified && classLastModified >= jaxxLastModified) {
-
- // ok class is up to date, choose it
- Class<?> javaClass = getClass(className, classLoader);
-
- log.debug("<<< from class [" + className + "] " + javaClass);
-
- result = createClassDescriptorFromClass(javaClass);
- descriptors.put(className, result);
- return result;
- }
-
- // the class is not the last modified resource, do not use it
- }
-
-// if (jaxxLastModified != -1) {
-//
-// // there is a jaxx file, use it
-//
-// File jaxxFilePath = JAXXCompiler.URLtoFile(jaxxFile);
-//
-// JAXXCompilerFile file = new JAXXCompilerFile(jaxxFilePath, className);
-//
-// engine.addFileToCompile(jaxxFilePath, className);
-//
-// JAXXCompiler compiler = engine.getJAXXCompiler(className);
-//
-// result = createClassDescriptorFromSymbolTable(
-// compiler,
-// className,
-// classLoader
-// );
-// // result = createClassDescriptorFromSymbolTable(className, classLoader);
-// descriptors.put(className, result);
-// return result;
-// }
-
- if (javaLastModified != -1) {
-
- // there is a java source
-
- if (javaLastModified > jaxxLastModified) {
-
- log.info("<<< from java file [" + className + "] " + javaFile);
-
- // ok java source is up to date, choose it
- result = createClassDescriptorFromJavaSource(javaFile, classLoader);
-
- descriptors.put(className, result);
-// }
- return result;
- }
-
- // the java source is not the last modified resource, do not use it
-
- }
-
-
- // last fall back for class
- Class<?> javaClass = getClass(className, classLoader);
-
- log.debug("<<< from class [" + className + "] " + javaClass);
-
- result = createClassDescriptorFromClass(javaClass);
-
- if (result != null) {
- descriptors.put(className, result);
- return result;
- }
-
- // can NOT come here, means could not find result...
-
- throw new IllegalStateException("Can not find descriptor for " + className);
-//
-// if (jaxxLastModified != -1 && JAXXFactory.isEngineRegistred() && symbolTable == null) {
-// jaxxLastModified = -1; // file has been modified, but wasn't included in this
-// }
-// // compilation set so we don't have a symbol table
-//
-// if (javaLastModified != -1 || classLastModified != -1 || jaxxLastModified != -1) {
-//
-// if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified) {
-// result = createClassDescriptorFromJavaSource(javaFile, classLoader);
-// }
-//// if (jaxxLastModified > classLastModified && jaxxLastModified > javaLastModified) {
-//// result = createClassDescriptorFromSymbolTable(className, classLoader);
-//// } else if (javaLastModified > classLastModified && javaLastModified > jaxxLastModified) {
-//// result = createClassDescriptorFromJavaSource(javaFile, classLoader);
-//// }
-// }
-// // else work off of the class file. This also handles the case where
-// // the class is available, but wasn't in a location where
-// // we could check its last modified date (in a JAR, over the network, etc.)
-// if (result == null) {
-// Class<?> javaClass = getClass(className, classLoader);
-// result = createClassDescriptorFromClass(javaClass);
-// }
-// descriptors.put(className, result);
-//// }
-// return result;
- }
-
- @Deprecated
- public static ClassDescriptor getClassDescriptor(Class<?> javaClass) {
- return ClassDescriptorHelper.getClassDescriptor(javaClass);
-// try {
-// return getClassDescriptor(
-// javaClass.getName(),
-// javaClass.getClassLoader()
-// );
-// } catch (ClassNotFoundException e) {
-// throw new RuntimeException(e);
-// }
- }
-
- @Deprecated
- public static Class<?> getPrimitiveBoxedClass(String className) {
- return ClassDescriptorHelper.getPrimitiveBoxedClass(className);
-// if (className.equals("boolean")) {
-// return Boolean.class;
-// }
-// if (className.equals("byte")) {
-// return Byte.class;
-// }
-// if (className.equals("short")) {
-// return Short.class;
-// }
-// if (className.equals("int")) {
-// return Integer.class;
-// }
-// if (className.equals("long")) {
-// return Long.class;
-// }
-// if (className.equals("float")) {
-// return Float.class;
-// }
-// if (className.equals("double")) {
-// return Double.class;
-// }
-// if (className.equals("char")) {
-// return Character.class;
-// }
-// if (className.equals("void")) {
-// return Void.class;
-// }
-// return null;
- }
-
- @Deprecated
- public static Class<?> getPrimitiveClass(
- String className) throws ClassNotFoundException {
- return ClassDescriptorHelper.getPrimitiveClass(className);
-// if (className.equals("boolean")) {
-// return boolean.class;
-// }
-// if (className.equals("byte")) {
-// return byte.class;
-// }
-// if (className.equals("short")) {
-// return short.class;
-// }
-// if (className.equals("int")) {
-// return int.class;
-// }
-// if (className.equals("long")) {
-// return long.class;
-// }
-// if (className.equals("float")) {
-// return float.class;
-// }
-// if (className.equals("double")) {
-// return double.class;
-// }
-// if (className.equals("char")) {
-// return char.class;
-// }
-// if (className.equals("void")) {
-// return void.class;
-// }
-// // detect arrays
-// int arrayCount = 0;
-// while (className.endsWith("[]")) {
-// arrayCount++;
-// className = className.substring(0, className.length() - 2);
-// }
-// Class<?> klass;
-// if (arrayCount > 0) {
-// klass = getPrimitiveClass(className);
-// if (klass == null) {
-// // none primitive array
-// return null;
-// }
-// // must take the boxed class, other it does not works
-// // to make a Class.forName("[Lchar;"); but works
-// // with Class.forName("[LCharacter;"); ...
-// klass = getPrimitiveBoxedClass(className);
-// className = klass.getName();
-//
-// className = "L" + className + ";";
-// while (arrayCount > 0) {
-// className = "[" + className;
-// arrayCount--;
-// }
-// //System.out.println("primitive array class "+className);
-// return Class.forName(className);
-// }
-// return null;
- }
-
- @Deprecated
- public static Class<?> getClass(String className,
- ClassLoader classLoader) throws ClassNotFoundException {
- return ClassDescriptorHelper.getClass(className, classLoader);
-// Class<?> klass = getPrimitiveClass(className);
-// if (klass != null) {
-// return klass;
-// }
-// // try an array of none primitive classes
-// int arrayCount = 0;
-// while (className.endsWith("[]")) {
-// arrayCount++;
-// className = className.substring(0, className.length() - 2);
-// }
-// if (arrayCount > 0) {
-// className = "L" + className + ";";
-// while (arrayCount > 0) {
-// className = "[" + className;
-// arrayCount--;
-// }
-// }
-// try {
-// return classLoader != null ?
-// Class.forName(className, true, classLoader) :
-// Class.forName(className);
-//
-// } catch (ClassNotFoundException e) {
-// // perharps we are in a inner class ?
-// int dotIndex = className.lastIndexOf(".");
-// if (dotIndex > -1) {
-// String parentFQN = className.substring(0, dotIndex);
-// String simpleName = className.substring(dotIndex + 1);
-// try {
-// Class<?> parentClass = classLoader != null ? Class.forName(parentFQN, true, classLoader) : Class.forName(parentFQN);
-// for (Class<?> innerClass : parentClass.getClasses()) {
-// if (simpleName.equals(innerClass.getSimpleName())) {
-// return innerClass;
-// }
-// }
-// } catch (ClassNotFoundException e1) {
-// // no super class,so let the first exception throw...
-// }
-// }
-// throw e;
-// } catch (NoClassDefFoundError e) {
-//
-// throw new ClassNotFoundException(e.toString());
-// }
- }
-
- private static MethodDescriptor createMethodDescriptor(Method javaMethod,
- ClassLoader classLoader) {
- String methodName = javaMethod.getName();
- int modifiers = javaMethod.getModifiers();
- String returnType = javaMethod.getReturnType().getName();
- Class<?>[] javaParameters = javaMethod.getParameterTypes();
- String[] parameters = new String[javaParameters.length];
- for (int i = 0; i < parameters.length; i++) {
- parameters[i] = javaParameters[i].getName();
- }
- return new MethodDescriptor(methodName, modifiers, returnType, parameters, classLoader);
- }
-
- private static FieldDescriptor createFieldDescriptor(Field javaField,
- ClassLoader classLoader) {
- String fieldName = javaField.getName();
- int modifiers = javaField.getModifiers();
- String type = javaField.getType().getName();
- return new FieldDescriptor(fieldName, modifiers, type, classLoader);
- }
-
- private static JAXXObjectDescriptor getJAXXObjectDescriptor(Class<?> jaxxClass) {
- if (!JAXXObject.class.isAssignableFrom(jaxxClass) ||
- JAXXObject.class.equals(jaxxClass)) {
- return null;
- }
- try {
- Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor");
- return (JAXXObjectDescriptor) getJAXXObjectDescriptor.invoke(null);
- } catch (NoSuchMethodException e) {
- throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + " to have a static method named $getJAXXObjectDescriptor");
- } catch (IllegalAccessException e) {
- throw new CompilerException("Expected JAXXObject " + jaxxClass.getName() + "'s $getJAXXObjectDescriptor method to be public");
- } catch (InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-
- private static ClassDescriptor createClassDescriptorFromJavaSource(URL javaSource, ClassLoader classLoader) throws ClassNotFoundException {
- try {
- InputStream in = javaSource.openStream();
- ClassDescriptor result = null;
- Reader reader = new InputStreamReader(in, "utf-8");
- try {
- if (log.isDebugEnabled()) {
- log.debug("for source " + javaSource);
- }
- result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, classLoader);
- } finally {
-
- reader.close();
- }
- return result;
- } catch (IOException e) {
- throw new ClassNotFoundException(e.toString());
- }
- }
-
- private static ClassDescriptor createClassDescriptorFromSymbolTable(
- final JAXXCompiler compiler,
- String className,
- ClassLoader classLoader) throws ClassNotFoundException {
-
- final SymbolTable symbolTable = compiler.getSymbolTable();
-// final JAXXCompiler compiler = JAXXFactory.getEngine().getJAXXCompiler(className);
-// final SymbolTable symbolTable = JAXXFactory.getEngine().getSymbolTable(className);
- if (symbolTable == null) {
- throw new CompilerException("Internal error: no symbol table was generated for class '" + className + "'");
- }
- if (log.isDebugEnabled()) {
- log.debug("for compiler " + compiler.getOutputClassName());
- }
- ClassDescriptor superclass = getClassDescriptor(symbolTable.getSuperclassName(), classLoader);
- List<MethodDescriptor> publicMethods = symbolTable.getScriptMethods();
- List<FieldDescriptor> publicFields = symbolTable.getScriptFields();
- //List<MethodDescriptor> declaredMethods = new ArrayList<MethodDescriptor>(publicMethods);
- //List<FieldDescriptor> declaredFields = new ArrayList<FieldDescriptor>(publicFields);
- Iterator<MethodDescriptor> methods = publicMethods.iterator();
- while (methods.hasNext()) {
- MethodDescriptor method = methods.next();
- if (!Modifier.isPublic(method.getModifiers())) {
- methods.remove();
- }
- }
- Iterator<FieldDescriptor> fields = publicFields.iterator();
- while (fields.hasNext()) {
- FieldDescriptor field = fields.next();
- if (!Modifier.isPublic(field.getModifiers())) {
- fields.remove();
- }
- }
- Set<String> interfaces = new HashSet<String>();
- if (symbolTable.getInterfaces() != null) {
- // having interfaces
- for (String anInterface : symbolTable.getInterfaces()) {
- int genericIndex = anInterface.indexOf("<");
- if (genericIndex > -1) {
- // remove generic type
- anInterface = anInterface.substring(0, genericIndex);
- }
- if (log.isDebugEnabled()) {
- log.debug("getting interface " + anInterface + " descriptor for class " + className);
- }
- interfaces.add(anInterface);
- ClassDescriptor interfaceclass = getClassDescriptor(anInterface, classLoader);
- publicMethods.addAll(Arrays.asList(interfaceclass.getMethodDescriptors()));
- publicFields.addAll(Arrays.asList(interfaceclass.getFieldDescriptors()));
- }
- }
- publicMethods.addAll(Arrays.asList(superclass.getMethodDescriptors()));
- publicFields.addAll(Arrays.asList(superclass.getFieldDescriptors()));
- int dotPos = className.lastIndexOf(".");
- String packageName = dotPos != -1 ? className.substring(0, dotPos) : null;
-
- ClassDescriptor[] superclassInterfaces = superclass.getInterfaces();
- for (ClassDescriptor superclassInterface : superclassInterfaces) {
- interfaces.add(superclassInterface.getName());
- }
- interfaces.add(JAXXObject.class.getName());
- return new ClassDescriptor(className, packageName, symbolTable.getSuperclassName(),
- interfaces.toArray(new String[interfaces.size()]), false, false, null, null, classLoader,
- publicMethods.toArray(new MethodDescriptor[publicMethods.size()]),
- publicFields.toArray(new FieldDescriptor[publicFields.size()])) {
-
- @Override
- public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
- String type = symbolTable.getClassTagIds().get(name);
- if (type != null) {
- return new FieldDescriptor(name, Modifier.PROTECTED, type, compiler.getClassLoader());
- }
- throw new NoSuchFieldException(name);
- }
-
- @Override
- public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
- throw new NoSuchMethodException(name);
- }
-
- @Override
- public JAXXObjectDescriptor getJAXXObjectDescriptor() {
- return compiler.getJAXXObjectDescriptor();
- }
- };
- }
-
- private static ClassDescriptor createClassDescriptorFromClass(final Class<?> javaClass) {
- String name = javaClass.getName();
- Package p = javaClass.getPackage();
- String packageName = p != null ? p.getName() : null;
- Class<?> superclass = javaClass.getSuperclass();
- String superclassName = superclass != null ? superclass.getName() : null;
- Class<?>[] interfaces = javaClass.getInterfaces();
- String[] interfaceNames = new String[interfaces.length];
- for (int i = 0; i < interfaces.length; i++) {
- interfaceNames[i] = interfaces[i].getName();
- }
- boolean isInterface = javaClass.isInterface();
- boolean isArray = javaClass.isArray();
- String componentTypeName = isArray ? javaClass.getComponentType().getName() : null;
- JAXXObjectDescriptor jaxxObjectDescriptor = getJAXXObjectDescriptor(javaClass);
- ClassLoader classLoader = javaClass.getClassLoader();
- Method[] javaMethods = javaClass.getMethods();
- MethodDescriptor[] methods = new MethodDescriptor[javaMethods.length];
- for (int i = 0; i < methods.length; i++) {
- methods[i] = createMethodDescriptor(javaMethods[i], javaClass.getClassLoader());
- }
- Field[] javaFields = javaClass.getFields();
- FieldDescriptor[] fields = new FieldDescriptor[javaFields.length];
- for (int i = 0; i < fields.length; i++) {
- fields[i] = createFieldDescriptor(javaFields[i], javaClass.getClassLoader());
- }
- return new ClassDescriptor(name, packageName,
- superclassName,
- interfaceNames,
- isInterface,
- isArray,
- componentTypeName,
- jaxxObjectDescriptor,
- classLoader,
- methods,
- fields) {
-
- @Override
- public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
- return createFieldDescriptor(javaClass.getDeclaredField(name),
- javaClass.getClassLoader()
- );
- }
-
- @Override
- public MethodDescriptor getDeclaredMethodDescriptor(String name,
- ClassDescriptor... parameterTypes) throws NoSuchMethodException {
- try {
- Class<?>[] parameterTypeClasses = new Class[parameterTypes.length];
- for (int i = 0; i < parameterTypes.length; i++) {
- parameterTypeClasses[i] = Class.forName(parameterTypes[i].getName());
- }
- return createMethodDescriptor(javaClass.getDeclaredMethod(name, parameterTypeClasses), javaClass.getClassLoader());
- } catch (ClassNotFoundException e) {
- throw new RuntimeException(e);
- }
- }
- };
- }
-
- public static void checkSupportClass(Class<?> handlerClass, ClassDescriptor beanClass, Class<?>... tagClasses) {
- for (Class<?> tagClass : tagClasses) {
- if (getClassDescriptor(tagClass).isAssignableFrom(beanClass)) {
- return;
- }
- }
- throw new IllegalArgumentException(handlerClass.getName() + " does not support the class " + beanClass.getName());
- }
-
- public static void reset() {
- descriptors.clear();
- }
-}
Deleted: trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java
===================================================================
--- trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2010-10-05 08:37:01 UTC (rev 2106)
+++ trunk/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2010-10-05 08:55:56 UTC (rev 2107)
@@ -1,573 +0,0 @@
-/*
- * #%L
- * JAXX :: Compiler
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package jaxx.compiler.reflect;
-
-import jaxx.compiler.CompilerException;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXFactory;
-import jaxx.compiler.java.parser.JavaParser;
-import jaxx.compiler.java.parser.JavaParserTreeConstants;
-import jaxx.compiler.java.parser.ParseException;
-import jaxx.compiler.java.parser.SimpleNode;
-import jaxx.compiler.tags.TagManager;
-import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.runtime.JAXXUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.Reader;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-/**
- * @deprecated since 2.0.2, now use the {@link ClassDescriptorHelper} to obtain
- * descriptors from java source files.
- */
-@Deprecated
-public class JavaFileParser {
-
- /** Logger */
- static private final Log log = LogFactory.getLog(JavaFileParser.class);
-
- /**
- * the compiler used (this is a dummy compiler with no link with any file).
- * <p/>
- * FIXME-TC20100504 We should remove this link : should not need of a
- * compiler to parse a java files.
- */
- private JAXXCompiler compiler;
-
- /** fully qualified name of the class */
- private String className;
-
- /** package of the class */
- private String packageName;
-
- /** fully qualified name of the super class or {@code null} if no super class. */
- private String superclass;
-
- /**
- * flag to known if we deal with an enum (the state is setted in the
- * {@link #doParse(String, Reader)} method).
- */
- private boolean isEnum;
-
- /**
- * flag to known if we deal with an interface(the state is setted in the
- * {@link #doParse(String, Reader)} method).
- */
- private boolean isInterface;
-
- /** set of fully qualified names of interfaces of the class. */
- private Set<String> interfaces;
-
- /** public methods of the class */
- private List<MethodDescriptor> methods;
-
- /** public fields of the class */
- private List<FieldDescriptor> fields;
-
- /** none public fields of the class */
- private List<FieldDescriptor> declaredFields;
-
- /**
- * If sets, compressed value of the $jaxxObjectDescriptor field, this means
- * the class if a JAXXObject implementation.
- */
- private String jaxxObjectDescriptorValue;
-
- public static final String[] EMPTY_STRING_ARRAY = new String[0];
-
- private JavaFileParser(ClassLoader classLoader) {
- //FIXME-TC-20100504 : shoudl remove this to make the parser free of jaxx :)
- // We could imagine just to offers to the parser a list of namespaces
- // (for class resolving)...
- compiler = JAXXFactory.newDummyCompiler(classLoader);
- methods = new ArrayList<MethodDescriptor>();
- interfaces = new HashSet<String>();
- fields = new ArrayList<FieldDescriptor>();
- declaredFields = new ArrayList<FieldDescriptor>();
- superclass = Object.class.getName();
- }
-
- public static ClassDescriptor parseJavaFile(
- String displayName,
- Reader src,
- ClassLoader classLoader) throws ClassNotFoundException {
- //FIXME-TC20091205 : no now JAXX can look to interfaces, must add them
- // has some limitations -- it reports all members as public, leaves getDeclaredMethod and getDeclaredField
- // undefined, and doesn't report interfaces. It's safe to leave those the way they are for now, because
- // JAXX doesn't look at any of those for non-JAXX classes.
- JavaFileParser parser = new JavaFileParser(classLoader);
- if (log.isDebugEnabled()) {
- log.debug("starting parsing : " + displayName);
- }
- try {
- parser.doParse(displayName, src);
- } catch (Exception e) {
- log.error(e.getMessage());
- throw new RuntimeException(e);
- }
-
- JAXXObjectDescriptor jaxxObjectDescriptor = null;
-
- if (parser.jaxxObjectDescriptorValue != null) {
-
- // compute the jaxx object descriptor
-
- jaxxObjectDescriptor = JAXXUtil.decodeCompressedJAXXObjectDescriptor(
- parser.jaxxObjectDescriptorValue
- );
- }
-
- List<MethodDescriptor> publicMethods = parser.methods;
- List<FieldDescriptor> publicFields = parser.fields;
- List<FieldDescriptor> declaredFields = parser.declaredFields;
- //List/*<MethodDescriptor>*/ declaredMethods = new ArrayList/*<MethodDescriptor>*/(publicMethods);
- //List/*<FieldDescriptor>*/ declaredFields = new ArrayList/*<FieldDescriptor>*/(publicFields);
- Iterator<MethodDescriptor> methods = publicMethods.iterator();
- while (methods.hasNext()) {
- MethodDescriptor method = methods.next();
- if (!Modifier.isPublic(method.getModifiers())) {
- methods.remove();
- }
- }
- Iterator<FieldDescriptor> fields = publicFields.iterator();
- while (fields.hasNext()) {
- FieldDescriptor field = fields.next();
- if (!Modifier.isPublic(field.getModifiers())) {
- fields.remove();
- }
- }
-
- if (parser.superclass != null) {
- //FIXME-TC20100504 This is not good, should add nothing here
- // and modify the algorithm of ClassDescriptor to go and seek
- // in super classes on interfaces if required.
- ClassDescriptor superclassDescriptor = ClassDescriptorHelper.getClassDescriptor(parser.superclass, classLoader);
- publicMethods.addAll(Arrays.asList(superclassDescriptor.getMethodDescriptors()));
- publicFields.addAll(Arrays.asList(superclassDescriptor.getFieldDescriptors()));
- }
- //FIXME-TC20091205 : now JAXX can look to interfaces, must add them
- //Set<String> interfaces = new HashSet<String>();
- //ClassDescriptor[] superclassInterfaces = superclassDescriptor.getInterfaces();
- //for (ClassDescriptor superclassInterface : superclassInterfaces) {
- //interfaces.add(superclassInterface.getName());
- //}
- String[] interfaces = parser.interfaces.toArray(new String[parser.interfaces.size()]);
- return new ClassDescriptor(parser.className,
- parser.packageName,
- parser.superclass,
- interfaces,
- parser.isInterface,
- false,
- null,
- jaxxObjectDescriptor,
- classLoader,
- publicMethods.toArray(new MethodDescriptor[publicMethods.size()]),
- publicFields.toArray(new FieldDescriptor[publicFields.size()]),
- declaredFields.toArray(new FieldDescriptor[declaredFields.size()])
- ) {
-// publicFields.toArray(new FieldDescriptor[publicFields.size()])) {
-
- @Override
- public FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException {
- for (FieldDescriptor descriptor : declaredFieldDescriptors) {
- if (name.equals(descriptor.getName())) {
- log.info("Using a declared field descriptor [" + name + "] for " + getName());
- return descriptor;
- }
- }
- throw new NoSuchFieldException(name);
- }
-
- @Override
- public MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
- throw new NoSuchMethodException(name);
- }
- };
- }
-
- private void doParse(String displayName, Reader src) {
- try {
- JavaParser p = new JavaParser(src);
- p.CompilationUnit();
- SimpleNode node = p.popNode();
- if (node != null) {
- scanCompilationUnit(node);
- return;
- }
- throw new CompilerException("Internal error: null node parsing Java file from " + src);
- } catch (ParseException e) {
- throw new CompilerException("Error parsing Java source code " + displayName + ": " + e.getMessage());
- } finally {
- if (isInterface) {
-
- // remove super class
- superclass = null;
- }
-
- if (isEnum) {
-
- // super class is always Enum
-
- superclass = Enum.class.getName();
- }
- }
- }
-
- private void scanCompilationUnit(SimpleNode node) {
- for (int i = 0; i < node.jjtGetNumChildren(); i++) {
- SimpleNode child = node.getChild(i);
- scanCompilationUnitChild(child);
- }
- }
-
- private void scanCompilationUnitChild(SimpleNode child) {
- int nodeType = child.getId();
- switch (nodeType) {
- case JavaParserTreeConstants.JJTPACKAGEDECLARATION:
- packageName = child.getChild(1).getText().trim();
- compiler.addImport(packageName + ".*");
-
- // add implicit java.lnag namespace available
- compiler.addImport("java.lang.*");
- break;
- case JavaParserTreeConstants.JJTIMPORTDECLARATION:
- String text = child.getText().trim();
- if (text.startsWith("import")) {
- text = text.substring("import".length()).trim();
- }
- if (text.endsWith(";")) {
- text = text.substring(0, text.length() - 1);
- }
- if (log.isDebugEnabled()) {
- log.debug("import " + text);
- }
- compiler.addImport(text);
- break;
- case JavaParserTreeConstants.JJTTYPEDECLARATION:
- scanCompilationUnit(child);
- break;
-
- case JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION:
- isInterface = child.firstToken.image.equals("interface");
- scanClass(child);
- case JavaParserTreeConstants.JJTENUMDECLARATION:
- isEnum = child.firstToken.image.equals("enum");
- scanClass(child);
- break;
- }
- }
-
- // scans the main ClassOrInterfaceDeclaration
-
- private void scanClass(SimpleNode node) {
-// boolean isInterface = node.firstToken.image.equals("interface");
- className = node.firstToken.next.image;
- if (packageName != null) {
- className = packageName + "." + className;
- }
- for (int i = 0; i < node.jjtGetNumChildren(); i++) {
- SimpleNode child = node.getChild(i);
- int nodeType = child.getId();
-
- if (nodeType == JavaParserTreeConstants.JJTIMPLEMENTSLIST) {
-
- if (log.isDebugEnabled()) {
- log.debug("[" + className + "] Found a implements list " + child + " :: " + child.jjtGetNumChildren());
- }
- // obtain interfaces
- for (int j = 0; j < child.jjtGetNumChildren(); j++) {
- String rawName = child.getChild(j).getText().trim();
-
- addInterface(rawName);
- }
- continue;
- }
- if (nodeType == JavaParserTreeConstants.JJTEXTENDSLIST) {
-
- if (isInterface) {
-
- // obtain interfaces
- for (int j = 0; j < child.jjtGetNumChildren(); j++) {
- String rawName = child.getChild(j).getText().trim();
-
- addInterface(rawName);
- }
- continue;
- }
- // this is an extends
- assert child.jjtGetNumChildren() == 1 : "expected ExtendsList to have exactly one child for a non-interface class";
- String rawName = child.getChild(0).getText().trim();
- superclass = TagManager.resolveClassName(rawName, compiler);
- if (superclass == null) {
- throw new CompilerException("Could not find class: " + rawName);
- }
- if (log.isDebugEnabled()) {
- log.debug("Set superClass = " + superclass);
- }
- } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEBODY) {
- scanClassNode(child);
- }
- }
- }
-
- protected void addInterface(String rawName) {
- if (rawName.contains("<")) {
-
- // generic type
- rawName = rawName.substring(0, rawName.indexOf("<"));
- }
- if (log.isDebugEnabled()) {
- log.debug("[" + className + "] try to obtain type of interface " + rawName);
- }
-
- String myInterface = resolveFullyQualifiedName(rawName);
- if (myInterface == null) {
- throw new CompilerException("Could not find interface: " + myInterface);
- }
- if (!interfaces.contains(myInterface)) {
- if (log.isDebugEnabled()) {
- log.debug("[" + className + "] add interface " + myInterface);
- }
- interfaces.add(myInterface);
- }
- }
-
- protected String resolveFullyQualifiedName(String rawName) {
- String result;
-
- String realRawName = null;
- String realParentRawName = null;
- if (rawName.contains(".")) {
- // this is a inner class
- int index = rawName.lastIndexOf(".");
- realParentRawName = rawName.substring(0, index);
- realRawName = rawName.substring(index + 1);
-
- log.info("inner class detected ? " + realParentRawName + "//" + realRawName);
- }
-
- log.info("try fqn = " + rawName);
- result = TagManager.resolveClassName(rawName, compiler);
-
- if (result != null) {
- // interface is detected fine (fqn was used or in good package ?)
- return result;
- }
-
- String suffix = "." + rawName;
-
- if (realParentRawName != null) {
- suffix = "." + realParentRawName;
- }
-
- for (String aClass : compiler.getImportedClasses()) {
-
- if (aClass.endsWith(suffix)) {
-
- // found the class as an already knwon class
-
- if (realRawName != null) {
- aClass += "." + realRawName;
- }
-
- return aClass;
- }
- }
-
- // try on packages
-
- Set<String> importedPackages = compiler.getImportedPackages();
-
- for (String aClass : importedPackages) {
- String fqn = aClass + rawName;
-
- log.info("try fqn = " + fqn);
- result = TagManager.resolveClassName(fqn, compiler);
- if (result != null) {
- return result;
- }
- }
-
- // nothing was found
- return null;
- }
-
-
- // scans class body nodes
-
- private void scanClassNode(SimpleNode node) {
- int nodeType = node.getId();
- if (nodeType == JavaParserTreeConstants.JJTMETHODDECLARATION) {
- String returnType = null;
- String name = null;
- List<String> parameterTypes = new ArrayList<String>();
- //List<String> parameterNames = new ArrayList<String>();
- for (int i = 0; i < node.jjtGetNumChildren(); i++) {
- SimpleNode child = node.getChild(i);
- int type = child.getId();
- if (type == JavaParserTreeConstants.JJTRESULTTYPE) {
- returnType = TagManager.resolveClassName(child.getText().trim(), compiler);
- } else if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) {
- name = child.firstToken.image.trim();
- SimpleNode formalParameters = child.getChild(0);
- assert formalParameters.getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS;
- for (int j = 0; j < formalParameters.jjtGetNumChildren(); j++) {
- SimpleNode parameter = formalParameters.getChild(j);
- String rawParameterType = parameter.getChild(1).getText().trim().replaceAll("\\.\\.\\.", "[]");
- String parameterType = TagManager.resolveClassName(rawParameterType, compiler);
- if (parameterType == null && JAXXCompiler.STRICT_CHECKS) {
- throw new CompilerException("could not find class '" + rawParameterType + "'");
- }
- parameterTypes.add(parameterType);
- //parameterNames.add(parameter.getChild(2).getText().trim());
- }
- }
- }
- methods.add(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader())); // TODO: determine the actual modifiers
- } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) {
- // TODO: handle inner classes
- } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) {
- // TODO: handle constructors
- } else if (nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) {
-
- String text = node.getText();
- String declaration = text;
- String value = null;
- int equals = text.indexOf("=");
- if (equals != -1) {
- value = declaration.substring(equals + 1).trim();
- declaration = declaration.substring(0, equals);
- }
- declaration = declaration.trim();
-
- // get modifiers of the field
-
- int modifiers;
- if (isInterface) {
- modifiers = Modifier.PUBLIC | Modifier.STATIC | Modifier.FINAL;
- } else {
- modifiers = getModifiers(node);
- }
-
- log.info("field [" + declaration + "] modifiers == " + Modifier.toString(modifiers));
-
- String[] declarationTokens = declaration.split("\\s");
- String name = declarationTokens[declarationTokens.length - 1];
- if (name.endsWith(";")) {
- name = name.substring(0, name.length() - 1).trim();
- }
- String cName = declarationTokens[declarationTokens.length - 2];
- String type = TagManager.resolveClassName(cName, compiler);
-
- FieldDescriptor descriptor = new FieldDescriptor(
- name,
- modifiers,
- type,
- compiler.getClassLoader()
- );
-
- if ("$jaxxObjectDescriptor".equals(name) && value != null) {
-
- // we are in a jaxx object, save the value of the field
-
- // value have this form : = "XXX";, we just want the XXX part
- int firstIndex = value.indexOf("\"");
- int lastIndex = value.lastIndexOf("\"");
-
- jaxxObjectDescriptorValue = value.substring(firstIndex + 1, lastIndex);
-
- log.info("detected a $jaxxObjectDescriptor = " +
- jaxxObjectDescriptorValue);
-
- }
-
- if (Modifier.isPublic(modifiers)) {
- fields.add(descriptor);
- } else {
- declaredFields.add(descriptor);
- }
-
- } else {
- for (int i = 0; i < node.jjtGetNumChildren(); i++) {
- SimpleNode child = node.getChild(i);
- scanClassNode(child);
- }
- }
- }
-
- protected int getModifiers(SimpleNode node) {
- SimpleNode parentNode = node.getParent();
- for (int i = 0; i < parentNode.jjtGetNumChildren(); i++) {
- SimpleNode child = parentNode.getChild(i);
- if (child.getId() == JavaParserTreeConstants.JJTMODIFIERS) {
- String modifiersStr = child.getText().trim();
- int modifiers = scanModifiers(modifiersStr);
- return modifiers;
- }
- }
- return 0;
- }
-
- protected int scanModifiers(String modifiersStr) {
- int modifiers = 0;
- if (modifiersStr.contains("public")) {
- modifiers |= Modifier.PUBLIC;
- }
- if (modifiersStr.contains("protected")) {
- modifiers |= Modifier.PROTECTED;
- }
- if (modifiersStr.contains("private")) {
- modifiers |= Modifier.PRIVATE;
- }
- if (modifiersStr.contains("static")) {
- modifiers |= Modifier.STATIC;
- }
- if (modifiersStr.contains("final")) {
- modifiers |= Modifier.FINAL;
- }
- if (modifiersStr.contains("volatile")) {
- modifiers |= Modifier.VOLATILE;
- }
- if (modifiersStr.contains("transient")) {
- modifiers |= Modifier.TRANSIENT;
- }
- if (modifiersStr.contains("synchronized")) {
- modifiers |= Modifier.SYNCHRONIZED;
- }
- if (modifiersStr.contains("abstract")) {
- modifiers |= Modifier.ABSTRACT;
- }
- return modifiers;
- }
-}
Deleted: trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/JavaFileParserTest.java
===================================================================
--- trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/JavaFileParserTest.java 2010-10-05 08:37:01 UTC (rev 2106)
+++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/JavaFileParserTest.java 2010-10-05 08:55:56 UTC (rev 2107)
@@ -1,286 +0,0 @@
-/*
- * #%L
- * JAXX :: Compiler
- *
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2008 - 2010 CodeLutin
- * %%
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation, either version 3 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Lesser Public License for more details.
- *
- * You should have received a copy of the GNU General Lesser Public
- * License along with this program. If not, see
- * <http://www.gnu.org/licenses/lgpl-3.0.html>.
- * #L%
- */
-
-package jaxx.compiler.reflect;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.nuiton.util.ApplicationConfig;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.InputStreamReader;
-import java.io.Reader;
-import java.io.Serializable;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.List;
-
-public class JavaFileParserTest {
-
- /** log */
- protected static final Log log =
- LogFactory.getLog(JavaFileParserTest.class);
-
- /** test source root directory */
- public static File testSourceRoot;
-
- @BeforeClass
- public static void initBaseDir() {
- // get maven env basedir
- String basedir = System.getenv("basedir");
- if (basedir == null) {
-
- // says basedir is where we start tests.
- basedir = new File("").getAbsolutePath();
- }
- testSourceRoot = new File(new File(basedir),
- "src" + File.separator +
- "test" + File.separator + "java");
- }
-
- @Test
- public void parseJavaFileParserTest() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(JavaFileParserTest.class);
-
- assertInterfaces(descriptor);
- assertSuperClass(descriptor, Object.class);
- }
-
- @Test
- public void parseMyEnum() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(MyEnum.class);
-
- assertInterfaces(descriptor, Serializable.class, MyInterface.class);
- assertInterfaces(descriptor, MyEnum.class.getInterfaces());
- assertSuperClass(descriptor, Enum.class);
-
- assertIsAssignableFrom(
- descriptor,
- Serializable.class,
- MyInterface.class,
- Enum.class
- );
- }
-
- @Test
- public void parseMyInterface() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(MyInterface.class);
-
- assertInterfaces(descriptor);
- assertSuperClass(descriptor, null);
- }
-
- @Test
- public void parseMyInterface2() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(MyInterface2.class);
-
- assertInterfaces(descriptor, MyInterface2.class.getInterfaces());
- assertInterfaces(descriptor, ApplicationConfig.OptionDef.class);
- assertSuperClass(descriptor, null);
- }
-
- @Test
- public void parseMyInterface3() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(MyInterface3.class);
-
- assertInterfaces(descriptor, MyInterface3.class.getInterfaces());
- assertInterfaces(descriptor, ApplicationConfig.OptionDef.class, Iterable.class);
- assertSuperClass(descriptor, null);
- }
-
- @Test
- public void parseMyAbstractClass() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(MyAbstractClass.class);
-
- assertInterfaces(descriptor, MyAbstractClass.class.getInterfaces());
- assertInterfaces(descriptor, MyInterface.class);
- assertSuperClass(descriptor, Object.class);
- assertIsAssignableFrom(descriptor, MyInterface.class, Object.class);
- }
-
- @Test
- public void parseMyClass() throws Exception {
-
- ClassDescriptor descriptor = getDescriptor(MyClass.class);
-
- assertInterfaces(descriptor, MyClass.class.getInterfaces());
- assertInterfaces(descriptor, Serializable.class);
- assertSuperClass(descriptor, MyAbstractClass.class);
- assertIsAssignableFrom(descriptor,
- Serializable.class,
- MyInterface.class,
- MyAbstractClass.class);
-
- assertDeclaredField(
- descriptor,
- "serialVersionUID",
- long.class,
- Modifier.PRIVATE | Modifier.FINAL | Modifier.STATIC
- );
-
- assertDeclaredField(
- descriptor,
- "myPrivateStringField",
- String.class,
- Modifier.PRIVATE | Modifier.FINAL
- );
-
- assertDeclaredField(
- descriptor,
- "myProtectedStringField",
- String.class,
- Modifier.PROTECTED
- );
-
- assertField(
- descriptor,
- "myPublicStringField",
- String.class,
- Modifier.PUBLIC
- );
-
- }
-
- public static void assertField(ClassDescriptor descriptor,
- String fieldName,
- Class<?> fieldType,
- int fieldModifiers) throws NoSuchFieldException {
- FieldDescriptor fieldDescriptor =
- descriptor.getFieldDescriptor(fieldName);
- Assert.assertNotNull(fieldDescriptor);
- ClassDescriptor type = fieldDescriptor.getType();
- Assert.assertNotNull(type);
- Assert.assertEquals(fieldType.getName(), type.getName());
- int modifiers = fieldDescriptor.getModifiers();
- Assert.assertEquals(fieldModifiers, modifiers);
- }
-
- public static void assertDeclaredField(ClassDescriptor descriptor,
- String fieldName,
- Class<?> fieldType,
- int fieldModifiers) throws NoSuchFieldException {
- FieldDescriptor fieldDescriptor =
- descriptor.getDeclaredFieldDescriptor(fieldName);
- Assert.assertNotNull(fieldDescriptor);
- ClassDescriptor type = fieldDescriptor.getType();
- Assert.assertNotNull(type);
- Assert.assertEquals(fieldType.getName(), type.getName());
- int modifiers = fieldDescriptor.getModifiers();
- Assert.assertEquals(fieldModifiers, modifiers);
- }
-
- protected ClassDescriptor getDescriptor(Class<?> klass) throws Exception {
-
- String javaFilePath =
- klass.getName().replaceAll("\\.", File.separator) + ".java";
- File src = new File(testSourceRoot, javaFilePath);
- Assert.assertTrue(src.exists());
-
- if (log.isInfoEnabled()) {
- log.info("file to parse " + src);
- }
-
- Reader reader = new InputStreamReader(new FileInputStream(src));
- try {
-
- ClassDescriptor descriptor = JavaFileParser.parseJavaFile(
- klass.getSimpleName(),
- reader, null);
-
- Assert.assertNotNull(descriptor);
- if (log.isInfoEnabled()) {
- log.info("loaded " + descriptor);
- }
- Assert.assertEquals(klass.getName(), descriptor.getName());
- return descriptor;
- } finally {
-
- reader.close();
- }
- }
-
- public static void assertIsAssignableFrom(ClassDescriptor descriptor,
- Class<?>... interfaces) {
-
- for (Class<?> anInterface : interfaces) {
- ClassDescriptor descriptor2 =
- ClassDescriptorHelper.getClassDescriptor(anInterface);
- Assert.assertNotNull(descriptor2);
- boolean value = descriptor2.isAssignableFrom(descriptor);
- Assert.assertTrue(
- anInterface + " should be assignable from " + descriptor,
- value
- );
- }
- }
-
- public static void assertInterfaces(ClassDescriptor descriptor,
- Class<?>... interfaces) {
- ClassDescriptor[] descriptors = descriptor.getInterfaces();
- Assert.assertEquals(interfaces.length, descriptors.length);
-
- List<String> doFind = new ArrayList<String>();
- for (Class<?> anInterface : interfaces) {
- doFind.add(anInterface.getName());
- }
-
- for (ClassDescriptor descriptor1 : descriptors) {
- String name = descriptor1.getName();
- Assert.assertTrue(doFind.contains(name));
- doFind.remove(name);
- }
- Assert.assertTrue(
- "The follwing interfaces were not find found : " + doFind,
- doFind.isEmpty()
- );
-
- }
-
- public static void assertSuperClass(ClassDescriptor descriptor,
- Class<?> superClass) {
- ClassDescriptor superDescriptor = descriptor.getSuperclass();
- if (superClass == null) {
- Assert.assertNull(
- "Should be null but was " + superDescriptor,
- superDescriptor
- );
- } else {
- Assert.assertNotNull(superDescriptor);
- Assert.assertEquals(superClass.getName(), superDescriptor.getName());
- }
-
- }
-
-}
Modified: trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/resolvers/ClassDescriptorResolverFromJavaFileTest.java
===================================================================
--- trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/resolvers/ClassDescriptorResolverFromJavaFileTest.java 2010-10-05 08:37:01 UTC (rev 2106)
+++ trunk/jaxx-compiler/src/test/java/jaxx/compiler/reflect/resolvers/ClassDescriptorResolverFromJavaFileTest.java 2010-10-05 08:55:56 UTC (rev 2107)
@@ -25,7 +25,8 @@
package jaxx.compiler.reflect.resolvers;
import jaxx.compiler.reflect.ClassDescriptor;
-import jaxx.compiler.reflect.JavaFileParserTest;
+import jaxx.compiler.reflect.ClassDescriptorHelper;
+import jaxx.compiler.reflect.FieldDescriptor;
import jaxx.compiler.reflect.MyAbstractClass;
import jaxx.compiler.reflect.MyClass;
import jaxx.compiler.reflect.MyEnum;
@@ -42,13 +43,9 @@
import java.io.File;
import java.io.Serializable;
import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.List;
-import static jaxx.compiler.reflect.JavaFileParserTest.assertDeclaredField;
-import static jaxx.compiler.reflect.JavaFileParserTest.assertField;
-import static jaxx.compiler.reflect.JavaFileParserTest.assertInterfaces;
-import static jaxx.compiler.reflect.JavaFileParserTest.assertIsAssignableFrom;
-import static jaxx.compiler.reflect.JavaFileParserTest.assertSuperClass;
-
/**
* Tests the {@link ClassDescriptorResolverFromJavaFile} resolver.
*
@@ -61,16 +58,29 @@
protected static final Log log =
LogFactory.getLog(ClassDescriptorResolverFromJavaFileTest.class);
+
+ /** test source root directory */
+ public static File testSourceRoot;
+
@BeforeClass
public static void initBaseDir() {
- JavaFileParserTest.initBaseDir();
+ // get maven env basedir
+ String basedir = System.getenv("basedir");
+ if (basedir == null) {
+
+ // says basedir is where we start tests.
+ basedir = new File("").getAbsolutePath();
+ }
+ testSourceRoot = new File(new File(basedir),
+ "src" + File.separator +
+ "test" + File.separator + "java");
}
protected ClassDescriptor getDescriptor(Class<?> klass) throws Exception {
String javaFilePath =
klass.getName().replaceAll("\\.", File.separator) + ".java";
- File src = new File(JavaFileParserTest.testSourceRoot, javaFilePath);
+ File src = new File(testSourceRoot, javaFilePath);
Assert.assertTrue(src.exists());
if (log.isInfoEnabled()) {
@@ -205,4 +215,85 @@
}
+ public static void assertField(ClassDescriptor descriptor,
+ String fieldName,
+ Class<?> fieldType,
+ int fieldModifiers) throws NoSuchFieldException {
+ FieldDescriptor fieldDescriptor =
+ descriptor.getFieldDescriptor(fieldName);
+ Assert.assertNotNull(fieldDescriptor);
+ ClassDescriptor type = fieldDescriptor.getType();
+ Assert.assertNotNull(type);
+ Assert.assertEquals(fieldType.getName(), type.getName());
+ int modifiers = fieldDescriptor.getModifiers();
+ Assert.assertEquals(fieldModifiers, modifiers);
+ }
+
+ public static void assertDeclaredField(ClassDescriptor descriptor,
+ String fieldName,
+ Class<?> fieldType,
+ int fieldModifiers) throws NoSuchFieldException {
+ FieldDescriptor fieldDescriptor =
+ descriptor.getDeclaredFieldDescriptor(fieldName);
+ Assert.assertNotNull(fieldDescriptor);
+ ClassDescriptor type = fieldDescriptor.getType();
+ Assert.assertNotNull(type);
+ Assert.assertEquals(fieldType.getName(), type.getName());
+ int modifiers = fieldDescriptor.getModifiers();
+ Assert.assertEquals(fieldModifiers, modifiers);
+ }
+
+
+ public static void assertIsAssignableFrom(ClassDescriptor descriptor,
+ Class<?>... interfaces) {
+
+ for (Class<?> anInterface : interfaces) {
+ ClassDescriptor descriptor2 =
+ ClassDescriptorHelper.getClassDescriptor(anInterface);
+ Assert.assertNotNull(descriptor2);
+ boolean value = descriptor2.isAssignableFrom(descriptor);
+ Assert.assertTrue(
+ anInterface + " should be assignable from " + descriptor,
+ value
+ );
+ }
+ }
+
+ public static void assertInterfaces(ClassDescriptor descriptor,
+ Class<?>... interfaces) {
+ ClassDescriptor[] descriptors = descriptor.getInterfaces();
+ Assert.assertEquals(interfaces.length, descriptors.length);
+
+ List<String> doFind = new ArrayList<String>();
+ for (Class<?> anInterface : interfaces) {
+ doFind.add(anInterface.getName());
+ }
+
+ for (ClassDescriptor descriptor1 : descriptors) {
+ String name = descriptor1.getName();
+ Assert.assertTrue(doFind.contains(name));
+ doFind.remove(name);
+ }
+ Assert.assertTrue(
+ "The follwing interfaces were not find found : " + doFind,
+ doFind.isEmpty()
+ );
+
+ }
+
+ public static void assertSuperClass(ClassDescriptor descriptor,
+ Class<?> superClass) {
+ ClassDescriptor superDescriptor = descriptor.getSuperclass();
+ if (superClass == null) {
+ Assert.assertNull(
+ "Should be null but was " + superDescriptor,
+ superDescriptor
+ );
+ } else {
+ Assert.assertNotNull(superDescriptor);
+ Assert.assertEquals(superClass.getName(), superDescriptor.getName());
+ }
+
+ }
+
}
1
0
r2106 - in trunk: . jaxx-runtime jaxx-widgets jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean
by tchemit@users.nuiton.org 05 Oct '10
by tchemit@users.nuiton.org 05 Oct '10
05 Oct '10
Author: tchemit
Date: 2010-10-05 10:37:01 +0200 (Tue, 05 Oct 2010)
New Revision: 2106
Url: http://nuiton.org/repositories/revision/jaxx/2106
Log:
Evolution #914: Update swingx to swingx-core 1.6.2-2
Modified:
trunk/jaxx-runtime/pom.xml
trunk/jaxx-widgets/pom.xml
trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java
trunk/pom.xml
Modified: trunk/jaxx-runtime/pom.xml
===================================================================
--- trunk/jaxx-runtime/pom.xml 2010-10-05 08:04:30 UTC (rev 2105)
+++ trunk/jaxx-runtime/pom.xml 2010-10-05 08:37:01 UTC (rev 2106)
@@ -90,7 +90,7 @@
<dependency>
<groupId>org.swinglabs</groupId>
- <artifactId>swingx</artifactId>
+ <artifactId>swingx-core</artifactId>
</dependency>
</dependencies>
Modified: trunk/jaxx-widgets/pom.xml
===================================================================
--- trunk/jaxx-widgets/pom.xml 2010-10-05 08:04:30 UTC (rev 2105)
+++ trunk/jaxx-widgets/pom.xml 2010-10-05 08:37:01 UTC (rev 2106)
@@ -53,7 +53,7 @@
<dependency>
<groupId>org.swinglabs</groupId>
- <artifactId>swingx</artifactId>
+ <artifactId>swingx-core</artifactId>
</dependency>
<!--dependency>
Modified: trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java
===================================================================
--- trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java 2010-10-05 08:04:30 UTC (rev 2105)
+++ trunk/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/bean/BeanUIUtil.java 2010-10-05 08:37:01 UTC (rev 2106)
@@ -31,12 +31,17 @@
import jaxx.runtime.swing.JAXXButtonGroup;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.jdesktop.swingx.autocomplete.AutoCompleteComboBoxEditor;
import org.jdesktop.swingx.autocomplete.AutoCompleteDecorator;
-import org.jdesktop.swingx.autocomplete.AutoCompletePropertyChangeListener;
+import org.jdesktop.swingx.autocomplete.AutoCompleteDocument;
+import org.jdesktop.swingx.autocomplete.ComboBoxAdaptor;
import org.jdesktop.swingx.autocomplete.ObjectToStringConverter;
import javax.swing.AbstractButton;
+import javax.swing.ActionMap;
import javax.swing.ButtonGroup;
+import javax.swing.ComboBoxEditor;
+import javax.swing.InputMap;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
@@ -47,10 +52,16 @@
import javax.swing.text.JTextComponent;
import java.awt.Component;
import java.awt.Dimension;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyListener;
import java.beans.Introspector;
import java.beans.PropertyChangeListener;
import java.util.Date;
+import java.util.List;
+import static java.util.Arrays.asList;
+import static java.util.Collections.unmodifiableList;
import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
@@ -94,6 +105,11 @@
*/
public static void decorate(JComboBox combo, ObjectToStringConverter convertor) {
+ // tchemit 2010-10-05 since swingx 1.6.2, undecorate stuff is no more
+ // public and we want to use it, so hack it...
+ combo.putClientProperty("oldEditor", combo.getEditor());
+ combo.putClientProperty("oldDocument", combo.getEditor().getEditorComponent());
+
AutoCompleteDecorator.decorate(combo, convertor);
}
@@ -101,28 +117,119 @@
* Désactive l'aut-complétion sur une liste déroulante, en y repositionnant
* le modèle du document d'édition d'avant auto-complétion.
*
- * @param combo la liste déroulante à décorer
+ * @param comboBox la liste déroulante à décorer
* @param originalDocument le document original de l'édtieur de la
* liste déroulante.
*/
- public static void undecorate(JComboBox combo, Document originalDocument) {
+ public static void undecorate(JComboBox comboBox, Document originalDocument) {
// has not to be editable
- combo.setEditable(false);
+ comboBox.setEditable(false);
// configure the text component=editor component
- Component c = combo.getEditor().getEditorComponent();
+ Component c = comboBox.getEditor().getEditorComponent();
JTextComponent editorComponent = (JTextComponent) c;
editorComponent.setDocument(originalDocument);
editorComponent.setText(null);
+ //undecorate(comboBox);
+
//remove old property change listener
- for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) {
- if (l instanceof AutoCompletePropertyChangeListener) {
- c.removePropertyChangeListener("editor", l);
+ //for (PropertyChangeListener l : c.getPropertyChangeListeners("editor")) {
+ // if (l instanceof AutoCompletePropertyChangeListener) {
+ // c.removePropertyChangeListener("editor", l);
+ // }
+ //}
+
+ ComboBoxEditor oldEditor = (ComboBoxEditor) comboBox.getClientProperty("oldEditor");
+
+ if (editorComponent.getDocument() instanceof AutoCompleteDocument) {
+ AutoCompleteDocument doc = (AutoCompleteDocument) editorComponent.getDocument();
+
+ if (doc.isStrictMatching()) {
+ ActionMap map = comboBox.getActionMap();
+
+ for (String key : COMBO_BOX_ACTIONS) {
+ map.put(key, null);
+ }
}
+
+ //remove old property change listener
+ for (PropertyChangeListener l : comboBox.getPropertyChangeListeners("editor")) {
+ //if (l instanceof AutoComplete.PropertyChangeListener) {
+ if (l.getClass().getName().contains("AutoComplete")) {
+ comboBox.removePropertyChangeListener("editor", l);
+ }
+ }
+
+ for (PropertyChangeListener l : comboBox.getPropertyChangeListeners("enabled")) {
+ //if (l instanceof AutoComplete.PropertyChangeListener) {
+ if (l.getClass().getName().contains("AutoComplete")) {
+ comboBox.removePropertyChangeListener("enabled", l);
+ }
+ }
+
+ AutoCompleteComboBoxEditor editor = (AutoCompleteComboBoxEditor) comboBox.getEditor();
+ comboBox.setEditor(oldEditor);
+
+ //remove old key listener
+ for (KeyListener l : editorComponent.getKeyListeners()) {
+ //if (l instanceof AutoComplete.KeyAdapter) {
+ if (l.getClass().getName().contains("AutoComplete")) {
+ editorComponent.removeKeyListener(l);
+ break;
+ }
+ }
+
+ undecorate(editorComponent, originalDocument);
+
+ for (ActionListener l : comboBox.getActionListeners()) {
+ if (l instanceof ComboBoxAdaptor) {
+ comboBox.removeActionListener(l);
+ break;
+ }
+ }
+
+ //TODO remove aqua fix
+
+ //TODO reset editibility
}
}
+ static void undecorate(JTextComponent textComponent, Document originalDocument) {
+ Document doc = textComponent.getDocument();
+
+ if (doc instanceof AutoCompleteDocument) {
+ //remove autocomplete key/action mappings
+ InputMap map = textComponent.getInputMap();
+
+ while (map.getParent() != null) {
+ InputMap parent = map.getParent();
+
+ //if (parent instanceof AutoComplete.InputMap) {
+ if (parent.getClass().getName().contains("AutoComplete")) {
+ map.setParent(parent.getParent());
+ }
+
+ map = parent;
+ }
+
+ textComponent.getActionMap().put("nonstrict-backspace", null);
+
+ //remove old focus listener
+ for (FocusListener l : textComponent.getFocusListeners()) {
+ //if (l instanceof AutoComplete.FocusAdapter) {
+ if (l.getClass().getName().contains("AutoComplete")) {
+ textComponent.removeFocusListener(l);
+ break;
+ }
+ }
+
+ //reset to original document
+ //textComponent.setDocument(((AutoCompleteDocument) doc).delegate);
+ textComponent.setDocument(originalDocument);
+ }
+ }
+
public static <O> MultiJXPathDecorator<O> createDecorator(JXPathDecorator<O> decorator) {
if (decorator == null) {
throw new NullPointerException(
@@ -205,7 +312,7 @@
* @param popupLabel
* @param sortUp
* @param sortDown
- * @param decorator le decorateur a utiliser
+ * @param decorator le decorateur a utiliser
*/
protected void preparePopup(String selectedTip,
String notSelectedTip,
@@ -271,4 +378,11 @@
getPopup().invalidate();
}
}
+
+
+ //these keys were pulled from BasicComboBoxUI from Sun JDK 1.6.0_20
+
+ private static final List<String> COMBO_BOX_ACTIONS = unmodifiableList(asList("selectNext",
+ "selectNext2", "selectPrevious", "selectPrevious2", "pageDownPassThrough",
+ "pageUpPassThrough", "homePassThrough", "endPassThrough"));
}
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2010-10-05 08:04:30 UTC (rev 2105)
+++ trunk/pom.xml 2010-10-05 08:37:01 UTC (rev 2106)
@@ -311,8 +311,8 @@
<dependency>
<groupId>org.swinglabs</groupId>
- <artifactId>swingx</artifactId>
- <version>1.6.1</version>
+ <artifactId>swingx-core</artifactId>
+ <version>1.6.2-2</version>
<scope>compile</scope>
</dependency>
1
0