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 2009
- 3 participants
- 80 discussions
r1570 - in branches/jaxx-2.X/maven-jaxx-plugin/src/main: java/org/nuiton/jaxx/plugin resources
by tchemit@users.nuiton.org 08 Oct '09
by tchemit@users.nuiton.org 08 Oct '09
08 Oct '09
Author: tchemit
Date: 2009-10-08 23:10:15 +0200 (Thu, 08 Oct 2009)
New Revision: 1570
Modified:
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
Log:
generate help search index (still does not works everywhere, a shame the code is from com.sun we do not have the source...)
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 21:10:15 UTC (rev 1570)
@@ -18,18 +18,26 @@
*##%*/
package org.nuiton.jaxx.plugin;
+import com.sun.java.help.search.Indexer;
import java.io.BufferedReader;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStreamReader;
+import java.io.PrintStream;
+import java.lang.reflect.Method;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.Locale;
import java.util.Properties;
+import org.codehaus.plexus.util.DirectoryScanner;
+import org.codehaus.plexus.util.FileUtils;
+import org.codehaus.plexus.util.StringUtils;
import org.nuiton.i18n.I18n;
import org.nuiton.util.FileUtil;
import org.nuiton.util.SortedProperties;
@@ -82,7 +90,7 @@
/**
* The template used to generate helpset file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
* @required
@@ -93,7 +101,7 @@
/**
* The template used to generate helpset map file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
* @required
@@ -104,7 +112,7 @@
/**
* The template used to generate helpset index file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
* @required
@@ -115,7 +123,7 @@
/**
* The template used to generate helpset toc file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
* @required
@@ -126,7 +134,7 @@
/**
* The template used to generate helpset content file.
*
- * Must be an existing file or a ressource in classp-ath
+ * Must be an existing file or a ressource in class-path
*
* @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
* @required
@@ -135,6 +143,15 @@
*/
protected File contentTemplate;
/**
+ * Flag to generate the search index.
+ *
+ * @parameter expression="${jaxx.generateSearch}" default-value="true"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected boolean generateSearch;
+ /**
* The help ids discovered in {@link #helpIdsStore} files.
*/
private Properties helpIds;
@@ -192,7 +209,7 @@
}
// load ids from idsStore file
-
+
helpIds = new SortedProperties();
BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
@@ -255,7 +272,7 @@
env.put("mapFileName", mapFileName);
env.put("indexFileName", indexFileName);
env.put("tocFileName", tocFileName);
-// env.put("searchData", localePath + "/index");
+ env.put("generateSearch", generateSearch);
// ---------------------------------------------------------------
// --- main helpset file -----------------------------------------
@@ -275,7 +292,7 @@
file = new File(localizedTarget, mapFileName);
- Properties mergedHelpIds = generateMapFile(file, env);
+ generateMapFile(file, env);
touchedFiles++;
// ---------------------------------------------------------------
@@ -284,7 +301,7 @@
file = new File(localizedTarget, indexFileName);
- NodeItem indexRootItem = generateIndexFile(file, env);
+ generateIndexFile(file, env);
touchedFiles++;
// ---------------------------------------------------------------
@@ -293,7 +310,7 @@
file = new File(localizedTarget, tocFileName);
- NodeItem tocRootItem = generateTocFile(file, env);
+ generateTocFile(file, env);
touchedFiles++;
// ---------------------------------------------------------------
@@ -302,6 +319,16 @@
touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+ // ---------------------------------------------------------------
+ // --- generate search index -------------------------------------
+ // ---------------------------------------------------------------
+
+ if (generateSearch) {
+
+ generateSearchIndex(localizedTarget, locale);
+ }
+
+
}
getLog().info(touchedFiles + " file(s) treated.");
@@ -475,6 +502,35 @@
return rootItem;
}
+ protected void generateSearchIndex(File localizedTarget, Locale locale) throws IllegalArgumentException, IOException, InvocationTargetException, SecurityException, IllegalAccessException, NoSuchMethodException {
+
+ Method m = Indexer.class.getDeclaredMethod("main", String[].class);
+ File indexDir = new File(localizedTarget, "JavaHelpSearch");
+ // remove old index
+ FileUtils.deleteDirectory(indexDir);
+ //copy resources to a tmp dir (without any VCS infos)
+ File tmpDir = new File(project.getBasedir(), "target" + File.separator + "jaxx-tmp" + File.separator + "indexer-" + locale + "-" + System.nanoTime());
+ getLog().info("copy files to " + tmpDir + " for indexing them");
+ FileUtils.copyDirectory(localizedTarget, tmpDir, "**/*", StringUtils.join(DirectoryScanner.DEFAULTEXCLUDES, ","));
+ List<String> params = new ArrayList<String>();
+ params.add("-verbose");
+ params.add("-db");
+ params.add(indexDir.getAbsolutePath());
+ params.add("-logfile");
+ File logFile = new File(project.getBasedir(), "target" + File.separator + "generated-sources" + File.separator + "jaxx" + File.separator + "indexer-" + locale + ".log");
+ params.add(logFile.getAbsolutePath());
+ params.add(tmpDir.getAbsolutePath());
+ PrintStream out = System.out;
+ PrintStream err = System.err;
+ try {
+ m.invoke(null, (Object) params.toArray(new String[params.size()]));
+ } finally {
+ System.setOut(out);
+ System.setErr(err);
+ }
+ getLog().info("Search Index generated");
+ }
+
protected NodeItem generateTocFile(File file, Properties env) throws Exception {
NodeItem rootItem = null;
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 21:10:15 UTC (rev 1570)
@@ -386,7 +386,7 @@
return;
}
- getLog().info("Detects " + files.length + " modify jaxx file(s). ");
+ getLog().info("Detects " + files.length + " modified jaxx file(s). ");
try {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-08 19:10:44 UTC (rev 1569)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-08 21:10:15 UTC (rev 1570)
@@ -31,13 +31,13 @@
<data>$localePath/$indexFileName</data>
</view>
-#if ( $searchData )
+#if ( $generateSearch )
<view>
<name>Search</name>
<label>Search</label>
<type>javax.help.SearchView</type>
<data engine="com.sun.java.help.search.DefaultSearchEngine">
- $searchData
+ $localePath/JavaHelpSearch
</data>
</view>
#end
1
0
r1569 - in branches/jaxx-2.X: jaxx-compiler/src/main/java/jaxx/compiler maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin
by tchemit@users.nuiton.org 08 Oct '09
by tchemit@users.nuiton.org 08 Oct '09
08 Oct '09
Author: tchemit
Date: 2009-10-08 21:10:44 +0200 (Thu, 08 Oct 2009)
New Revision: 1569
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
Log:
- add encoding on goals (should be in JAXXCompiler)
- simplify helpIdsStore (only store ids, path will be computed if needed)
- maven-helper-plugin common code
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -122,4 +122,10 @@
* @return {@code true} if compiler is verbose
*/
boolean isVerbose();
+
+ /**
+ *
+ * @return the encoding to use to write files
+ */
+ String getEncoding();
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -86,6 +86,10 @@
* since this class should be in sources (so not yet compiled)
*/
private String helpBrokerFQN;
+ /**
+ * Encoding to use to write files
+ */
+ private String encoding;
@Override
public File getTargetDirectory() {
@@ -182,6 +186,11 @@
}
@Override
+ public String getEncoding() {
+ return encoding;
+ }
+
+ @Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
}
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -32,6 +32,9 @@
*/
public abstract class AbstractJaxxMojo extends AbstractPlugin {
+ public abstract File getTargetDirectory();
+
+ public abstract void setTargetDirectory(File targetDirectory);
/**
* Dépendance du projet.
*
@@ -41,6 +44,13 @@
*/
protected MavenProject project;
/**
+ * Encoding pour la generation des fichiers
+ *
+ * @parameter expression="${jaxx.encoding}" default-value="${project.build.sourceEncoding}"
+ * @since 2.0.0
+ */
+ protected String encoding;
+ /**
* verbose flag
*
* @parameter expression="${jaxx.verbose}" default-value="false"
@@ -52,7 +62,7 @@
* The store of helpIds generated by the goal {@link GenerateMojo} and then
* used by the goal {@link GenerateHelpMojo}.
*
- * @parameter expression="${jaxx.helpIdsStore}" default-value="target/helpIds.properties"
+ * @parameter expression="${jaxx.helpIdsStore}" default-value="target/generated-sources/jaxx/helpIds.properties"
* @required
*
* @since 1.3
@@ -91,4 +101,12 @@
public void setHelpIdsStore(File helpIdsStore) {
this.helpIdsStore = helpIdsStore;
}
+
+ public String getEncoding() {
+ return encoding;
+ }
+
+ public void setEncoding(String encoding) {
+ this.encoding = encoding;
+ }
}
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -18,11 +18,12 @@
*##%*/
package org.nuiton.jaxx.plugin;
+import java.io.BufferedReader;
import org.apache.maven.plugin.MojoFailureException;
import java.io.File;
import java.io.FileInputStream;
-import java.io.InputStream;
+import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Enumeration;
@@ -185,21 +186,21 @@
checkResource(tocTemplate);
checkResource(contentTemplate);
- if (!outHelp.exists()) {
- getLog().info("mkdir " + outHelp);
- outHelp.mkdirs();
+ if (!getTargetDirectory().exists()) {
+ getLog().info("mkdir " + getTargetDirectory());
+ getTargetDirectory().mkdirs();
}
+ // load ids from idsStore file
+
helpIds = new SortedProperties();
- InputStream stream = new FileInputStream(idsStore);
-
- try {
- helpIds.load(stream);
- } finally {
- if (stream != null) {
- stream.close();
- }
+ BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(idsStore), getEncoding()));
+ String id = null;
+ while ((id = reader.readLine()) != null) {
+ id = id.trim();
+ String path = id.replaceAll("\\.", File.separator) + ".html";
+ helpIds.put(id, path);
}
if (helpIds.isEmpty()) {
@@ -208,7 +209,6 @@
getLog().warn("No helpIds detected, will skip.");
return false;
}
-
return true;
}
@@ -235,7 +235,9 @@
localizedTarget.mkdirs();
}
getLog().info("Generate help for language " + language);
- getLog().info(" Localized target : " + localizedTarget);
+ if (isVerbose()) {
+ getLog().info(" Localized target : " + localizedTarget);
+ }
Properties env = new Properties();
@@ -305,6 +307,16 @@
getLog().info(touchedFiles + " file(s) treated.");
}
+ @Override
+ public File getTargetDirectory() {
+ return outHelp;
+ }
+
+ @Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outHelp = targetDirectory;
+ }
+
protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
int touchedFiles = 0;
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -27,27 +27,18 @@
import jaxx.compiler.tags.TagManager;
import jaxx.runtime.JAXXContext;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
import org.nuiton.io.FileUpdaterHelper;
import org.nuiton.io.MirroredFileUpdater;
import java.io.File;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.net.MalformedURLException;
import java.util.Map;
import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
import java.util.Set;
import jaxx.runtime.swing.help.JAXXHelpBroker;
import org.apache.commons.lang.builder.ToStringBuilder;
@@ -336,7 +327,6 @@
return true;
}
-// if (addSourcesToClassPath || addProjectClassPath) {
cl = initClassLoader(project,
src,
addSourcesToClassPath,
@@ -346,10 +336,6 @@
addProjectClassPath);
Thread.currentThread().setContextClassLoader(cl);
-// } else {
-// cl = getClass().getClassLoader();
- //cl = Thread.currentThread().getContextClassLoader();
-// }
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
@@ -368,8 +354,8 @@
BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
}
- if (!outJava.exists()) {
- outJava.mkdirs();
+ if (!getTargetDirectory().exists()) {
+ getTargetDirectory().mkdirs();
}
// compute extra imports (can not use java classes since some of
@@ -442,6 +428,11 @@
}
@Override
+ public void setTargetDirectory(File targetDirectory) {
+ this.outJava = targetDirectory;
+ }
+
+ @Override
public boolean getOptimize() {
return optimize;
}
@@ -534,16 +525,9 @@
}
if (testPhase) {
- if (!project.getTestCompileSourceRoots().contains(
- outJava.getPath())) {
- getLog().info("Add test compile source root : " + outJava);
- project.addTestCompileSourceRoot(outJava.getPath());
- }
+ addTestCompileSourceRoots(getTargetDirectory());
} else {
- if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
- getLog().info("Add compile source root : " + outJava);
- project.addCompileSourceRoot(outJava.getPath());
- }
+ addCompileSourceRoots(getTargetDirectory());
}
}
@@ -586,91 +570,18 @@
idsStore.getParentFile().mkdirs();
}
- Properties p = new Properties();
+ StringBuilder buffer = new StringBuilder();
for (String helpId : helpIds) {
- String path = helpId.replaceAll("\\.", File.separator);
- path = removeQuote(path) + ".html";
- p.put(removeQuote(helpId), path);
+ buffer.append(removeQuote(helpId)).append('\n');
}
+ writeFile(idsStore, buffer.toString(), encoding);
- FileOutputStream w = new FileOutputStream(idsStore);
-
- try {
- p.store(w, null);
- } finally {
- w.close();
- }
-
getLog().info("helpIdStore generated in " + idsStore);
helpIds.clear();
}
- //TODO use the AbstractPublig method
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
- URLClassLoader loader = null;
- if (project != null) {
-
- URLClassLoader result;
- try {
-
- List<URL> lUrls = new ArrayList<URL>();
- List<String> sources = project.getCompileSourceRoots();
-
- if (addSourcesToClassPath) {
- for (String source : sources) {
- lUrls.add(new File(source).toURI().toURL());
- }
- if (testPhase) {
- for (Object source : project.getTestCompileSourceRoots()) {
- lUrls.add(new File(source.toString()).toURI().toURL());
- }
- }
- }
- if (addResourcesToClassPath) {
- for (Object source : project.getResources()) {
- Resource r = (Resource) source;
- lUrls.add(new File(r.getDirectory()).toURI().toURL());
- }
- }
- if (testPhase && addCompileClassPath) {
- if (project != null) {
- lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
- }
- }
- if (addProjectClassPath) {
- getLog().info("use project compile scope class-path");
- // add also all dependencies of the project in compile scope
- Set<?> artifacts = project.getArtifacts();
- for (Object o : artifacts) {
- Artifact a = (Artifact) o;
- lUrls.add(a.getFile().toURI().toURL());
- }
- }
-
- result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
-
- } catch (IOException e) {
- throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
- }
- loader = result;
- } else {
- List<URL> lUrls = new ArrayList<URL>();
- if (addSourcesToClassPath) {
- lUrls.add(src.toURI().toURL());
- }
- loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
- }
- if (verbose) {
- for (URL entry : loader.getURLs()) {
- log.info("classpath : " + entry);
- }
- }
- return loader;
- }
-
protected String removeQuote(String txt) {
if (txt.startsWith("\"")) {
txt = txt.substring(1);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/NodeItem.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -35,6 +35,10 @@
return childs;
}
+ public void setText(String text) {
+ this.text = text;
+ }
+
public NodeItem findChild(String path) {
NodeItem result = null;
String[] paths = path.split("\\.");
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-10-08 16:48:27 UTC (rev 1568)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-10-08 19:10:44 UTC (rev 1569)
@@ -106,7 +106,7 @@
// premier item
if (rootItem.getTarget().equals(target)) {
// le premier item est bien top
- //rootItem.setText(text);
+ rootItem.setText(text);
currentItem = rootItem;
} else {
// le premier noeud n'est pas top
1
0
Author: tchemit
Date: 2009-10-08 18:48:27 +0200 (Thu, 08 Oct 2009)
New Revision: 1568
Added:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
Removed:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
Log:
evolution #78 : rendre le syst?\195?\168me d'aide multi-langue + JAXXContext is returned to jaxx.runtime package
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -14,7 +14,7 @@
/**
*
- * @return the class loader to use by compilers
+ * @return the class loader used by compilers
*/
ClassLoader getClassLoader();
@@ -51,36 +51,6 @@
/**
*
- * @return the name of the help set to generate
- */
- String getHelpSetName();
-
- /**
- *
- * @return the prefix of i18n keys to use in help system
- */
- String getHelpsetI18nPrefix();
-
- /**
- *
- * @return the suffix of i18n keys to use in index of help system
- */
- String getHelpsetIndexI18nSuffix();
-
- /**
- *
- * @return the suffix of i18n keys to use in title of the help system
- */
- String getHelpsetTitleI18nSuffix();
-
- /**
- *
- * @return the suffix of i18n keys to use in toc of the help system
- */
- String getHelpsetTocI18nSuffix();
-
- /**
- *
* @return the type of context to use in each generated jaxx object
*/
Class<? extends JAXXContext> getJaxxContextClass();
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -13,24 +13,20 @@
*/
public class DefaultCompilerConfiguration implements CompilerConfiguration {
-// private File javacTargetDirectory;
-// private String classPath;
-// private String javacOpts;
-// private boolean keepJavaFiles;
/**
- *
+ * where to generate
*/
private File targetDirectory;
/**
- *
+ * flag to optimize generated code
*/
private boolean optimize;
/**
- *
+ * verbose flag
*/
private boolean verbose;
/**
- *
+ * to do a profile pass after generation
*/
private boolean profile;
/**
@@ -59,11 +55,11 @@
*/
private Class<?> defaultErrorUI;
/**
- *
+ * class loader to use in compiler
*/
private ClassLoader classLoader;
/**
- *
+ * the compiler class to use
*/
private Class<? extends JAXXCompiler> compilerClass;
/**
@@ -90,36 +86,6 @@
* since this class should be in sources (so not yet compiled)
*/
private String helpBrokerFQN;
- /**
- * The prefix to add to i18n key for any help i18n key.
- *
- * @since 1.3
- */
- protected String helpsetI18nPrefix;
- /**
- * The suffix to add to i18n key for an help Id.
- *
- * @since 1.3
- */
- protected String helpsetTitleI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetTocI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetIndexI18nSuffix;
- /**
- * The helpset name
- *
- * @since 1.3
- */
- protected String helpSetName;
@Override
public File getTargetDirectory() {
@@ -211,31 +177,6 @@
}
@Override
- public String getHelpsetIndexI18nSuffix() {
- return helpsetIndexI18nSuffix;
- }
-
- @Override
- public String getHelpsetTitleI18nSuffix() {
- return helpsetTitleI18nSuffix;
- }
-
- @Override
- public String getHelpsetTocI18nSuffix() {
- return helpsetTocI18nSuffix;
- }
-
- @Override
- public String getHelpSetName() {
- return helpSetName;
- }
-
- @Override
- public String getHelpsetI18nPrefix() {
- return helpsetI18nPrefix;
- }
-
- @Override
public Class<?> getValidatorClass() {
return validatorClass;
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -44,8 +44,8 @@
if (options.isGenerateHelp()) {
- // add JaxxHelpUI interface
- Class<?> validatorInterface = jaxx.runtime.swing.JaxxHelpUI.class;
+ // add JAXXHelpUI interface
+ Class<?> validatorInterface = jaxx.runtime.swing.help.JAXXHelpUI.class;
String helpBrokerFQN = getBrokerFQN(compiler);
javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -91,7 +91,9 @@
* @param <O> type of container to obtain from context
* @param clazz clazz desired
* @return parent's container
+ * @deprecated since 2.0.0 : breaks neutral since Swing
*/
+ @Deprecated
public <O extends Container> O getParentContainer(Class<O> clazz);
/**
@@ -101,6 +103,8 @@
* @param top the top container
* @param clazz desired
* @return parent's container
+ * @deprecated since 2.0.0 : breaks neutral since Swing
*/
+ @Deprecated
public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,6 +1,5 @@
package jaxx.runtime.context;
-import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import static jaxx.runtime.context.JAXXContextEntryDef.newDef;
import org.apache.commons.logging.Log;
@@ -25,14 +24,25 @@
*/
public class DefaultJAXXContext implements JAXXContext {
+ /**
+ * entry of the parent context
+ */
protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = newDef(JAXXContext.class);
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * Logger
+ */
static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
- /** l'ui auquel est rattache le context */
+ /**
+ * l'ui auquel est rattache le context
+ */
protected JAXXObject ui;
- /** le context parent */
+ /**
+ * le context parent
+ */
protected JAXXContext parentContext;
- /** les données contenues dans le context */
+ /**
+ * les données contenues dans le context
+ */
protected final Map<JAXXContextEntryDef<?>, Object> data;
public DefaultJAXXContext() {
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,556 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.applet.Applet;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.InputEvent;
-import java.awt.event.KeyEvent;
-import java.awt.event.MouseEvent;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Vector;
-import javax.help.CSH;
-import javax.help.HelpBroker;
-import javax.help.HelpSet;
-import javax.swing.AbstractButton;
-import javax.swing.SwingUtilities;
-import javax.swing.UIManager;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * La classe pour encapsuler l'aide de l'application.
- *
- * @param <B> le type de broker
- * @author tony
- * @since 1.4
- */
-public abstract class JaxxHelpBroker<B extends JaxxHelpBroker<?>> {
-
- public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
- /**
- * Logger
- */
- static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
- /**
- * name of helpset
- */
- protected final String helpsetName;
- /**
- * default id to use if none given
- */
- protected final String defaultID;
- /**
- * help key
- */
- protected final String helpKey;
- /**
- * helpset to use
- */
- protected HelpSet helpset;
- /**
- * help broker
- */
- protected HelpBroker helpBroker;
- /**
- * current locale used
- */
- protected Locale locale;
- /**
- * cache of cursors modified when in context-sensitive mode
- */
- protected Hashtable<Component, Cursor> cursors;
- /**
- * cursor to use in context-sensitive mode
- */
- protected Cursor onItemCursor;
- /**
- * cache of component which cursor have been modified
- */
- protected final Map<Component, String> cache;
-
- protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
- this(null, helpsetName, helpKey, defaultID);
- }
-
- protected JaxxHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID) {
- if (helpsetName == null) {
- throw new NullPointerException("parameter helpsetName can not be null!");
- }
- this.locale = locale;
- this.helpsetName = helpsetName;
- this.helpKey = helpKey;
- this.defaultID = defaultID;
- cache = new HashMap<Component, String>();
-// try {
-// ClassLoader cl = getClass().getClassLoader();
-// URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
-// helpset = new HelpSet(cl, url);
-// helpBroker = helpset.createHelpBroker();
-// } catch (Exception ee) {
-// throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
-// }
- }
-
- public void prepareUI(JAXXObject c) {
- if (c == null) {
- throw new NullPointerException("parameter c can not be null!");
- }
-
- // l'ui doit avoir un boutton showHelp
- AbstractButton help = getShowHelpButton(c);
-
- if (help == null) {
- if (log.isDebugEnabled()) {
- log.debug("no showButton detected for " + c.getClass());
- }
- } else {
-
- // attach context to button
- help.putClientProperty(JAXX_CONTEXT_ENTRY, c.getDelegateContext());
-
- // add tracking action
- ActionListener listener = getShowHelpAction();
- if (log.isDebugEnabled()) {
- log.debug("adding tracking action " + listener);
- }
- help.addActionListener(listener);
-
- }
- if (log.isDebugEnabled()) {
- log.debug("done for " + c);
- }
- }
-
- public HelpBroker getHelpBroker() {
- if (helpBroker == null) {
- helpBroker = getHelpset().createHelpBroker();
- }
- return helpBroker;
- }
-
- public String getHelpKey() {
- return helpKey;
- }
-
- public HelpSet getHelpset() {
- if (helpset == null) {
- try {
- ClassLoader cl = getClass().getClassLoader();
- URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
- helpset = new HelpSet(cl, url);
- } catch (Exception ee) {
- throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
- }
- }
- return helpset;
- }
-
- public String getHelpsetName() {
- return helpsetName;
- }
-
- public String getDefaultID() {
- return defaultID;
- }
-
- public void setLocale(Locale locale) {
- this.locale = locale;
- // need to reload helpset and helpbroker
- helpset = null;
- helpBroker = null;
- getHelpset();
- getHelpBroker();
- }
-
- public void showHelpSet() {
- if (log.isDebugEnabled()) {
- log.debug(this);
- }
- new CSH.DisplayHelpFromSource(helpBroker);
- }
-
- public void showHelp(JAXXContext context, String helpId) {
- }
-
- public void installUI(Component comp, String helpId) {
- CSH.setHelpIDString(comp, helpId);
- if (log.isDebugEnabled()) {
- log.debug(helpId + " : " + comp.getName());
- }
- cache.put(comp, helpId);
- }
-
- public class ShowHelpForTrackedComponentAction implements ActionListener {
-
- @Override
- public void actionPerformed(ActionEvent e) {
- AbstractButton source = (AbstractButton) e.getSource();
-
- JAXXContext context = (JAXXContext) source.getClientProperty(JAXX_CONTEXT_ENTRY);
-
- // prepare cursor
- onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor");
- Vector<?> topComponents = null;
- cursors = null;
-
- if (onItemCursor != null) {
- cursors = new Hashtable<Component, Cursor>();
- topComponents = getTopContainers(source);
- Enumeration<?> enums = topComponents.elements();
- while (enums.hasMoreElements()) {
- setAndStoreCursors((Container) enums.nextElement(), onItemCursor);
- }
- }
-
- // get the tracked component
- Component comp = null;
- try {
- MouseEvent event = getMouseEvent();
- if (event == null) {
- // tracking canceled
- return;
- }
- comp = (Component) event.getSource();
- if (log.isDebugEnabled()) {
- log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName());
- }
- comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY());
- if (log.isDebugEnabled()) {
- log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName());
- }
- } finally {
- // restore the old cursors
- if (topComponents != null) {
- Enumeration<?> containers = topComponents.elements();
- while (containers.hasMoreElements()) {
- resetAndRestoreCursors((Container) containers.nextElement());
- }
- }
- cursors = null;
- }
-
- String helpID = findHelpId(comp);
- showHelp(context, helpID);
- }
-
- public String findHelpId(Component comp) {
- String helpID = CSH.getHelpIDString(comp);
- if (defaultID.equals(helpID)) {
- String id = cache.get(comp);
- // on verifie qu'on est bien sur sur le bon id
- if (helpID.equals(id)) {
- // ok
- return helpID;
- }
- if (log.isDebugEnabled()) {
- log.debug("will try to find better id for comp : " + comp.getName());
- }
- // on est pas sur le bon id
- // on recherche parmis les parents
- helpID = findExtactHelpId(comp);
- }
- if (log.isInfoEnabled()) {
- log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName());
- }
- return helpID;
- }
-
- protected String findExtactHelpId(Component comp) {
- Container parent = comp.getParent();
- while (parent != null) {
- String id = cache.get(parent);
- if (id == null) {
- // ce container n'a pas d'id
- // on va directement sur le parent
- parent = parent.getParent();
- continue;
- }
- // le parent possède un id
- // on utilise cet id
- return id;
- }
- // on a pas trouve d'id
- // on retourne l'id par defaut
- return defaultID;
- }
- }
-
- protected AbstractButton getShowHelpButton(JAXXObject c) {
- return (AbstractButton) c.getObjectById("showHelp");
- }
-
- protected ActionListener getShowHelpAction() {
- return new ShowHelpForTrackedComponentAction();
- }
-
- //-------------------------------------------------------------------------
- //--- Copy CSH code but with accessible modifiers and little improvments
- //-------------------------------------------------------------------------
- /*
- * Get all top level containers to change it's cursors
- */
- protected Vector<?> getTopContainers(Object source) {
- // This method is used to obtain all top level components of application
- // for which the changing of cursor to question mark is wanted.
- // Method Frame.getFrames() is used to get list of Frames and
- // Frame.getOwnedWindows() method on elements of the list
- // returns all Windows, Dialogs etc. It works correctly in application.
- // Problem is in applets. There is no way how to get reference to applets
- // from elsewhere than applet itself. So, if request for CSH (this means
- // pressing help button or select help menu item) does't come from component
- // in a Applet, cursor for applets is not changed to question mark. Only for
- // Frames, Windows and Dialogs is cursor changed properly.
-
- Vector<Component> containers = new Vector<Component>();
- Component topComponent = null;
- topComponent = getRoot(source);
- if (topComponent instanceof Applet) {
- try {
- Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets();
- while (applets.hasMoreElements()) {
- containers.add(applets.nextElement());
- }
- } catch (NullPointerException npe) {
- containers.add(topComponent);
- }
- }
- Frame frames[] = Frame.getFrames();
- for (int i = 0; i < frames.length; i++) {
- Window[] windows = frames[i].getOwnedWindows();
- for (int j = 0; j < windows.length; j++) {
- containers.add(windows[j]);
- }
- if (!containers.contains(frames[i])) {
- containers.add(frames[i]);
- }
- }
- return containers;
- }
-
- protected Component getRoot(Object comp) {
- Object parent = comp;
- while (parent != null) {
- comp = parent;
- if (comp instanceof MenuComponent) {
- parent = ((MenuComponent) comp).getParent();
- } else if (comp instanceof Component) {
- if (comp instanceof Window) {
- break;
- }
- if (comp instanceof Applet) {
- break;
- }
- parent = ((Component) comp).getParent();
- } else {
- break;
- }
- }
- if (comp instanceof Component) {
- return ((Component) comp);
- }
- return null;
- }
-
- /*
- * Set the cursor for a component and its children.
- * Store the old cursors for future resetting
- */
- protected void setAndStoreCursors(Component comp, Cursor cursor) {
- if (comp == null) {
- return;
- }
- Cursor compCursor = comp.getCursor();
- if (compCursor != cursor) {
- cursors.put(comp, compCursor);
- log.debug("set cursor on " + comp);
- comp.setCursor(cursor);
- }
- if (comp instanceof Container) {
- Component component[] = ((Container) comp).getComponents();
- for (int i = 0; i < component.length; i++) {
- setAndStoreCursors(component[i], cursor);
- }
- }
- }
-
- /*
- * Actually restore the cursor for a component and its children
- */
- protected void resetAndRestoreCursors(Component comp) {
- if (comp == null) {
- return;
- }
- Cursor oldCursor = cursors.get(comp);
- if (oldCursor != null) {
- log.debug("restored cursor " + oldCursor + " on " + comp);
- comp.setCursor(oldCursor);
- }
- if (comp instanceof Container) {
- Component component[] = ((Container) comp).getComponents();
- for (int i = 0; i < component.length; i++) {
- resetAndRestoreCursors(component[i]);
- }
- }
- }
-
- /**
- * Context Sensitive Event Tracking
- *
- * Creates a new EventDispatchThread from which to dispatch events. This
- * method returns when stopModal is invoked.
- *
- * @return MouseEvent The mouse event occurred. Null if
- * cancelled on an undetermined object.
- */
- public static MouseEvent getMouseEvent() {
- // Should the cursor change to a quesiton mark here or
- // require the user to change the cursor externally to this method?
- // The problem is that each component can have it's own cursor.
- // For that reason it might be better to have the user change the
- // cusor rather than us.
-
- // To track context-sensitive events get the event queue and process
- // the events the same way EventDispatchThread does. Filter out
- // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???).
- // Note: This code only handles mouse events. Accessiblity might
- // require additional functionality or event trapping
-
- // If the eventQueue can't be retrieved, the thread gets interrupted,
- // or the thread isn't a instanceof EventDispatchThread then return
- // a null as we won't be able to trap events.
- try {
- if (EventQueue.isDispatchThread()) {
- EventQueue eq = null;
-
- // Find the eventQueue. If we can't get to it then just return
- // null since we won't be able to trap any events.
-
- try {
- eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
- } catch (Exception ee) {
- log.debug(ee);
- }
-
- // Safe guard
- if (eq == null) {
- return null;
- }
-
- int eventNumber = -1;
-
- // Process the events until an object has been selected or
- // the context-sensitive search has been canceled.
- while (true) {
- // This is essentially the body of EventDispatchThread
- // modified to trap context-senstive events and act
- // appropriately
- eventNumber++;
- AWTEvent event = eq.getNextEvent();
- Object src = event.getSource();
- // can't call eq.dispatchEvent
- // so I pasted it's body here
-
- if (log.isDebugEnabled()) {
- log.debug(event);
- }
-
- // Not sure if I should suppress ActiveEvents or not
- // Modal dialogs do. For now we will not suppress the
- // ActiveEvent events
-
- if (event instanceof ActiveEvent) {
- ((ActiveEvent) event).dispatch();
- continue;
- }
-
- if (src instanceof Component) {
- // Trap the context-sensitive events here
- if (event instanceof KeyEvent) {
- KeyEvent e = (KeyEvent) event;
- // if this is the cancel key then exit
- // otherwise pass all other keys up
- if (e.getKeyCode() == KeyEvent.VK_CANCEL ||
- e.getKeyCode() == KeyEvent.VK_ESCAPE) {
- e.consume();
- return null;
- } else {
- e.consume();
- // dispatchEvent(event);
- }
- } else if (event instanceof MouseEvent) {
- MouseEvent e = (MouseEvent) event;
- int eID = e.getID();
-
- if ((eID == MouseEvent.MOUSE_CLICKED ||
- eID == MouseEvent.MOUSE_PRESSED ||
- eID == MouseEvent.MOUSE_RELEASED) &&
- SwingUtilities.isRightMouseButton(e)) {
- // cancel tracking
- e.consume();
- if (log.isDebugEnabled()) {
- log.debug("tracking canceled!!!");
- }
- return null;
- }
-
- if ((eID == MouseEvent.MOUSE_CLICKED ||
- eID == MouseEvent.MOUSE_PRESSED ||
- eID == MouseEvent.MOUSE_RELEASED) &&
- SwingUtilities.isLeftMouseButton(e)) {
- if (eID == MouseEvent.MOUSE_CLICKED) {
- if (eventNumber == 0) {
- dispatchEvent(event);
- continue;
- }
- }
- e.consume();
- return e;
- } else {
- e.consume();
- }
- } else {
- dispatchEvent(event);
- }
- } else if (src instanceof MenuComponent) {
- if (event instanceof InputEvent) {
- ((InputEvent) event).consume();
- }
- } else {
- log.error("unable to dispatch event: " + event);
- }
- }
- }
- } catch (InterruptedException e) {
- if (log.isDebugEnabled()) {
- log.debug(e);
- }
- }
- if (log.isDebugEnabled()) {
- log.debug("Fall Through code");
- }
- return null;
- }
-
- private static void dispatchEvent(AWTEvent event) {
- Object src = event.getSource();
- if (event instanceof ActiveEvent) {
- // This could become the sole method of dispatching in time.
- ((ActiveEvent) event).dispatch();
- } else if (src instanceof Component) {
- ((Component) src).dispatchEvent(event);
- } else if (src instanceof MenuComponent) {
- ((MenuComponent) src).dispatchEvent(event);
- } else {
- log.error("unable to dispatch event: " + event);
- }
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,22 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.awt.Component;
-
-/**
- *
- * Contract to be added on JAXXObject wihch wants to use javax help.
- *
- * @param <B> type of broker.
- *
- * @author tony
- * @since 1.3
- * @see JaxxHelpBroker
- */
-public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
-
- B getBroker();
-
- void registerHelpId(B broker, Component component, String helpId);
-
- void showHelp(String helpId);
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java (from rev 1567, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpBroker.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,564 @@
+package jaxx.runtime.swing.help;
+
+import java.applet.Applet;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.InputEvent;
+import java.awt.event.KeyEvent;
+import java.awt.event.MouseEvent;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Locale;
+import java.util.Map;
+import java.util.Vector;
+import javax.help.CSH;
+import javax.help.HelpBroker;
+import javax.help.HelpSet;
+import javax.swing.AbstractButton;
+import javax.swing.SwingUtilities;
+import javax.swing.UIManager;
+import jaxx.runtime.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * La classe pour encapsuler l'aide de l'application.
+ *
+ * @author tony
+ * @since 1.4
+ */
+public class JAXXHelpBroker {
+
+ public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
+ /**
+ * Logger
+ */
+ static private Log log = LogFactory.getLog(JAXXHelpBroker.class);
+ /**
+ * name of helpset
+ */
+ protected final String helpsetName;
+ /**
+ * default id to use if none given
+ */
+ protected final String defaultID;
+ /**
+ * help key
+ */
+ protected final String helpKey;
+ /**
+ * helpset to use
+ */
+ protected HelpSet helpset;
+ /**
+ * help broker
+ */
+ protected HelpBroker helpBroker;
+ /**
+ * current locale used
+ */
+ protected Locale locale;
+ /**
+ * cache of cursors modified when in context-sensitive mode
+ */
+ protected Hashtable<Component, Cursor> cursors;
+ /**
+ * cursor to use in context-sensitive mode
+ */
+ protected Cursor onItemCursor;
+ /**
+ * cache of component which cursor have been modified
+ */
+ protected final Map<Component, String> cache;
+ /**
+ * help ui handler
+ */
+ protected JAXXHelpUIHandler handler;
+
+ public JAXXHelpBroker(String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) {
+ this(null, helpsetName, helpKey, defaultID, handler);
+ }
+
+ public JAXXHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID, JAXXHelpUIHandler handler) {
+ if (helpsetName == null) {
+ throw new NullPointerException("parameter helpsetName can not be null!");
+ }
+ if (handler == null) {
+ throw new NullPointerException("handler can not be null");
+ }
+ this.locale = locale;
+ this.helpsetName = helpsetName;
+ this.helpKey = helpKey;
+ this.defaultID = defaultID;
+ this.handler = handler;
+ this.cache = new HashMap<Component, String>();
+ }
+
+ public void prepareUI(JAXXObject c) {
+ if (c == null) {
+ throw new NullPointerException("parameter c can not be null!");
+ }
+
+ // l'ui doit avoir un boutton showHelp
+ AbstractButton help = getShowHelpButton(c);
+
+ if (help == null) {
+ // no showHelp button
+ return;
+ }
+
+ // attach context to button
+ if (log.isDebugEnabled()) {
+ log.debug("attach context to showhelp button " + c);
+ }
+ help.putClientProperty(JAXX_CONTEXT_ENTRY, c);
+
+ // add tracking action
+ ActionListener listener = getShowHelpAction();
+ if (log.isDebugEnabled()) {
+ log.debug("adding tracking action " + listener);
+ }
+ help.addActionListener(listener);
+
+ if (log.isDebugEnabled()) {
+ log.debug("done for " + c);
+ }
+
+
+ getHelpBroker().enableHelpKey(((Component) c), getDefaultID(), getHelpset());
+ }
+
+ public void showHelp(JAXXContext context, String helpId) {
+ getHandler().showHelp(context, this, helpId);
+ }
+
+ public JAXXHelpUIHandler getHandler() {
+ return handler;
+ }
+
+ public HelpBroker getHelpBroker() {
+ if (helpBroker == null) {
+ helpBroker = getHelpset().createHelpBroker();
+ }
+ return helpBroker;
+ }
+
+ public String getHelpKey() {
+ return helpKey;
+ }
+
+ public HelpSet getHelpset() {
+ if (helpset == null) {
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, helpsetName, locale);
+ helpset = new HelpSet(cl, url);
+ } catch (Exception ee) {
+ throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+ }
+ }
+ return helpset;
+ }
+
+ public String getHelpsetName() {
+ return helpsetName;
+ }
+
+ public String getDefaultID() {
+ return defaultID;
+ }
+
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ // need to reload helpset and helpbroker
+ helpset = null;
+ helpBroker = null;
+ getHelpset();
+ getHelpBroker();
+ }
+
+ public void showHelpSet() {
+ if (log.isDebugEnabled()) {
+ log.debug(this);
+ }
+ new CSH.DisplayHelpFromSource(getHelpBroker());
+ }
+
+ public void installUI(Component comp, String helpId) {
+ CSH.setHelpIDString(comp, helpId);
+ if (log.isDebugEnabled()) {
+ log.debug(helpId + " : " + comp.getName());
+ }
+ cache.put(comp, helpId);
+ }
+
+ public class ShowHelpForTrackedComponentAction implements ActionListener {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AbstractButton source = (AbstractButton) e.getSource();
+
+ JAXXContext context = (JAXXContext) source.getClientProperty(JAXX_CONTEXT_ENTRY);
+
+ // prepare cursor
+ onItemCursor = (Cursor) UIManager.get("HelpOnItemCursor");
+ Vector<?> topComponents = null;
+ cursors = null;
+
+ if (onItemCursor != null) {
+ cursors = new Hashtable<Component, Cursor>();
+ topComponents = getTopContainers(source);
+ Enumeration<?> enums = topComponents.elements();
+ while (enums.hasMoreElements()) {
+ setAndStoreCursors((Container) enums.nextElement(), onItemCursor);
+ }
+ }
+
+ // get the tracked component
+ Component comp = null;
+ try {
+ MouseEvent event = getMouseEvent();
+ if (event == null) {
+ // tracking canceled
+ return;
+ }
+ comp = (Component) event.getSource();
+ if (log.isDebugEnabled()) {
+ log.debug("component traking " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ comp = SwingUtil.getDeepestObjectAt(comp, event.getX(), event.getY());
+ if (log.isDebugEnabled()) {
+ log.debug("deepest component " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ } finally {
+ // restore the old cursors
+ if (topComponents != null) {
+ Enumeration<?> containers = topComponents.elements();
+ while (containers.hasMoreElements()) {
+ resetAndRestoreCursors((Container) containers.nextElement());
+ }
+ }
+ cursors = null;
+ }
+
+ String helpID = findHelpId(comp);
+ showHelp(context, helpID);
+ }
+
+ public String findHelpId(Component comp) {
+ String helpID = CSH.getHelpIDString(comp);
+ if (defaultID.equals(helpID)) {
+ String id = cache.get(comp);
+ // on verifie qu'on est bien sur sur le bon id
+ if (helpID.equals(id)) {
+ // ok
+ return helpID;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will try to find better id for comp : " + comp.getName());
+ }
+ // on est pas sur le bon id
+ // on recherche parmis les parents
+ helpID = findExtactHelpId(comp);
+ }
+ if (log.isInfoEnabled()) {
+ log.info("helpID " + helpID + " for comp " + comp.getName() + " : " + comp.getClass().getName());
+ }
+ return helpID;
+ }
+
+ protected String findExtactHelpId(Component comp) {
+ Container parent = comp.getParent();
+ while (parent != null) {
+ String id = cache.get(parent);
+ if (id == null) {
+ // ce container n'a pas d'id
+ // on va directement sur le parent
+ parent = parent.getParent();
+ continue;
+ }
+ // le parent possède un id
+ // on utilise cet id
+ return id;
+ }
+ // on a pas trouve d'id
+ // on retourne l'id par defaut
+ return defaultID;
+ }
+ }
+
+ protected AbstractButton getShowHelpButton(JAXXObject c) {
+ return (AbstractButton) c.getObjectById("showHelp");
+ }
+
+ protected ActionListener getShowHelpAction() {
+ return new ShowHelpForTrackedComponentAction();
+ }
+
+ //-------------------------------------------------------------------------
+ //--- Copy CSH code but with accessible modifiers and little improvments
+ //-------------------------------------------------------------------------
+ /*
+ * Get all top level containers to change it's cursors
+ */
+ protected Vector<?> getTopContainers(Object source) {
+ // This method is used to obtain all top level components of application
+ // for which the changing of cursor to question mark is wanted.
+ // Method Frame.getFrames() is used to get list of Frames and
+ // Frame.getOwnedWindows() method on elements of the list
+ // returns all Windows, Dialogs etc. It works correctly in application.
+ // Problem is in applets. There is no way how to get reference to applets
+ // from elsewhere than applet itself. So, if request for CSH (this means
+ // pressing help button or select help menu item) does't come from component
+ // in a Applet, cursor for applets is not changed to question mark. Only for
+ // Frames, Windows and Dialogs is cursor changed properly.
+
+ Vector<Component> containers = new Vector<Component>();
+ Component topComponent = null;
+ topComponent = getRoot(source);
+ if (topComponent instanceof Applet) {
+ try {
+ Enumeration<Applet> applets = ((Applet) topComponent).getAppletContext().getApplets();
+ while (applets.hasMoreElements()) {
+ containers.add(applets.nextElement());
+ }
+ } catch (NullPointerException npe) {
+ containers.add(topComponent);
+ }
+ }
+ Frame frames[] = Frame.getFrames();
+ for (int i = 0; i < frames.length; i++) {
+ Window[] windows = frames[i].getOwnedWindows();
+ for (int j = 0; j < windows.length; j++) {
+ containers.add(windows[j]);
+ }
+ if (!containers.contains(frames[i])) {
+ containers.add(frames[i]);
+ }
+ }
+ return containers;
+ }
+
+ protected Component getRoot(Object comp) {
+ Object parent = comp;
+ while (parent != null) {
+ comp = parent;
+ if (comp instanceof MenuComponent) {
+ parent = ((MenuComponent) comp).getParent();
+ } else if (comp instanceof Component) {
+ if (comp instanceof Window) {
+ break;
+ }
+ if (comp instanceof Applet) {
+ break;
+ }
+ parent = ((Component) comp).getParent();
+ } else {
+ break;
+ }
+ }
+ if (comp instanceof Component) {
+ return ((Component) comp);
+ }
+ return null;
+ }
+
+ /*
+ * Set the cursor for a component and its children.
+ * Store the old cursors for future resetting
+ */
+ protected void setAndStoreCursors(Component comp, Cursor cursor) {
+ if (comp == null) {
+ return;
+ }
+ Cursor compCursor = comp.getCursor();
+ if (compCursor != cursor) {
+ cursors.put(comp, compCursor);
+ log.debug("set cursor on " + comp);
+ comp.setCursor(cursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ setAndStoreCursors(component[i], cursor);
+ }
+ }
+ }
+
+ /*
+ * Actually restore the cursor for a component and its children
+ */
+ protected void resetAndRestoreCursors(Component comp) {
+ if (comp == null) {
+ return;
+ }
+ Cursor oldCursor = cursors.get(comp);
+ if (oldCursor != null) {
+ log.debug("restored cursor " + oldCursor + " on " + comp);
+ comp.setCursor(oldCursor);
+ }
+ if (comp instanceof Container) {
+ Component component[] = ((Container) comp).getComponents();
+ for (int i = 0; i < component.length; i++) {
+ resetAndRestoreCursors(component[i]);
+ }
+ }
+ }
+
+ /**
+ * Context Sensitive Event Tracking
+ *
+ * Creates a new EventDispatchThread from which to dispatch events. This
+ * method returns when stopModal is invoked.
+ *
+ * @return MouseEvent The mouse event occurred. Null if
+ * cancelled on an undetermined object.
+ */
+ public static MouseEvent getMouseEvent() {
+ // Should the cursor change to a quesiton mark here or
+ // require the user to change the cursor externally to this method?
+ // The problem is that each component can have it's own cursor.
+ // For that reason it might be better to have the user change the
+ // cusor rather than us.
+
+ // To track context-sensitive events get the event queue and process
+ // the events the same way EventDispatchThread does. Filter out
+ // ContextSensitiveEvents SelectObject & Cancel (MouseDown & ???).
+ // Note: This code only handles mouse events. Accessiblity might
+ // require additional functionality or event trapping
+
+ // If the eventQueue can't be retrieved, the thread gets interrupted,
+ // or the thread isn't a instanceof EventDispatchThread then return
+ // a null as we won't be able to trap events.
+ try {
+ if (EventQueue.isDispatchThread()) {
+ EventQueue eq = null;
+
+ // Find the eventQueue. If we can't get to it then just return
+ // null since we won't be able to trap any events.
+
+ try {
+ eq = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ } catch (Exception ee) {
+ log.debug(ee);
+ }
+
+ // Safe guard
+ if (eq == null) {
+ return null;
+ }
+
+ int eventNumber = -1;
+
+ // Process the events until an object has been selected or
+ // the context-sensitive search has been canceled.
+ while (true) {
+ // This is essentially the body of EventDispatchThread
+ // modified to trap context-senstive events and act
+ // appropriately
+ eventNumber++;
+ AWTEvent event = eq.getNextEvent();
+ Object src = event.getSource();
+ // can't call eq.dispatchEvent
+ // so I pasted it's body here
+
+ if (log.isDebugEnabled()) {
+ log.debug(event);
+ }
+
+ // Not sure if I should suppress ActiveEvents or not
+ // Modal dialogs do. For now we will not suppress the
+ // ActiveEvent events
+
+ if (event instanceof ActiveEvent) {
+ ((ActiveEvent) event).dispatch();
+ continue;
+ }
+
+ if (src instanceof Component) {
+ // Trap the context-sensitive events here
+ if (event instanceof KeyEvent) {
+ KeyEvent e = (KeyEvent) event;
+ // if this is the cancel key then exit
+ // otherwise pass all other keys up
+ if (e.getKeyCode() == KeyEvent.VK_CANCEL ||
+ e.getKeyCode() == KeyEvent.VK_ESCAPE) {
+ e.consume();
+ return null;
+ } else {
+ e.consume();
+ // dispatchEvent(event);
+ }
+ } else if (event instanceof MouseEvent) {
+ MouseEvent e = (MouseEvent) event;
+ int eID = e.getID();
+
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isRightMouseButton(e)) {
+ // cancel tracking
+ e.consume();
+ if (log.isDebugEnabled()) {
+ log.debug("tracking canceled!!!");
+ }
+ return null;
+ }
+
+ if ((eID == MouseEvent.MOUSE_CLICKED ||
+ eID == MouseEvent.MOUSE_PRESSED ||
+ eID == MouseEvent.MOUSE_RELEASED) &&
+ SwingUtilities.isLeftMouseButton(e)) {
+ if (eID == MouseEvent.MOUSE_CLICKED) {
+ if (eventNumber == 0) {
+ dispatchEvent(event);
+ continue;
+ }
+ }
+ e.consume();
+ return e;
+ } else {
+ e.consume();
+ }
+ } else {
+ dispatchEvent(event);
+ }
+ } else if (src instanceof MenuComponent) {
+ if (event instanceof InputEvent) {
+ ((InputEvent) event).consume();
+ }
+ } else {
+ log.error("unable to dispatch event: " + event);
+ }
+ }
+ }
+ } catch (InterruptedException e) {
+ if (log.isDebugEnabled()) {
+ log.debug(e);
+ }
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("Fall Through code");
+ }
+ return null;
+ }
+
+ private static void dispatchEvent(AWTEvent event) {
+ Object src = event.getSource();
+ if (event instanceof ActiveEvent) {
+ // This could become the sole method of dispatching in time.
+ ((ActiveEvent) event).dispatch();
+ } else if (src instanceof Component) {
+ ((Component) src).dispatchEvent(event);
+ } else if (src instanceof MenuComponent) {
+ ((MenuComponent) src).dispatchEvent(event);
+ } else {
+ log.error("unable to dispatch event: " + event);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java (from rev 1567, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUI.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,22 @@
+package jaxx.runtime.swing.help;
+
+import java.awt.Component;
+
+/**
+ *
+ * Contract to be added on JAXXObject which wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JAXXHelpBroker
+ */
+public interface JAXXHelpUI<B extends JAXXHelpBroker> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Added: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,12 @@
+package jaxx.runtime.swing.help;
+
+import jaxx.runtime.JAXXContext;
+
+/**
+ *
+ * @author chemit
+ */
+public interface JAXXHelpUIHandler {
+
+ void showHelp(JAXXContext context, JAXXHelpBroker broker, String helpID);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/help/JAXXHelpUIHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -41,12 +41,6 @@
*/
protected MavenProject project;
/**
- * Repertoire de destination des fichiers java a generer.
- *
- * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
- */
- protected File outJava;
- /**
* verbose flag
*
* @parameter expression="${jaxx.verbose}" default-value="false"
@@ -55,72 +49,15 @@
*/
protected boolean verbose;
/**
- * to make compiler i18nable, says add the {@link org.nuiton.i18n.I18n#_(String, Object[])} method
- * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes.
- *
- * @parameter expression="${jaxx.i18nable}" default-value="true"
- * @see jaxx.compiler.I18nHelper
- */
- protected boolean i18nable;
- /**
- * The store of helpIds generated by {@link JaxxGeneratorMojo}.
- * <p/>
- *
- * @parameter expression="${jaxx.helpIdStore}" default-value="target/helpIds.properties"
+ * The store of helpIds generated by the goal {@link GenerateMojo} and then
+ * used by the goal {@link GenerateHelpMojo}.
+ *
+ * @parameter expression="${jaxx.helpIdsStore}" default-value="target/helpIds.properties"
* @required
*
* @since 1.3
*/
- protected File helpIdStore;
- /**
- * The name of the helpset to generate.
- *
- * @parameter expression="${jaxx.helpSetName}" default-value="${project.artifactId}"
- * @required
- *
- * @since 1.3
- */
- protected String helpSetName;
- /**
- * The prefix to add to i18n key for any help i18n key.
- *
- * @parameter expression="${jaxx.helpsetI18nPrefix}" default-value="${jaxx.helpSetName}.help."
- * @required
- *
- * @since 1.3
- */
- protected String helpsetI18nPrefix;
- /**
- * The suffix to add to i18n key for an help Id.
- *
- * @parameter expression="${jaxx.helpsetTitleI18nSuffix}" default-value=".title"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetTitleI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @parameter expression="${jaxx.helpsetTocI18nSuffix}" default-value=".toc"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetTocI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @parameter expression="${jaxx.helpsetIndexI18nSuffix}" default-value=".index"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetIndexI18nSuffix;
- /**
- *
- */
- protected ClassLoader cl;
+ protected File helpIdsStore;
@Override
protected boolean checkPackaging() {
@@ -146,4 +83,12 @@
public void setVerbose(boolean verbose) {
this.verbose = verbose;
}
+
+ public File getHelpIdsStore() {
+ return helpIdsStore;
+ }
+
+ public void setHelpIdsStore(File helpIdsStore) {
+ this.helpIdsStore = helpIdsStore;
+ }
}
Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java (from rev 1566, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java)
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateHelpMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,520 @@
+/* *##%
+ * Copyright (C) 2007
+ * JaxxPlugin, Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+package org.nuiton.jaxx.plugin;
+
+import org.apache.maven.plugin.MojoFailureException;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Locale;
+import java.util.Properties;
+import org.nuiton.i18n.I18n;
+import org.nuiton.util.FileUtil;
+import org.nuiton.util.SortedProperties;
+
+/**
+ * Mojo to generate javax help stuff for your project.
+ *
+ * HelpIds should have been discovered by the JaxxMojo.
+ *
+ * @author chemit
+ * @goal generate-help
+ * @phase process-sources
+ *
+ * @requiresProject
+ * @requiresDependencyResolution compile
+ * @since 1.3
+ */
+public class GenerateHelpMojo extends AbstractJaxxMojo {
+
+ private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
+ /**
+ * The directory where to generate help files.
+ *
+ * @parameter expression="${jaxx.outHelp}" default-value="${project.basedir}/src/main/help"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File outHelp;
+ /**
+ * The locales to generate for help, seprated by comma.
+ *
+ * The first locale given is the default locale.
+ *
+ * @parameter expression="${jaxx.locales}"
+ * @required
+ *
+ * @since 2.0.0
+ */
+ protected String locales;
+ /**
+ * The name of the helpset to generate.
+ *
+ * @parameter expression="${jaxx.helpsetName}" default-value="${project.artifactId}"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected String helpsetName;
+ /**
+ * The template used to generate helpset file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.helpsetTemplate}" default-value="/defaultHelpSet.hs.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File helpsetTemplate;
+ /**
+ * The template used to generate helpset map file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File mapTemplate;
+ /**
+ * The template used to generate helpset index file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File indexTemplate;
+ /**
+ * The template used to generate helpset toc file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File tocTemplate;
+ /**
+ * The template used to generate helpset content file.
+ *
+ * Must be an existing file or a ressource in classp-ath
+ *
+ * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
+ * @required
+ *
+ * @since 1.3
+ */
+ protected File contentTemplate;
+ /**
+ * The help ids discovered in {@link #helpIdsStore} files.
+ */
+ private Properties helpIds;
+ /**
+ * Default locale (the first locale in {@link #localesToTreate}.
+ */
+ private Locale defaultLocale;
+ /**
+ * Locales to treate
+ */
+ private Locale[] localesToTreate;
+
+ @Override
+ public boolean init() throws Exception {
+
+ File idsStore = getHelpIdsStore();
+
+ if (!idsStore.exists()) {
+ getLog().info("no helpIdStore to react at " + idsStore);
+ return false;
+ }
+
+ if (locales == null || locales.trim().isEmpty()) {
+ throw new MojoFailureException("You must set the 'locales' property properly (was " + locales + ").");
+ }
+
+ // check there is a outHelp
+ if (outHelp == null) {
+ throw new MojoFailureException("You must set the 'target' property.");
+ }
+
+ List<Locale> tmp = new ArrayList<Locale>();
+ for (String loc : locales.split(",")) {
+ Locale l = I18n.newLocale(loc);
+ tmp.add(l);
+ }
+
+ if (tmp.isEmpty()) {
+ throw new MojoFailureException("you must set the 'locales' property.");
+ }
+
+ localesToTreate = tmp.toArray(new Locale[tmp.size()]);
+ defaultLocale = localesToTreate[0];
+
+ // check ressources
+ checkResource(helpsetTemplate);
+ checkResource(mapTemplate);
+ checkResource(indexTemplate);
+ checkResource(tocTemplate);
+ checkResource(contentTemplate);
+
+ if (!outHelp.exists()) {
+ getLog().info("mkdir " + outHelp);
+ outHelp.mkdirs();
+ }
+
+ helpIds = new SortedProperties();
+
+ InputStream stream = new FileInputStream(idsStore);
+
+ try {
+ helpIds.load(stream);
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
+ }
+
+ if (helpIds.isEmpty()) {
+
+ // no ids detected
+ getLog().warn("No helpIds detected, will skip.");
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public void doAction() throws Exception {
+
+ int touchedFiles = 0;
+
+ String mapFileName = helpsetName + "Map.jhm";
+ String indexFileName = helpsetName + "Index.xml";
+ String tocFileName = helpsetName + "TOC.xml";
+
+ for (Locale locale : localesToTreate) {
+
+ boolean isDefaultLocale = locale == defaultLocale;
+
+ String language = locale.getLanguage();
+
+ String localePath = (isDefaultLocale ? "default" : language);
+
+ File localizedTarget = new File(outHelp, localePath);
+
+ if (!localizedTarget.exists()) {
+ localizedTarget.mkdirs();
+ }
+ getLog().info("Generate help for language " + language);
+ getLog().info(" Localized target : " + localizedTarget);
+
+ Properties env = new Properties();
+
+ env.put("helpSetName", helpsetName);
+ env.put("locale", language);
+ env.put("localePath", localePath);
+ env.put("separator", " ");
+ env.put("autoremoveLine", AUTOREMOVE_LINE);
+
+ String localeSuffix = isDefaultLocale ? "" : "_" + language;
+ String helpsetFileName = helpsetName + localeSuffix + ".hs";
+
+ env.put("helpSetFileName", helpsetFileName);
+
+ env.put("mapFileName", mapFileName);
+ env.put("indexFileName", indexFileName);
+ env.put("tocFileName", tocFileName);
+// env.put("searchData", localePath + "/index");
+
+ // ---------------------------------------------------------------
+ // --- main helpset file -----------------------------------------
+ // ---------------------------------------------------------------
+
+ File file = new File(outHelp, helpsetFileName);
+
+ boolean doCreate = generateHelpsetFile(file, env);
+
+ if (doCreate) {
+ touchedFiles++;
+ }
+
+ // ---------------------------------------------------------------
+ // --- helpset map file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, mapFileName);
+
+ Properties mergedHelpIds = generateMapFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset index file ----------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, indexFileName);
+
+ NodeItem indexRootItem = generateIndexFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset toc file ------------------------------------------
+ // ---------------------------------------------------------------
+
+ file = new File(localizedTarget, tocFileName);
+
+ NodeItem tocRootItem = generateTocFile(file, env);
+ touchedFiles++;
+
+ // ---------------------------------------------------------------
+ // --- helpset content files -------------------------------------
+ // ---------------------------------------------------------------
+
+ touchedFiles += generateContentFiles(localizedTarget, env, localePath);
+
+ }
+
+ getLog().info(touchedFiles + " file(s) treated.");
+ }
+
+ protected int generateContentFiles(File localizedTarget, Properties env, String localePath) throws Exception {
+
+ int touchedFiles = 0;
+ TemplateGenerator gen = prepareGenerator(contentTemplate);
+ Enumeration<?> keys = helpIds.keys();
+ while (keys.hasMoreElements()) {
+ String key = (String) keys.nextElement();
+ String url = (String) helpIds.get(key);
+ url = helpsetName + File.separator + url;
+ File f = new File(localizedTarget, url);
+ boolean exist = f.exists();
+ if (exist) {
+ // check if there is a autoremoveLine in content
+ String content = FileUtil.readAsString(f);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (verbose) {
+ getLog().debug("skip existing file " + f);
+ }
+ continue;
+ }
+ }
+ f.getParentFile().mkdirs();
+ if (verbose) {
+ if (exist) {
+ getLog().info("regenerate content file " + f);
+ } else {
+ getLog().info("generate content file " + f);
+ }
+ }
+ env.put("helpId", key);
+ env.put("helpIdUrl", localePath + "/" + url);
+ gen.generate(env, f);
+ touchedFiles++;
+ }
+ return touchedFiles;
+ }
+
+ protected boolean generateHelpsetFile(File file, Properties env) throws Exception {
+
+ if (file.exists()) {
+ // check the autoremove line presence
+ String content = FileUtil.readAsString(file);
+ if (!content.contains(AUTOREMOVE_LINE)) {
+ // no regenerate marker detected, so skip this file
+ if (verbose) {
+ getLog().info("skip existing helpset main file " + file);
+ }
+ return false;
+ }
+ }
+
+ if (verbose) {
+ if (file.exists()) {
+ getLog().info("regenerate helpset main file " + file);
+ } else {
+ getLog().info("generate helpset main file " + file);
+ }
+ }
+ doGen(helpsetTemplate, file, env);
+ return true;
+ }
+
+ protected Properties generateMapFile(File file, Properties env) throws Exception {
+
+ boolean create;
+
+ Properties mergedHelpIds = null;
+ if (file.exists()) {
+
+ // get back the exisiting data and merge it with incoming ones
+
+ if (verbose) {
+ getLog().info("loading existing helpset map file " + file);
+ }
+
+ mergedHelpIds = XmlHelper.getExistingHelpIds(file, verbose, getLog());
+ create = false;
+
+ } else {
+
+ mergedHelpIds = new SortedProperties();
+ create = true;
+ }
+
+ // inject new helpIds
+
+ for (Object k : helpIds.keySet()) {
+ mergedHelpIds.put(k, helpsetName + "/" + helpIds.get(k));
+ }
+
+ if (!mergedHelpIds.contains("top")) {
+
+ // on ajoute une entree vers le root du helpset
+
+ String topUrl = helpsetName + ".html";
+ helpIds.put("top", topUrl);
+ mergedHelpIds.put("top", helpsetName + "/" + topUrl);
+ if (verbose) {
+ getLog().debug("add top entry with url " + topUrl);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset map file " + file);
+ } else {
+ getLog().info("udpate helpset map file " + file);
+ }
+ }
+
+ env.put("helpIds", mergedHelpIds);
+ doGen(mapTemplate, file, env);
+ env.remove("helpIds");
+ return mergedHelpIds;
+ }
+
+ protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = XmlHelper.getExistingItems("indexitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpsetName);
+ }
+
+ // inject new index entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (verbose) {
+ getLog().debug("index " + k + " : " + toc);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset index file " + file);
+ } else {
+ getLog().info("udpate helpset index file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(indexTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected NodeItem generateTocFile(File file, Properties env) throws Exception {
+ NodeItem rootItem = null;
+
+ boolean create;
+
+ if (file.exists()) {
+
+ create = false;
+
+ rootItem = XmlHelper.getExistingItems("tocitem", file);
+ } else {
+ create = true;
+ }
+
+ if (rootItem == null) {
+ rootItem = new NodeItem("top", helpsetName);
+ }
+ // inject new toc entries
+
+ for (Object k : helpIds.keySet()) {
+ NodeItem toc = rootItem.findChild(k + "");
+ if (verbose) {
+ getLog().debug("toc " + k + " : " + toc);
+ }
+ }
+
+ if (verbose) {
+ if (create) {
+ getLog().info("generate helpset toc file " + file);
+ } else {
+ getLog().info("udpate helpset toc file " + file);
+ }
+ }
+
+ env.put("rootItem", rootItem);
+ doGen(tocTemplate, file, env);
+ env.remove("rootItem");
+ return rootItem;
+ }
+
+ protected void doGen(File template, File f, Properties env) throws Exception {
+ TemplateGenerator gen = prepareGenerator(template);
+ gen.generate(env, f);
+ }
+
+ protected TemplateGenerator prepareGenerator(File template) throws Exception {
+ URL templateURL = getTemplate(template);
+
+ if (verbose) {
+ getLog().info("using template " + templateURL);
+ }
+ TemplateGenerator gen = new TemplateGenerator(project, templateURL);
+ return gen;
+ }
+}
Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java (from rev 1567, branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java)
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/GenerateMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,683 @@
+/* *##%
+ * Copyright (C) 2007
+ * JaxxPlugin, Code Lutin
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * 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 Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+ *##%*/
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.CompilerConfiguration;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.beans.BeanInfoUtil;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+import jaxx.compiler.tags.TagManager;
+import jaxx.runtime.JAXXContext;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
+import org.apache.maven.plugin.MojoExecutionException;
+import org.apache.maven.plugin.MojoFailureException;
+import org.apache.maven.project.MavenProject;
+
+import org.nuiton.io.FileUpdaterHelper;
+import org.nuiton.io.MirroredFileUpdater;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.util.Map;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Properties;
+import java.util.Set;
+import jaxx.runtime.swing.help.JAXXHelpBroker;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ * Generates some java code from jaxx files.
+ *
+ * @author chemit
+ * @goal generate
+ * @phase process-sources
+ * @requiresDependencyResolution compile
+ * @requiresProject
+ */
+public class GenerateMojo extends AbstractJaxxMojo implements CompilerConfiguration {
+
+ /**
+ * Default includes to use, if none provided
+ */
+ private static final String[] INCLUDES = {"**\\/*.jaxx"};
+ /**
+ * Repertoire sources des fichiers jaxx a generer.
+ *
+ * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
+ */
+ protected File src;
+ /**
+ * Repertoire de destination des fichiers java a generer.
+ *
+ * @parameter expression="${jaxx.outJava}" default-value="${basedir}/target/generated-sources/java"
+ */
+ protected File outJava;
+ /**
+ * pour filter les fichiers a traiter
+ *
+ * @parameter expression="${jaxx.includes}"
+ */
+ protected String[] includes;
+ /**
+ * pour filter les fichiers a ne pas traiter
+ *
+ * @parameter expression="${jaxx.excludes}"
+ */
+ protected String[] excludes;
+ /**
+ * Le compilateur à utiliser (par défaut celui de Swing)
+ *
+ * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler"
+ */
+ protected String compilerFQN;
+ /**
+ * Le compilateur à utiliser (par défaut celui de Swing)
+ *
+ * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
+ */
+ protected String validatorFQN;
+ /**
+ * the name of implementation of {@link jaxx.runtime.JAXXContext}
+ * to be used on {@link jaxx.runtime.JAXXObject}.
+ * <p/>
+ * Must not be abstract.
+ *
+ * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext"
+ * @required
+ */
+ protected String jaxxContextFQN;
+ /**
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
+ *
+ * @parameter expression="${jaxx.defaultErrorUIFQN}"
+ */
+ protected String defaultErrorUIFQN;
+ /**
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
+ *
+ * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
+ *
+ * @see jaxx.compiler.decorators.CompiledObjectDecorator
+ */
+ protected String defaultDecoratorFQN;
+ /**
+ * flag to include in compiler classpath the java sources directories (src and outJava).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false"
+ */
+ protected boolean addSourcesToClassPath;
+ /**
+ * flag to include in compiler classpath the java resources directories (src and outJava).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addResourcesToClassPath}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean addResourcesToClassPath;
+ /**
+ * flag to include in compiler classpath the compile class-path (can only be used in a test phase).
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addCompileClassPath}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean addCompileClassPath;
+ /**
+ * flag to include in compiler classpath the project compile classpath.
+ * <p/>
+ * By default, false.
+ *
+ * @parameter expression="${jaxx.addProjectClassPath}" default-value="false"
+ */
+ protected boolean addProjectClassPath;
+ /**
+ * to force generation of java source for any jaxx files with no timestamp checking.
+ * <p/>
+ * By default, never force generation.
+ *
+ * @parameter expression="${jaxx.force}" default-value="false"
+ */
+ protected boolean force;
+ /**
+ * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
+ *
+ * @parameter expression="${jaxx.testPhase}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean testPhase;
+ /**
+ * to make compiler i18nable, says add the {@link org.nuiton.i18n.I18n#_(String, Object[])} method
+ * invocation on {@link jaxx.compiler.I18nHelper#I18N_ATTRIBUTES} attributes.
+ *
+ * @parameter expression="${jaxx.i18nable}" default-value="true"
+ * @see jaxx.compiler.I18nHelper
+ */
+ protected boolean i18nable;
+ /**
+ * pour optimizer le code compile ou genere ?
+ *
+ * @parameter expression="${jaxx.optimize}" default-value="false"
+ */
+ protected boolean optimize;
+ /**
+ * flag to add logger to each generated jaxx file.
+ * <p/>
+ * By default, always add it.
+ *
+ * @parameter expression="${jaxx.addLogger}" default-value="true"
+ */
+ protected boolean addLogger;
+ /**
+ * flag to keep compilers after the generate operation (usefull for tests.
+ * <p/>
+ * By default, always reset.
+ *
+ * @parameter expression="${jaxx.resetAfterCompile}" default-value="true"
+ */
+ protected boolean resetAfterCompile;
+ /**
+ * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
+ * <p/>
+ * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
+ * <p/>
+ * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}.
+ * <p/>
+ * <p/>
+ * This permit to use real beanInfo of imported graphic libraries.
+ *
+ * @parameter expression="${jaxx.beanInfoSearchPath}"
+ */
+ protected String[] beanInfoSearchPath;
+ /**
+ * list of fqn of class toimport for all generated jaxx files
+ *
+ * @parameter expression="${jaxx.extraImportList}"
+ */
+ protected String extraImportList;
+ /**
+ * a flag to use UIManager to retreave icons.
+ *
+ * @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
+ */
+ protected boolean useUIManagerForIcon;
+ /**
+ * flag to activate profile mode.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.profile}" default-value="false"
+ */
+ protected boolean profile;
+ /**
+ * flag to activate help generation process.
+ * <p/>
+ * By default, not active.
+ *
+ * @parameter expression="${jaxx.generateHelp}" default-value="false"
+ *
+ * @since 1.3
+ */
+ protected boolean generateHelp;
+ /**
+ * the FQN of help broker
+ * <p/>
+ * By default, use the JAXX implementation {@link JAXXHelpBroker}.
+ *
+ * @parameter expression="${jaxx.helpBrokerFQN}" default-value="jaxx.runtime.swing.help.JAXXHelpBroker"
+ *
+ * @since 1.3
+ */
+ protected String helpBrokerFQN;
+ /**
+ * detected jaxx files in {@link #init()} method
+ */
+ protected String[] files;
+ /**
+ * file updater used to detect jaxx files.
+ *
+ * <b>Note:</b> if {@link #verbose} flag is on, will ne be used
+ */
+ protected MirroredFileUpdater updater;
+ /**
+ *
+ */
+ private Class<?> defaultErrorUIClass;
+ /**
+ *
+ */
+ private Class<?> validatorClass;
+ /**
+ *
+ */
+ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
+ /**
+ *
+ */
+ private Class<? extends JAXXContext> jaxxContextClass;
+ /**
+ *
+ */
+ private Class<? extends JAXXCompiler> compilerClass;
+ /**
+ *
+ */
+ private String[] extraImports;
+ /**
+ *
+ */
+ private boolean nofiles;
+ /**
+ *
+ */
+ protected ClassLoader cl;
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public boolean init() throws Exception {
+
+ if (generateHelp) {
+ // check there is some bundle
+ if (getHelpIdsStore() == null) {
+ throw new MojoFailureException("you must set the 'helpIdStore' property.");
+ }
+ }
+
+ fixCompileSourceRoots();
+
+ if (includes == null || includes.length == 0) {
+ // use default includes
+ includes = INCLUDES;
+ }
+ updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
+
+ Map<File, String[]> result = new HashMap<File, String[]>();
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
+
+ this.files = result.get(src);
+
+ nofiles = files == null || files.length == 0;
+ if (nofiles) {
+ return true;
+ }
+
+// if (addSourcesToClassPath || addProjectClassPath) {
+ cl = initClassLoader(project,
+ src,
+ addSourcesToClassPath,
+ testPhase,
+ addResourcesToClassPath,
+ addCompileClassPath,
+ addProjectClassPath);
+
+ Thread.currentThread().setContextClassLoader(cl);
+// } else {
+// cl = getClass().getClassLoader();
+ //cl = Thread.currentThread().getContextClassLoader();
+// }
+
+ compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
+ defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
+ jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
+ if (!JAXXContext.class.isAssignableFrom(jaxxContextClass)) {
+ throw new MojoExecutionException("jaxxContextFQN must be an implementation of " + JAXXContext.class + " but was : " + jaxxContextClass);
+ }
+ validatorClass = Class.forName(validatorFQN, false, cl);
+
+ if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
+ defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl);
+ }
+
+ if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
+ // register extra path
+ BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
+ }
+
+ if (!outJava.exists()) {
+ outJava.mkdirs();
+ }
+
+ // compute extra imports (can not use java classes since some of
+ // imports can not be still compiled)
+ if (extraImportList != null && !extraImportList.isEmpty()) {
+ String[] imports = extraImportList.split(",");
+ int i = 0;
+ for (String importS : imports) {
+ imports[i++] = importS.trim();
+ }
+ if (verbose) {
+ getLog().info("extra imports " + java.util.Arrays.toString(imports));
+ }
+ extraImports = imports;
+ }
+
+ if (verbose) {
+ printInit();
+ }
+ return true;
+ }
+
+ @Override
+ public void doAction() throws MojoExecutionException {
+
+ if (nofiles) {
+ getLog().info("No files to treate.");
+ return;
+ }
+
+ getLog().info("Detects " + files.length + " modify jaxx file(s). ");
+
+ try {
+
+ // force compiler init from here, not in a static block
+ TagManager.reset(verbose);
+
+ JAXXCompilerLaunchor launchor;
+ launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
+ boolean success = launchor.compile();
+ getLog().info("Generated " + launchor.getCompilerCount() + " file(s). ");
+
+ if (!success) {
+ throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
+ }
+
+ if (generateHelp) {
+ // generate help
+ generateHelp();
+ }
+
+ } catch (MojoExecutionException e) {
+ getLog().error(e);
+ throw e;
+ } catch (Exception e) {
+ //getLog().error(e);
+ Throwable e2 = e;
+ while (e2.getCause() != null) {
+ e2 = e.getCause();
+ }
+ getLog().error(e2);
+
+ throw new MojoExecutionException(e2.getMessage(), e2);
+ }
+ }
+
+ @Override
+ public File getTargetDirectory() {
+ return outJava;
+ }
+
+ @Override
+ public boolean getOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public boolean isI18nable() {
+ return i18nable;
+ }
+
+ @Override
+ public boolean isUseUIManagerForIcon() {
+ return useUIManagerForIcon;
+ }
+
+ @Override
+ public boolean isAddLogger() {
+ return addLogger;
+ }
+
+ @Override
+ public Class<? extends JAXXContext> getJaxxContextClass() {
+ return jaxxContextClass;
+ }
+
+ @Override
+ public String[] getExtraImports() {
+ return extraImports;
+ }
+
+ @Override
+ public boolean isResetAfterCompile() {
+ return resetAfterCompile;
+ }
+
+ @Override
+ public boolean isOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public Class<?> getDefaultErrorUI() {
+ return defaultErrorUIClass;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return cl;
+ }
+
+ @Override
+ public Class<? extends JAXXCompiler> getCompilerClass() {
+ return compilerClass;
+ }
+
+ @Override
+ public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
+ return defaultDecoratorClass;
+ }
+
+ @Override
+ public boolean isProfile() {
+ return profile;
+ }
+
+ @Override
+ public boolean isGenerateHelp() {
+ return generateHelp;
+ }
+
+ @Override
+ public String getHelpBrokerFQN() {
+ return helpBrokerFQN;
+ }
+
+ @Override
+ public Class<?> getValidatorClass() {
+ return validatorClass;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+
+ protected void fixCompileSourceRoots() {
+ if (project == null) {
+ // no project defined, can not fix anything
+ // this case could appears if we wanted to do some tests of the plugin
+ return;
+ }
+
+ if (testPhase) {
+ if (!project.getTestCompileSourceRoots().contains(
+ outJava.getPath())) {
+ getLog().info("Add test compile source root : " + outJava);
+ project.addTestCompileSourceRoot(outJava.getPath());
+ }
+ } else {
+ if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
+ getLog().info("Add compile source root : " + outJava);
+ project.addCompileSourceRoot(outJava.getPath());
+ }
+ }
+ }
+
+ protected void printInit() {
+ getLog().info(toString());
+ getLog().info("includes : " + Arrays.toString(includes));
+ for (String file : files) {
+ getLog().info("will generate " + file);
+ }
+
+ ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
+ getLog().info(threadLoader.toString());
+ if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
+ try {
+ java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
+ m.setAccessible(true);
+ URL[] urls = (URL[]) m.invoke(threadLoader);
+
+ for (URL url : urls) {
+ getLog().info("url in class loader " + url);
+ }
+ } catch (Exception e) {
+ getLog().warn("??? : " + e.getMessage(), e);
+ }
+ }
+ }
+
+ protected void generateHelp() throws IOException {
+ Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
+ if (helpIds.isEmpty()) {
+ if (verbose) {
+ // no ids detected in this compilation round
+ getLog().info("no helpIds detected.");
+ }
+ return;
+ }
+ File idsStore = getHelpIdsStore();
+
+ if (!idsStore.getParentFile().exists()) {
+ idsStore.getParentFile().mkdirs();
+ }
+
+ Properties p = new Properties();
+
+ for (String helpId : helpIds) {
+ String path = helpId.replaceAll("\\.", File.separator);
+ path = removeQuote(path) + ".html";
+ p.put(removeQuote(helpId), path);
+ }
+
+ FileOutputStream w = new FileOutputStream(idsStore);
+
+ try {
+ p.store(w, null);
+ } finally {
+ w.close();
+ }
+
+ getLog().info("helpIdStore generated in " + idsStore);
+
+ helpIds.clear();
+ }
+
+ //TODO use the AbstractPublig method
+ @SuppressWarnings({"unchecked"})
+ protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
+ URLClassLoader loader = null;
+ if (project != null) {
+
+ URLClassLoader result;
+ try {
+
+ List<URL> lUrls = new ArrayList<URL>();
+ List<String> sources = project.getCompileSourceRoots();
+
+ if (addSourcesToClassPath) {
+ for (String source : sources) {
+ lUrls.add(new File(source).toURI().toURL());
+ }
+ if (testPhase) {
+ for (Object source : project.getTestCompileSourceRoots()) {
+ lUrls.add(new File(source.toString()).toURI().toURL());
+ }
+ }
+ }
+ if (addResourcesToClassPath) {
+ for (Object source : project.getResources()) {
+ Resource r = (Resource) source;
+ lUrls.add(new File(r.getDirectory()).toURI().toURL());
+ }
+ }
+ if (testPhase && addCompileClassPath) {
+ if (project != null) {
+ lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
+ }
+ }
+ if (addProjectClassPath) {
+ getLog().info("use project compile scope class-path");
+ // add also all dependencies of the project in compile scope
+ Set<?> artifacts = project.getArtifacts();
+ for (Object o : artifacts) {
+ Artifact a = (Artifact) o;
+ lUrls.add(a.getFile().toURI().toURL());
+ }
+ }
+
+ result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
+
+ } catch (IOException e) {
+ throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
+ }
+ loader = result;
+ } else {
+ List<URL> lUrls = new ArrayList<URL>();
+ if (addSourcesToClassPath) {
+ lUrls.add(src.toURI().toURL());
+ }
+ loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
+ }
+ if (verbose) {
+ for (URL entry : loader.getURLs()) {
+ log.info("classpath : " + entry);
+ }
+ }
+ return loader;
+ }
+
+ protected String removeQuote(String txt) {
+ if (txt.startsWith("\"")) {
+ txt = txt.substring(1);
+ }
+ if (txt.endsWith("\"")) {
+ txt = txt.substring(0, txt.length() - 1);
+ }
+ return txt;
+ }
+}
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,688 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * JaxxPlugin, Code Lutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-package org.nuiton.jaxx.plugin;
-
-import jaxx.compiler.CompilerConfiguration;
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.compiler.beans.BeanInfoUtil;
-import jaxx.compiler.decorators.CompiledObjectDecorator;
-import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
-import jaxx.compiler.tags.TagManager;
-import jaxx.runtime.JAXXContext;
-
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
-import org.apache.maven.plugin.MojoExecutionException;
-import org.apache.maven.plugin.MojoFailureException;
-import org.apache.maven.project.MavenProject;
-
-import org.nuiton.io.FileUpdaterHelper;
-import org.nuiton.io.MirroredFileUpdater;
-
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.util.Map;
-import java.net.URL;
-import java.net.URLClassLoader;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import org.apache.commons.lang.builder.ToStringBuilder;
-import org.apache.commons.lang.builder.ToStringStyle;
-
-/**
- * Generates some java code from jaxx files.
- *
- * @author chemit
- * @goal generate
- * @phase process-sources
- * @requiresDependencyResolution compile
- * @requiresProject
- */
-public class JaxxGeneratorMojo extends AbstractJaxxMojo implements CompilerConfiguration {
-
- /**
- * Default includes to use, if none provided
- */
- private static final String[] INCLUDES = {"**\\/*.jaxx"};
- /**
- * Repertoire sources des fichiers jaxx a generer.
- *
- * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
- */
- protected File src;
- /**
- * pour filter les fichiers a traiter
- *
- * @parameter expression="${jaxx.includes}"
- */
- protected String[] includes;
- /**
- * pour filter les fichiers a ne pas traiter
- *
- * @parameter expression="${jaxx.excludes}"
- */
- protected String[] excludes;
- /**
- * Le compilateur à utiliser (par défaut celui de Swing)
- *
- * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler"
- */
- protected String compilerFQN;
- /**
- * Le compilateur à utiliser (par défaut celui de Swing)
- *
- * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
- */
- protected String validatorFQN;
- /**
- * the name of implementation of {@link jaxx.runtime.JAXXContext}
- * to be used on {@link jaxx.runtime.JAXXObject}.
- * <p/>
- * Must not be abstract.
- *
- * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext"
- * @required
- */
- protected String jaxxContextFQN;
- /**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultErrorUIFQN}"
- */
- protected String defaultErrorUIFQN;
- /**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
- *
- * @see jaxx.compiler.decorators.CompiledObjectDecorator
- */
- protected String defaultDecoratorFQN;
- /**
- * flag to include in compiler classpath the java sources directories (src and outJava).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addSourcesToClassPath}" default-value="false"
- */
- protected boolean addSourcesToClassPath;
- /**
- * flag to include in compiler classpath the java resources directories (src and outJava).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addResourcesToClassPath}" default-value="false"
- * @since 1.6.0
- */
- protected boolean addResourcesToClassPath;
- /**
- * flag to include in compiler classpath the compile class-path (can only be used in a test phase).
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addCompileClassPath}" default-value="false"
- * @since 1.6.0
- */
- protected boolean addCompileClassPath;
- /**
- * flag to include in compiler classpath the project compile classpath.
- * <p/>
- * By default, false.
- *
- * @parameter expression="${jaxx.addProjectClassPath}" default-value="false"
- */
- protected boolean addProjectClassPath;
- /**
- * to force generation of java source for any jaxx files with no timestamp checking.
- * <p/>
- * By default, never force generation.
- *
- * @parameter expression="${jaxx.force}" default-value="false"
- */
- protected boolean force;
- /**
- * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
- *
- * @parameter expression="${jaxx.testPhase}" default-value="false"
- * @since 1.6.0
- */
- protected boolean testPhase;
- /**
- * pour optimizer le code compile ou genere ?
- *
- * @parameter expression="${jaxx.optimize}" default-value="false"
- */
- protected boolean optimize;
- /**
- * flag to add logger to each generated jaxx file.
- * <p/>
- * By default, always add it.
- *
- * @parameter expression="${jaxx.addLogger}" default-value="true"
- */
- protected boolean addLogger;
- /**
- * flag to keep compilers after the generate operation (usefull for tests.
- * <p/>
- * By default, always reset.
- *
- * @parameter expression="${jaxx.resetAfterCompile}" default-value="true"
- */
- protected boolean resetAfterCompile;
- /**
- * extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
- * <p/>
- * add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
- * <p/>
- * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}.
- * <p/>
- * <p/>
- * This permit to use real beanInfo of imported graphic libraries.
- *
- * @parameter expression="${jaxx.beanInfoSearchPath}"
- */
- protected String[] beanInfoSearchPath;
- /**
- * list of fqn of class toimport for all generated jaxx files
- *
- * @parameter expression="${jaxx.extraImportList}"
- */
- protected String extraImportList;
- /**
- * a flag to use UIManager to retreave icons.
- *
- * @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
- */
- protected boolean useUIManagerForIcon;
- /**
- * flag to activate profile mode.
- * <p/>
- * By default, not active.
- *
- * @parameter expression="${jaxx.profile}" default-value="false"
- */
- protected boolean profile;
- /**
- * flag to activate help generation process.
- * <p/>
- * By default, not active.
- *
- * @parameter expression="${jaxx.generateHelp}" default-value="false"
- *
- * @since 1.3
- */
- protected boolean generateHelp;
- /**
- * the FQN of help broker
- * <p/>
- * By default, none.
- *
- * @parameter expression="${jaxx.helpBrokerFQN}"
- *
- * @since 1.3
- */
- protected String helpBrokerFQN;
- /**
- * detected jaxx files in {@link #init()} method
- */
- protected String[] files;
- /**
- * file updater used to detect jaxx files.
- *
- * <b>Note:</b> if {@link #verbose} flag is on, will ne be used
- */
- protected MirroredFileUpdater updater;
- /**
- *
- */
- private Class<?> defaultErrorUIClass;
- /**
- *
- */
- private Class<?> validatorClass;
- /**
- *
- */
- private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
- /**
- *
- */
- private Class<? extends JAXXContext> jaxxContextClass;
- /**
- *
- */
- private Class<? extends JAXXCompiler> compilerClass;
- /**
- *
- */
- private String[] extraImports;
- /**
- *
- */
- private boolean nofiles;
-
- @SuppressWarnings("unchecked")
- @Override
- public boolean init() throws Exception {
-
- if (generateHelp) {
- // check there is some bundle
- if (helpIdStore == null) {
- throw new MojoFailureException("you must set the helpIdStore property.");
- }
- }
-
- fixCompileSourceRoots();
-
- if (includes == null || includes.length == 0) {
- // use default includes
- includes = INCLUDES;
- }
- updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
-
- Map<File, String[]> result = new HashMap<File, String[]>();
- getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
-
- this.files = result.get(src);
-
- nofiles = files == null || files.length == 0;
- if (nofiles) {
- return true;
- }
-
-// if (addSourcesToClassPath || addProjectClassPath) {
- cl = initClassLoader(project,
- src,
- addSourcesToClassPath,
- testPhase,
- addResourcesToClassPath,
- addCompileClassPath,
- addProjectClassPath);
-
- Thread.currentThread().setContextClassLoader(cl);
-// } else {
-// cl = getClass().getClassLoader();
- //cl = Thread.currentThread().getContextClassLoader();
-// }
-
- compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
- defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
- jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
- if (!JAXXContext.class.isAssignableFrom(jaxxContextClass)) {
- throw new MojoExecutionException("jaxxContextFQN must be an implementation of " + JAXXContext.class + " but was : " + jaxxContextClass);
- }
- validatorClass = Class.forName(validatorFQN, false, cl);
-
- if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
- defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl);
- }
-
- if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
- // register extra path
- BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
- }
-
- if (!outJava.exists()) {
- outJava.mkdirs();
- }
-
- // compute extra imports (can not use java classes since some of
- // imports can not be still compiled)
- if (extraImportList != null && !extraImportList.isEmpty()) {
- String[] imports = extraImportList.split(",");
- int i = 0;
- for (String importS : imports) {
- imports[i++] = importS.trim();
- }
- if (verbose) {
- getLog().info("extra imports " + java.util.Arrays.toString(imports));
- }
- extraImports = imports;
- }
-
- if (verbose) {
- printInit();
- }
- return true;
- }
-
- @Override
- public void doAction() throws MojoExecutionException {
-
- if (nofiles) {
- getLog().info("No files to treate.");
- return;
- }
-
- getLog().info("Detects " + files.length + " modify jaxx file(s). ");
-
- try {
-
- // force compiler init from here, not in a static block
- TagManager.reset(verbose);
-
- JAXXCompilerLaunchor launchor;
- launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
- boolean success = launchor.compile();
- getLog().info("Generated " + launchor.getCompilerCount() + " file(s). ");
-
- if (!success) {
- throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
- }
-
- if (generateHelp) {
- // generate help
- generateHelp();
- }
-
- } catch (MojoExecutionException e) {
- getLog().error(e);
- throw e;
- } catch (Exception e) {
- //getLog().error(e);
- Throwable e2 = e;
- while (e2.getCause() != null) {
- e2 = e.getCause();
- }
- getLog().error(e2);
-
- throw new MojoExecutionException(e2.getMessage(), e2);
- }
- }
-
- @Override
- public File getTargetDirectory() {
- return outJava;
- }
-
- @Override
- public boolean getOptimize() {
- return optimize;
- }
-
- @Override
- public boolean isI18nable() {
- return i18nable;
- }
-
- @Override
- public boolean isUseUIManagerForIcon() {
- return useUIManagerForIcon;
- }
-
- @Override
- public boolean isAddLogger() {
- return addLogger;
- }
-
- @Override
- public Class<? extends JAXXContext> getJaxxContextClass() {
- return jaxxContextClass;
- }
-
- @Override
- public String[] getExtraImports() {
- return extraImports;
- }
-
- @Override
- public boolean isResetAfterCompile() {
- return resetAfterCompile;
- }
-
- @Override
- public boolean isOptimize() {
- return optimize;
- }
-
- @Override
- public Class<?> getDefaultErrorUI() {
- return defaultErrorUIClass;
- }
-
- @Override
- public ClassLoader getClassLoader() {
- return cl;
- }
-
- @Override
- public Class<? extends JAXXCompiler> getCompilerClass() {
- return compilerClass;
- }
-
- @Override
- public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
- return defaultDecoratorClass;
- }
-
- @Override
- public boolean isProfile() {
- return profile;
- }
-
- @Override
- public boolean isGenerateHelp() {
- return generateHelp;
- }
-
- @Override
- public String getHelpBrokerFQN() {
- return helpBrokerFQN;
- }
-
- @Override
- public String getHelpsetIndexI18nSuffix() {
- return helpsetIndexI18nSuffix;
- }
-
- @Override
- public String getHelpsetTitleI18nSuffix() {
- return helpsetTitleI18nSuffix;
- }
-
- @Override
- public String getHelpsetTocI18nSuffix() {
- return helpsetTocI18nSuffix;
- }
-
- @Override
- public String getHelpSetName() {
- return helpSetName;
- }
-
- @Override
- public String getHelpsetI18nPrefix() {
- return helpsetI18nPrefix;
- }
-
- @Override
- public Class<?> getValidatorClass() {
- return validatorClass;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
- }
-
- protected void fixCompileSourceRoots() {
- if (project == null) {
- // no project defined, can not fix anything
- // this case could appears if we wanted to do some tests of the plugin
- return;
- }
-
- if (testPhase) {
- if (!project.getTestCompileSourceRoots().contains(
- outJava.getPath())) {
- getLog().info("Add test compile source root : " + outJava);
- project.addTestCompileSourceRoot(outJava.getPath());
- }
- } else {
- if (!project.getCompileSourceRoots().contains(outJava.getPath())) {
- getLog().info("Add compile source root : " + outJava);
- project.addCompileSourceRoot(outJava.getPath());
- }
- }
- }
-
- protected void printInit() {
- getLog().info(toString());
- getLog().info("includes : " + Arrays.toString(includes));
- for (String file : files) {
- getLog().info("will generate " + file);
- }
-
- ClassLoader threadLoader = Thread.currentThread().getContextClassLoader();
- getLog().info(threadLoader.toString());
- if (threadLoader.getClass().getSimpleName().equals("RealmClassLoader")) {
- try {
- java.lang.reflect.Method m = threadLoader.getClass().getDeclaredMethod("getURLs");
- m.setAccessible(true);
- URL[] urls = (URL[]) m.invoke(threadLoader);
-
- for (URL url : urls) {
- getLog().info("url in class loader " + url);
- }
- } catch (Exception e) {
- getLog().warn("??? : " + e.getMessage(), e);
- }
- }
- }
-
- protected void generateHelp() throws IOException {
- Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
- if (helpIds.isEmpty()) {
- if (verbose) {
- // no ids detected in this compilation round
- getLog().info("no helpIds detected.");
- }
- return;
- }
-
- if (!helpIdStore.getParentFile().exists()) {
- helpIdStore.getParentFile().mkdirs();
- }
-
- Properties p = new Properties();
-
- for (String helpId : helpIds) {
- String path = helpId.replaceAll("\\.", File.separator);
- path = removeQuote(path) + ".html";
- p.put(removeQuote(helpId), path);
- }
-
- FileOutputStream w = new FileOutputStream(helpIdStore);
-
- try {
- p.store(w, null);
- } finally {
- w.close();
- }
-
- getLog().info("helpIdStore generated in " + helpIdStore);
-
- helpIds.clear();
- }
-
- //TODO use the AbstractPublig method
- @SuppressWarnings({"unchecked"})
- protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
- URLClassLoader loader = null;
- if (project != null) {
-
- URLClassLoader result;
- try {
-
- List<URL> lUrls = new ArrayList<URL>();
- List<String> sources = project.getCompileSourceRoots();
-
- if (addSourcesToClassPath) {
- for (String source : sources) {
- lUrls.add(new File(source).toURI().toURL());
- }
- if (testPhase) {
- for (Object source : project.getTestCompileSourceRoots()) {
- lUrls.add(new File(source.toString()).toURI().toURL());
- }
- }
- }
- if (addResourcesToClassPath) {
- for (Object source : project.getResources()) {
- Resource r = (Resource) source;
- lUrls.add(new File(r.getDirectory()).toURI().toURL());
- }
- }
- if (testPhase && addCompileClassPath) {
- if (project != null) {
- lUrls.add(new File(project.getBuild().getOutputDirectory()).toURI().toURL());
- }
- }
- if (addProjectClassPath) {
- getLog().info("use project compile scope class-path");
- // add also all dependencies of the project in compile scope
- Set<?> artifacts = project.getArtifacts();
- for (Object o : artifacts) {
- Artifact a = (Artifact) o;
- lUrls.add(a.getFile().toURI().toURL());
- }
- }
-
- result = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
-
- } catch (IOException e) {
- throw new RuntimeException("Can't create ClassLoader for reason " + e.getMessage(), e);
- }
- loader = result;
- } else {
- List<URL> lUrls = new ArrayList<URL>();
- if (addSourcesToClassPath) {
- lUrls.add(src.toURI().toURL());
- }
- loader = new URLClassLoader(lUrls.toArray(new URL[lUrls.size()]), getClass().getClassLoader());
- }
- if (verbose) {
- for (URL entry : loader.getURLs()) {
- log.info("classpath : " + entry);
- }
- }
- return loader;
- }
-
- protected String removeQuote(String txt) {
- if (txt.startsWith("\"")) {
- txt = txt.substring(1);
- }
- if (txt.endsWith("\"")) {
- txt = txt.substring(0, txt.length() - 1);
- }
- return txt;
- }
-}
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -1,780 +0,0 @@
-/* *##%
- * Copyright (C) 2007
- * JaxxPlugin, Code Lutin
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License
- * as published by the Free Software Foundation; either version 2
- * 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 Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- *##%*/
-package org.nuiton.jaxx.plugin;
-
-import org.apache.maven.plugin.MojoFailureException;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.util.Enumeration;
-import java.util.List;
-import java.util.Properties;
-import java.util.Set;
-import java.util.Stack;
-import org.apache.maven.model.Resource;
-import org.nuiton.i18n.I18n;
-import org.nuiton.util.FileUtil;
-import org.nuiton.util.SortedProperties;
-import org.xml.sax.Attributes;
-import org.xml.sax.ContentHandler;
-import org.xml.sax.InputSource;
-import org.xml.sax.Locator;
-import org.xml.sax.SAXException;
-import org.xml.sax.XMLReader;
-import org.xml.sax.helpers.XMLReaderFactory;
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Mojo to generate javax help stuff for your project.
- *
- * HelpIds should have been discovered by the JaxxMojo.
- *
- * @author chemit
- * @goal generate-help
- * @phase process-sources
- *
- * @requiresProject
- * @requiresDependencyResolution compile
- * @since 1.3
- */
-public class JaxxHelpGeneratorMojo extends AbstractJaxxMojo {
-
- /**
- * The directory where to generate javaHelp skeleton files.
- * <p/>
- * Is required if generateHelp is on.
- *
- * @parameter expression="${jaxx.helpTarget}" alias="target" default-value="${maven.src.dir}/main/help"
- * @required
- *
- * @since 1.3
- */
- protected File target;
- /**
- * The locale to generate for help.
- *
- * By default, stay in France.
- *
- * @parameter expression="${jaxx.locale}" default-value="fr"
- * @required
- *
- * @since 1.3
- */
- protected String locale;
- /**
- * The package where to generate i18n java file.
- *
- * @parameter expression="${jaxx.packageName}" default-value="${project.groupId}"
- * @required
- *
- * @since 1.3
- */
- protected String packageName;
- /**
- * The file name of the helpset to generate.
- *
- * @parameter expression="${jaxx.helpSetFileName}" default-value="${jaxx.helpSetName}.hs"
- * @required
- *
- * @since 1.3
- */
- protected String helpsetFileName;
- /**
- * The file name of the helpset map to generate.
- *
- * @parameter expression="${jaxx.mapFileName}" default-value="${jaxx.helpSetName}Map.jhm"
- * @required
- *
- * @since 1.3
- */
- protected String mapFileName;
- /**
- * The file name of the helpset index to generate.
- *
- * @parameter expression="${jaxx.indexFileName}" default-value="${jaxx.helpSetName}Index.xml"
- * @required
- *
- * @since 1.3
- */
- protected String indexFileName;
- /**
- * The file name of the helpset toc to generate.
- *
- * @parameter expression="${jaxx.tocFileName}" default-value="${jaxx.helpSetName}TOC.xml"
- * @required
- *
- * @since 1.3
- */
- protected String tocFileName;
- /**
- * The file name of the i18n java file to generate.
- *
- * @parameter expression="${jaxx.i8nFileName}" default-value="${jaxx.helpSetName}I18n.java"
- * @required
- *
- * @since 1.3
- */
- protected String i8nFileName;
- /**
- * The template used to generate helpset file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.helpSetTemplate}" default-value="/defaultHelpSet.hs.vm"
- * @required
- *
- * @since 1.3
- */
- protected File helpSetTemplate;
- /**
- * The template used to generate helpset map file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.mapTemplate}" default-value="/defaultMap.jhm.vm"
- * @required
- *
- * @since 1.3
- */
- protected File mapTemplate;
- /**
- * The template used to generate helpset index file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.indexTemplate}" default-value="/defaultIndex.xml.vm"
- * @required
- *
- * @since 1.3
- */
- protected File indexTemplate;
- /**
- * The template used to generate helpset toc file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.tocTemplate}" default-value="/defaultToc.xml.vm"
- * @required
- *
- * @since 1.3
- */
- protected File tocTemplate;
- /**
- * The template used to generate helpset content file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.contentTemplate}" default-value="/defaultContent.html.vm"
- * @required
- *
- * @since 1.3
- */
- protected File contentTemplate;
- /**
- * The template used to generate helpset content file.
- *
- * Must be an existing file or a ressource in classp-ath
- *
- * @parameter expression="${jaxx.i18nTemplate}" default-value="/defaultI18n.java.vm"
- * @required
- *
- * @since 1.3
- */
- protected File i18nTemplate;
- /**
- * The help ids discovered by Jaxx compilation
- */
- protected Properties helpIds;
- private static final String AUTOREMOVE_LINE = "REMOVE THS LINE TO DISABLE AUTO-REGENERATE THE FILE";
-
- @Override
- public boolean init() throws Exception {
-
- if (!helpIdStore.exists()) {
- getLog().info("no helpIdStore to react at " + helpIdStore);
- return false;
- }
-
- // check there is some bundle
- if (locale == null) {
- throw new MojoFailureException("you must set the bundles property.");
- }
- // check there is some bundle
- if (target == null) {
- throw new MojoFailureException("you must set the target property.");
- }
- // check ressources
- checkResource(helpSetTemplate);
- checkResource(mapTemplate);
- checkResource(indexTemplate);
- checkResource(tocTemplate);
- checkResource(contentTemplate);
-
- if (!target.exists()) {
- getLog().info("mkdir " + target);
- target.mkdirs();
- }
-
- helpIds = new SortedProperties();
-
- InputStream stream = new FileInputStream(helpIdStore);
-
- helpIds.load(stream);
-
- stream.close();
-
- if (helpIds.isEmpty()) {
-
- // no ids detected
- getLog().warn("no helpIds detected, will skip.");
- return false;
- }
-
- return true;
- }
-
- @Override
- public void doAction() throws Exception {
-
- if (i18nable) {
-
- List<URL> lUrls = new java.util.ArrayList<URL>();
- List<?> resources = project.getResources();
- for (Object o : resources) {
- Resource resource = (Resource) o;
- lUrls.add(new File(resource.getDirectory()).toURI().toURL());
- }
- I18n.setExtraURL(lUrls.toArray(new URL[lUrls.size()]));
- I18n.init(locale, null);
- }
-
- File file;
-
- Properties env = new Properties();
-
- env.put("helpSetName", helpSetName);
- env.put("helpSetFileName", helpsetFileName);
- env.put("mapFileName", mapFileName);
- env.put("indexFileName", indexFileName);
- env.put("tocFileName", tocFileName);
- env.put("separator", " ");
- env.put("autoremoveLine", AUTOREMOVE_LINE);
-
-
- int touchedFiles = 0;
-
- // ---------------------------------------------------------------
- // --- main helpset file -----------------------------------------
- // ---------------------------------------------------------------
-
-
- file = new File(target, helpsetFileName);
-
- boolean doCreate = generateHelSetFile(file, env);
-
- if (doCreate) {
- touchedFiles++;
- }
-
- // ---------------------------------------------------------------
- // --- helpset map file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(target, mapFileName);
-
- Properties mergedHelpIds = generateMapFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset index file ----------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(target, indexFileName);
-
- NodeItem indexRootItem = generateIndexFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset toc file ------------------------------------------
- // ---------------------------------------------------------------
-
- file = new File(target, tocFileName);
-
- NodeItem tocRootItem = generateTocFile(file, env);
- touchedFiles++;
-
- // ---------------------------------------------------------------
- // --- helpset content files -------------------------------------
- // ---------------------------------------------------------------
-
- TemplateGenerator gen = prepareGenerator(contentTemplate);
-
- Enumeration<?> keys = helpIds.keys();
-
- while (keys.hasMoreElements()) {
- String key = (String) keys.nextElement();
- String url = (String) helpIds.get(key);
- url = helpSetName + File.separator + url;
-
- File f = new File(target, url);
-
- boolean exist = f.exists();
-
- if (exist) {
- // check if there is a autoremoveLine in content
- String content = FileUtil.readAsString(f);
- if (!content.contains(AUTOREMOVE_LINE)) {
- // no regenerate marker detected, so skip this file
- if (verbose) {
- getLog().debug("skip existing file " + f);
- }
- continue;
- }
- }
-
- f.getParentFile().mkdirs();
-
- if (verbose) {
- if (exist) {
- getLog().info("regenerate content file " + f);
- } else {
- getLog().info("generate content file " + f);
- }
- }
-
- env.put("helpId", key);
- String i18n = helpsetI18nPrefix + key + helpsetTitleI18nSuffix;
- env.put("helpIdTitle", _(i18n));
- env.put("helpIdUrl", url);
-
- gen.generate(env, f);
- touchedFiles++;
- }
-
- // ---------------------------------------------------------------
- // --- i18n file -------------------------------------------------
- // ---------------------------------------------------------------
-
- String path = packageName.replaceAll("\\.", File.separator);
- path += File.separator + i8nFileName;
- file = new File(outJava, path);
- generateI18nFile(file, env, mergedHelpIds, indexRootItem, tocRootItem);
- touchedFiles++;
-
- getLog().info(touchedFiles + " file(s) treated.");
- }
-
- protected void generateI18nFile(File file, Properties env, Properties mergedHelpIds, NodeItem indexRootItem, NodeItem tocRootItem) throws Exception {
-
- boolean create = !file.exists();
-
- if (!file.getParentFile().exists()) {
- file.getParentFile().mkdirs();
- }
-
- Set<String> keys = new java.util.HashSet<String>();
-
- for (Object k : mergedHelpIds.keySet()) {
- String key = helpsetI18nPrefix + k + helpsetTitleI18nSuffix;
- keys.add(key);
- }
- indexRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetIndexI18nSuffix);
- tocRootItem.extractI18n(keys, helpsetI18nPrefix, helpsetTocI18nSuffix);
-
- env.put("keys", keys);
- env.put("packageName", packageName);
- String className = file.getName();
- int index = className.lastIndexOf(".");
- className = className.substring(0, index);
- env.put("className", className);
-
- if (verbose) {
- if (create) {
- getLog().info("generate i18n java file " + file);
- } else {
- getLog().info("udpate i18n java file " + file);
- }
- }
-
- doGen(i18nTemplate, file, env);
-
- }
-
- protected boolean generateHelSetFile(File file, Properties env) throws Exception {
-
- if (file.exists()) {
- // check the auto removeline presence
- String content = FileUtil.readAsString(file);
- if (!content.contains(AUTOREMOVE_LINE)) {
- // no regenerate marker detected, so skip this file
- if (verbose) {
- getLog().info("skip existing helpset main file " + file);
- }
- return false;
- }
- }
-
- if (verbose) {
- if (file.exists()) {
- getLog().info("regenerate helpset main file " + file);
- } else {
- getLog().info("generate helpset main file " + file);
- }
- }
- doGen(helpSetTemplate, file, env);
- return true;
- }
-
- protected Properties generateMapFile(File file, Properties env) throws Exception {
-
- boolean create;
-
- Properties mergedHelpIds = null;
- if (file.exists()) {
-
- // get back the exisiting data and merge it with incoming ones
-
- if (verbose) {
- getLog().info("loading existing helpset map file " + file);
- }
-
- mergedHelpIds = getExistingHelpIds(file);
- create = false;
-
- } else {
-
- mergedHelpIds = new SortedProperties();
- create = true;
- }
-
- // inject new helpIds
-
- for (Object k : helpIds.keySet()) {
- mergedHelpIds.put(k, helpSetName + "/" + helpIds.get(k));
- }
-
- if (!mergedHelpIds.contains("top")) {
- // on ajoute une entree vers le root du helpset
-
- String topUrl = helpSetName + ".html";
- helpIds.put("top", topUrl);
- mergedHelpIds.put("top", helpSetName + "/" + topUrl);
- if (verbose) {
- getLog().debug("add top entry with url " + topUrl);
- }
- }
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset map file " + file);
- } else {
- getLog().info("udpate helpset map file " + file);
- }
- }
-
- env.put("helpIds", mergedHelpIds);
- doGen(mapTemplate, file, env);
- env.remove("helpIds");
- return mergedHelpIds;
- }
-
- protected NodeItem generateIndexFile(File file, Properties env) throws Exception {
- NodeItem rootItem = null;
-
- boolean create;
-
- if (file.exists()) {
-
- create = false;
-
- rootItem = getExistingItems("indexitem", file);
- } else {
- create = true;
- }
-
- if (rootItem == null) {
- rootItem = new NodeItem("top", helpSetName);
- }
-
- // inject new index entries
-
- for (Object k : helpIds.keySet()) {
- NodeItem toc = rootItem.findChild(k + "");
- if (verbose) {
- getLog().debug("index " + k + " : " + toc);
- }
- }
-
- //String prefix = helpsetI18nPrefix;
- //String prefix = helpsetI18nPrefix + helpSetName + ".";
- rootItem.applyI18n(helpsetI18nPrefix, helpsetIndexI18nSuffix);
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset index file " + file);
- } else {
- getLog().info("udpate helpset index file " + file);
- }
- }
-
- env.put("rootItem", rootItem);
- doGen(indexTemplate, file, env);
- env.remove("rootItem");
- return rootItem;
- }
-
- protected NodeItem generateTocFile(File file, Properties env) throws Exception {
- NodeItem rootItem = null;
-
- boolean create;
-
- if (file.exists()) {
-
- create = false;
-
- rootItem = getExistingItems("tocitem", file);
- } else {
- create = true;
- }
-
- if (rootItem == null) {
- rootItem = new NodeItem("top", helpSetName);
- }
- // inject new toc entries
-
- for (Object k : helpIds.keySet()) {
- NodeItem toc = rootItem.findChild(k + "");
- if (verbose) {
- getLog().debug("toc " + k + " : " + toc);
- }
- }
-
- //String prefix = helpsetI18nPrefix + helpSetName + ".";
- rootItem.applyI18n(helpsetI18nPrefix, helpsetTocI18nSuffix);
-
- if (verbose) {
- if (create) {
- getLog().info("generate helpset toc file " + file);
- } else {
- getLog().info("udpate helpset toc file " + file);
- }
- }
-
- env.put("rootItem", rootItem);
- doGen(tocTemplate, file, env);
- env.remove("rootItem");
- return rootItem;
- }
-
- protected void doGen(File template, File f, Properties env) throws Exception {
- TemplateGenerator gen = prepareGenerator(template);
- gen.generate(env, f);
- }
-
- protected TemplateGenerator prepareGenerator(File template) throws Exception {
- URL templateURL = getTemplate(template);
-
- if (verbose) {
- getLog().info("using template " + templateURL);
- }
- TemplateGenerator gen = new TemplateGenerator(project, templateURL);
- return gen;
- }
-
-// protected URL getTemplate(File f) throws IOException {
-// URL r = null;
-// if (f.exists()) {
-// r = f.toURI().toURL();
-// } else {
-// r = getClass().getResource(f.toString());
-// }
-// return r;
-// }
-//
-// protected void checkResource(File f) throws MojoFailureException {
-// if (!f.exists()) {
-// // test in classPath
-// InputStream r = getClass().getResourceAsStream(f.toString());
-// if (r == null) {
-// throw new MojoFailureException("could not find ressource " + f);
-// }
-// }
-// }
- protected Properties getExistingHelpIds(File file) throws SAXException, IOException {
-
- final Properties result = new SortedProperties();
-
- XMLReader parser = XMLReaderFactory.createXMLReader();
-
- parser.setContentHandler(new ContentHandlerAdapter() {
-
- String target;
- String url;
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- if ("mapID".equals(localName)) {
- target = atts.getValue("target");
- url = atts.getValue("url");
- if (verbose) {
- getLog().debug("detect map entry : " + target + " : " + url);
- }
- result.put(target, url);
- }
- }
- });
-
- InputStream s = new FileInputStream(file);
- try {
- parser.parse(new InputSource(s));
- } finally {
- s.close();
- }
- return result;
- }
-
- protected NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException {
-
- XMLReader parser = XMLReaderFactory.createXMLReader();
- NodeItemHandler handler = new NodeItemHandler(tagName);
-
- parser.setContentHandler(handler);
-
- NodeItem rootItem = null;
- InputStream s = new FileInputStream(file);
- try {
- parser.parse(new InputSource(s));
- rootItem = handler.rootItem;
- } finally {
- s.close();
- }
- return rootItem;
- }
-
- static class NodeItemHandler extends ContentHandlerAdapter {
-
- NodeItem rootItem;
- NodeItem currentItem;
- final Stack<NodeItem> stack;
- final String tagName;
-
- public NodeItemHandler(String tagName) {
- this.tagName = tagName;
- this.stack = new Stack<NodeItem>();
- }
-
- @Override
- public void startDocument() throws SAXException {
- rootItem = new NodeItem("top", null);
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- if (tagName.equals(localName)) {
-
- String target = atts.getValue("target");
- String text = atts.getValue("text");
-
- // debut d'un item
- if (currentItem == null) {
- // premier item
- if (rootItem.getTarget().equals(target)) {
- // le premier item est bien top
- //rootItem.setText(text);
- currentItem = rootItem;
- } else {
- // le premier noeud n'est pas top
- // en l'encapsule
- stack.push(rootItem);
- currentItem = new NodeItem(target, text);
- rootItem.addChild(currentItem);
- }
- } else {
- NodeItem newItem = new NodeItem(target, text);
- currentItem.addChild(newItem);
- currentItem = newItem;
- }
- currentItem.adjustTarget();
- stack.push(currentItem);
-
- }
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- if (tagName.equals(localName)) {
- // fin d'un item
- stack.pop();
- if (!stack.isEmpty()) {
- currentItem = stack.peek();
- }
- }
- }
- }
-
- static class ContentHandlerAdapter implements ContentHandler {
-
- @Override
- public void setDocumentLocator(Locator locator) {
- }
-
- @Override
- public void startDocument() throws SAXException {
- }
-
- @Override
- public void endDocument() throws SAXException {
- }
-
- @Override
- public void startPrefixMapping(String prefix, String uri) throws SAXException {
- }
-
- @Override
- public void endPrefixMapping(String prefix) throws SAXException {
- }
-
- @Override
- public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
- }
-
- @Override
- public void endElement(String uri, String localName, String qName) throws SAXException {
- }
-
- @Override
- public void characters(char[] ch, int start, int length) throws SAXException {
- }
-
- @Override
- public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
- }
-
- @Override
- public void processingInstruction(String target, String data) throws SAXException {
- }
-
- @Override
- public void skippedEntity(String name) throws SAXException {
- }
- }
-}
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -0,0 +1,187 @@
+package org.nuiton.jaxx.plugin;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Properties;
+import java.util.Stack;
+import org.apache.maven.plugin.logging.Log;
+import org.nuiton.util.SortedProperties;
+import org.xml.sax.Attributes;
+import org.xml.sax.ContentHandler;
+import org.xml.sax.InputSource;
+import org.xml.sax.Locator;
+import org.xml.sax.SAXException;
+import org.xml.sax.XMLReader;
+import org.xml.sax.helpers.XMLReaderFactory;
+
+/**
+ * To load {@link NodeItem} from xml.
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public class XmlHelper {
+
+ public static Properties getExistingHelpIds(File file, final boolean verbose, final Log log) throws SAXException, IOException {
+
+ final Properties result = new SortedProperties();
+
+ XMLReader parser = XMLReaderFactory.createXMLReader();
+
+ parser.setContentHandler(new ContentHandlerAdapter() {
+
+ String target;
+ String url;
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ if ("mapID".equals(localName)) {
+ target = atts.getValue("target");
+ url = atts.getValue("url");
+ if (verbose) {
+ log.debug("detect map entry : " + target + " : " + url);
+ }
+ result.put(target, url);
+ }
+ }
+ });
+
+ InputStream s = new FileInputStream(file);
+ try {
+ parser.parse(new InputSource(s));
+ } finally {
+ if (s != null) {
+ s.close();
+ }
+ }
+ return result;
+ }
+
+ public static NodeItem getExistingItems(String tagName, File file) throws SAXException, IOException {
+
+ XMLReader parser = XMLReaderFactory.createXMLReader();
+ NodeItemHandler handler = new NodeItemHandler(tagName);
+
+ parser.setContentHandler(handler);
+
+ NodeItem rootItem = null;
+ InputStream s = new FileInputStream(file);
+ try {
+ parser.parse(new InputSource(s));
+ rootItem = handler.rootItem;
+ } finally {
+ s.close();
+ }
+ return rootItem;
+ }
+
+ static class NodeItemHandler extends ContentHandlerAdapter {
+
+ NodeItem rootItem;
+ NodeItem currentItem;
+ final Stack<NodeItem> stack;
+ final String tagName;
+
+ public NodeItemHandler(String tagName) {
+ this.tagName = tagName;
+ this.stack = new Stack<NodeItem>();
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ rootItem = new NodeItem("top", null);
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ if (tagName.equals(localName)) {
+
+ String target = atts.getValue("target");
+ String text = atts.getValue("text");
+
+ // debut d'un item
+ if (currentItem == null) {
+ // premier item
+ if (rootItem.getTarget().equals(target)) {
+ // le premier item est bien top
+ //rootItem.setText(text);
+ currentItem = rootItem;
+ } else {
+ // le premier noeud n'est pas top
+ // en l'encapsule
+ stack.push(rootItem);
+ currentItem = new NodeItem(target, text);
+ rootItem.addChild(currentItem);
+ }
+ } else {
+ NodeItem newItem = new NodeItem(target, text);
+ currentItem.addChild(newItem);
+ currentItem = newItem;
+ }
+ currentItem.adjustTarget();
+ stack.push(currentItem);
+
+ }
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ if (tagName.equals(localName)) {
+ // fin d'un item
+ stack.pop();
+ if (!stack.isEmpty()) {
+ currentItem = stack.peek();
+ }
+ }
+ }
+ }
+
+ static class ContentHandlerAdapter implements ContentHandler {
+
+ @Override
+ public void setDocumentLocator(Locator locator) {
+ }
+
+ @Override
+ public void startDocument() throws SAXException {
+ }
+
+ @Override
+ public void endDocument() throws SAXException {
+ }
+
+ @Override
+ public void startPrefixMapping(String prefix, String uri) throws SAXException {
+ }
+
+ @Override
+ public void endPrefixMapping(String prefix) throws SAXException {
+ }
+
+ @Override
+ public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+ }
+
+ @Override
+ public void endElement(String uri, String localName, String qName) throws SAXException {
+ }
+
+ @Override
+ public void characters(char[] ch, int start, int length) throws SAXException {
+ }
+
+ @Override
+ public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
+ }
+
+ @Override
+ public void processingInstruction(String target, String data) throws SAXException {
+ }
+
+ @Override
+ public void skippedEntity(String name) throws SAXException {
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/XmlHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultContent.html.vm 2009-10-08 16:48:27 UTC (rev 1568)
@@ -2,11 +2,11 @@
<HTML>
<HEAD>
<TITLE>
-$helpIdTitle
+$helpId
</TITLE>
</HEAD>
<BODY BGCOLOR="#ffffff">
-<H1>$helpIdTitle</H1>
+<H1>$helpId</H1>
<!-- $autoremoveLine -->
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/defaultHelpSet.hs.vm 2009-10-08 16:48:27 UTC (rev 1568)
@@ -3,7 +3,7 @@
PUBLIC "-//Sun Microsystems Inc.//DTD JavaHelp HelpSet Version 1.0//EN"
"http://java.sun.com/products/javahelp/helpset_1_0.dtd">
-<helpset version="1.0">
+<helpset version="1.0" xml:lang="$locale">
<!-- $autoremoveLine -->
@@ -13,7 +13,7 @@
<!-- maps -->
<maps>
<homeID>top</homeID>
- <mapref location="$mapFileName"/>
+ <mapref location="$localePath/$mapFileName"/>
</maps>
<!-- views -->
@@ -21,17 +21,17 @@
<name>TOC</name>
<label>Table Of Contents</label>
<type>javax.help.TOCView</type>
- <data>$tocFileName</data>
+ <data>$localePath/$tocFileName</data>
</view>
<view>
<name>Index</name>
<label>Index</label>
<type>javax.help.IndexView</type>
- <data>$indexFileName</data>
+ <data>$localePath/$indexFileName</data>
</view>
-#if ( $!searchData != "" )
+#if ( $searchData )
<view>
<name>Search</name>
<label>Search</label>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1751Test.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -7,7 +7,7 @@
@Test
public void Bug_1751() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(3);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -23,7 +23,7 @@
@Test
public void Icon() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
checkPattern(mojo, ".createImageIcon(\"myIcon.png\")", true);
checkPattern(mojo, ".createActionIcon(\"myActionIcon.png\")", true);
@@ -40,7 +40,7 @@
@Test
public void ClientProperty() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
checkPattern(mojo, ".putClientProperty(\"testOne\", \"oneTest\")", true);
checkPattern(mojo, ".putClientProperty(\"testTwo\", \"anotherTest\")", true);
@@ -60,7 +60,7 @@
@Test
public void WithLog() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
String[] files = mojo.files;
assertNumberJaxxFiles(2);
@@ -85,7 +85,7 @@
@Test
public void NoLog() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(2);
checkPattern(mojo, "Log log = LogFactory.getLog(", false);
@@ -96,7 +96,7 @@
@SuppressWarnings({"unchecked"})
@Test
public void Errors() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
// init mojo to get alls files to treate
mojo.init();
@@ -160,7 +160,7 @@
@Test
public void ErrorJaxxContextImplementorClass() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.jaxxContextFQN = null;
try {
mojo.init();
@@ -213,7 +213,7 @@
public void Force() throws Exception {
// first round, with force option so will generate theonly JButton.jaxx file
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
String[] files = mojo.files;
assertNumberJaxxFiles(1);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerValidatorTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -24,7 +24,7 @@
@SuppressWarnings({"unchecked"})
public void ValidatorErrors() throws Exception {
// init mojo to get alls files to treate
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.init();
String[] files = mojo.files;
assertNumberJaxxFiles(19);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/DecoratorTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -6,7 +6,7 @@
@Test
public void Decorator() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(1);
checkPattern(mojo, "root.add(jaxx.runtime.SwingUtil.boxComponentWithJxLayer(boxedButton))", true);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -15,7 +15,7 @@
@Test
public void ok() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.execute();
assertNumberJaxxFiles(6);
@@ -38,7 +38,7 @@
@SuppressWarnings({"unchecked"})
@Test
public void error() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
// init mojo to get alls files to treate
mojo.init();
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/I18nTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -6,7 +6,7 @@
@Test
public void I18nText() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.i18nable = false;
mojo.execute();
checkPattern(mojo, "testId.setText(_(\"test.text\"));", false);
@@ -19,7 +19,7 @@
@Test
public void I18nTitle() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.i18nable = false;
mojo.execute();
checkPattern(mojo, "testId.setTitle(_(\"test.title\"));", false);
@@ -32,7 +32,7 @@
@Test
public void I18nToolTipText() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
+ GenerateMojo mojo = getMojo();
mojo.i18nable = false;
mojo.execute();
checkPattern(mojo, "testId.setToolTipText(_(\"test.toolTipText\"));", false);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-07 21:03:42 UTC (rev 1567)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-08 16:48:27 UTC (rev 1568)
@@ -15,9 +15,9 @@
*
* @author chemit
* @see AbstractMojoTest
- * @see JaxxGeneratorMojo
+ * @see GenerateMojo
*/
-public abstract class JaxxBaseTest extends AbstractMojoTest<JaxxGeneratorMojo> {
+public abstract class JaxxBaseTest extends AbstractMojoTest<GenerateMojo> {
@Override
protected String getGoalName(String methodName) {
@@ -25,7 +25,7 @@
}
@Override
- protected void setUpMojo(JaxxGeneratorMojo mojo, File pomFile) throws Exception {
+ protected void setUpMojo(GenerateMojo mojo, File pomFile) throws Exception {
super.setUpMojo(mojo, pomFile);
mojo.jaxxContextFQN = DefaultJAXXContext.class.getName();
mojo.compilerFQN = jaxx.compiler.JAXXCompiler.class.getName();
@@ -33,7 +33,7 @@
mojo.defaultDecoratorFQN = jaxx.compiler.decorators.DefaultCompiledObjectDecorator.class.getName();
}
- protected void checkPattern(JaxxGeneratorMojo mojo, String pattern, boolean required, String... files) throws IOException {
+ protected void checkPattern(GenerateMojo mojo, String pattern, boolean required, String... files) throws IOException {
if (files.length == 0) {
files = mojo.files;
}
1
0
Author: tchemit
Date: 2009-10-07 23:03:42 +0200 (Wed, 07 Oct 2009)
New Revision: 1567
Added:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java
Removed:
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/pom.xml
branches/jaxx-2.X/src/site/rst/JAXXContext.rst
branches/jaxx-2.X/src/site/rst/migration.rst
Log:
ending migration
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -2,7 +2,7 @@
import java.io.File;
import jaxx.compiler.decorators.CompiledObjectDecorator;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
/**
* TODO javadoc.
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -5,7 +5,7 @@
import org.apache.commons.lang.builder.ToStringStyle;
import java.io.File;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
/**
* Options of the {@link JAXXCompiler} and {@link JAXXCompilerLaunchor}.
@@ -46,7 +46,7 @@
*/
private boolean resetAfterCompile;
/**
- * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * the name of implementation of {@link jaxx.runtime.JAXXContext}
* to be used on {@link jaxx.runtime.JAXXObject}.
*/
protected Class<? extends JAXXContext> jaxxContextClass;
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -45,7 +45,7 @@
if (options.isGenerateHelp()) {
// add JaxxHelpUI interface
- Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
+ Class<?> validatorInterface = jaxx.runtime.swing.JaxxHelpUI.class;
String helpBrokerFQN = getBrokerFQN(compiler);
javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -11,7 +11,7 @@
import jaxx.compiler.types.TypeManager;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.Util;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -49,7 +49,7 @@
protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
"java.util.Map", "$previousValues", "new java.util.HashMap()");
protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED,
- "jaxx.runtime.context.JAXXContext", "delegateContext");
+ JAXXContext.class.getName(), "delegateContext");
protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = JavaField.newField(0,
"java.beans.PropertyChangeSupport", "$propertyChangeSupport");
protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
@@ -431,7 +431,7 @@
}
code.append("$initialize();");
code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.context.JAXXContext", "parentContext"));
+ return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument(JAXXContext.class.getName(), "parentContext"));
}
public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
Modified: branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-07 21:03:42 UTC (rev 1567)
@@ -13,7 +13,7 @@
Le besoin initial de ce développement est de pouvoir facilement intégrer un context applicatif dans JAXX et de pouvoir
l'utiliser dans les fichiers JAXX pour injecter par exemple des données dans les widgets.
-jaxx.runtime.context.JAXXContext
+jaxx.runtime.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -20,7 +20,7 @@
*/
package jaxx.demo;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -21,7 +21,7 @@
package jaxx.demo;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.swing.navigation.NavigationTreeNode;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -21,7 +21,7 @@
package jaxx.demo.component.jaxx.navigation;
import jaxx.runtime.JAXXObject;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import static jaxx.runtime.context.JAXXContextEntryDef.newListDef;
import jaxx.runtime.decorator.Decorator;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,7 +1,6 @@
package jaxx.runtime;
import jaxx.runtime.context.JAXXInitialContext;
-import jaxx.runtime.context.JAXXContext;
/**
* This is the contract to be realized by any class to be used as Action class for an ui.
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,106 @@
+package jaxx.runtime;
+
+import java.awt.Container;
+
+/**
+ * The {@link jaxx.runtime.JAXXContext} contract defines a generic context.
+ * <p/>
+ * A context contains two king of entries :
+ * <p/>
+ * <h2>Unamed entry</h2>
+ * a such entry maps filter only on the clas of the object of the entry.
+ * <p/>
+ * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a
+ * such entry.
+ * <p/>
+ * <h2>named entry</h2>
+ * a such entry filter on class of the object and on the name of the entry.
+ * <p/>
+ * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)}
+ * to reteave a such entry.
+ *
+ * @author letellier
+ * @author chemit
+ */
+public interface JAXXContext {
+
+ /**
+ * Push in the context a new unamed entry.
+ * <p/>
+ * If a previous entry exists in context (unamed and same class), it will be removed.
+ *
+ * @param <T> type of data to set in context
+ * @param o the value to push in context
+ */
+ public <T> void setContextValue(T o);
+
+ /**
+ * * Push in the context a new amed entry.
+ * <p/>
+ * If a previous entry exists in context (same name and class), it will be removed.
+ *
+ * @param <T> type of data to set in context
+ * @param o the value to push in context
+ * @param name the name of the new entry
+ */
+ public <T> void setContextValue(T o, String name);
+
+ /**
+ * Remove from context the value with the given klazz as an unamed entry
+ *
+ * @param <T> type of data to remove from context
+ * @param klazz the klazz entry
+ */
+ public <T> void removeContextValue(Class<T> klazz);
+
+ /**
+ * Remove from context the value with the given klazz as an unamed (if name is null) or named entry
+ *
+ * @param <T> type of data to remove from context
+ * @param klazz the klazz entry
+ * @param name extra name of the entry
+ */
+ public <T> void removeContextValue(Class<T> klazz, String name);
+
+ /**
+ * Seek for a unamed entry in the context
+ * <p/>
+ * This is an exemple to call a method in JAXX :
+ * <p/>
+ * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
+ *
+ * @param <T> type of data to obtain from context
+ * @param clazz the class of unamed entry to seek in context
+ * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
+ */
+ public <T> T getContextValue(Class<T> clazz);
+
+ /**
+ * Seek for a named entry in the context
+ *
+ * @param <T> type of data to obtain from context
+ * @param clazz the class of named entry to seek in context
+ * @param name the name of the entry to seek in context
+ * @return the value of the named entry for the given class, or <code>null</code> if no such entry.
+ */
+ public <T> T getContextValue(Class<T> clazz, String name);
+
+ /**
+ * Return parent's container corresponding to the Class clazz
+ *
+ * @param <O> type of container to obtain from context
+ * @param clazz clazz desired
+ * @return parent's container
+ */
+ public <O extends Container> O getParentContainer(Class<O> clazz);
+
+ /**
+ * Return parent's container corresponding to the Class clazz
+ *
+ * @param <O> type of container to obtain from context
+ * @param top the top container
+ * @param clazz desired
+ * @return parent's container
+ */
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -5,7 +5,6 @@
package jaxx.runtime;
import java.util.Map;
-import jaxx.runtime.context.JAXXContext;
/**
* The <code>JAXXObject</code> interface is implemented by all classes
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,23 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Component;
-import jaxx.runtime.swing.JaxxHelpBroker;
-
-/**
- *
- * Contract to be added on JAXXObject wihch wants to use javax help.
- *
- * @param <B> type of broker.
- *
- * @author tony
- * @since 1.3
- * @see JaxxHelpBroker
- */
-public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
-
- B getBroker();
-
- void registerHelpId(B broker, Component component, String helpId);
-
- void showHelp(String helpId);
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -53,10 +53,10 @@
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.tree.TreeNode;
import javax.swing.tree.TreePath;
-import jaxx.runtime.swing.BooleanCellRenderer;
-import jaxx.runtime.swing.EmptyNumberTableCellRenderer;
-import jaxx.runtime.swing.EnumTableCellRenderer;
-import jaxx.runtime.swing.I18nTableCellRenderer;
+import jaxx.runtime.swing.renderer.BooleanCellRenderer;
+import jaxx.runtime.swing.renderer.EmptyNumberTableCellRenderer;
+import jaxx.runtime.swing.renderer.EnumTableCellRenderer;
+import jaxx.runtime.swing.renderer.I18nTableCellRenderer;
import jaxx.runtime.swing.Item;
import jaxx.runtime.swing.JAXXComboBox;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,6 +1,5 @@
package jaxx.runtime;
-import jaxx.runtime.context.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import java.awt.Container;
import java.beans.PropertyChangeListener;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -118,6 +118,8 @@
value = super.getContextValue(realClass, name);
}
+ //TC-20091007 TODO Make possible use of named autoload entries
+ //(add a parameter on AutoLoad annotation)
if (value == null) {
AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import static jaxx.runtime.context.JAXXContextEntryDef.newDef;
import org.apache.commons.logging.Log;
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,107 +0,0 @@
-package jaxx.runtime.context;
-
-import java.awt.Container;
-
-/**
- * The {@link jaxx.runtime.context.JAXXContext} contract defines a generic context.
- * <p/>
- * A context contains two king of entries :
- * <p/>
- * <h2>Unamed entry</h2>
- * a such entry maps filter only on the clas of the object of the entry.
- * <p/>
- * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a
- * such entry.
- * <p/>
- * <h2>named entry</h2>
- * a such entry filter on class of the object and on the name of the entry.
- * <p/>
- * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)}
- * to reteave a such entry.
- *
- * @author letellier
- * @author chemit
- */
-public interface JAXXContext {
-
- /**
- * Push in the context a new unamed entry.
- * <p/>
- * If a previous entry exists in context (unamed and same class), it will be removed.
- *
- * @param <T> type of data to set in context
- * @param o the value to push in context
- */
- public <T> void setContextValue(T o);
-
- /**
- * * Push in the context a new amed entry.
- * <p/>
- * If a previous entry exists in context (same name and class), it will be removed.
- *
- * @param <T> type of data to set in context
- * @param o the value to push in context
- * @param name the name of the new entry
- */
- public <T> void setContextValue(T o, String name);
-
- /**
- * Remove from context the value with the given klazz as an unamed entry
- *
- * @param <T> type of data to remove from context
- * @param klazz the klazz entry
- */
- public <T> void removeContextValue(Class<T> klazz);
-
- /**
- * Remove from context the value with the given klazz as an unamed (if name is null) or named entry
- *
- * @param <T> type of data to remove from context
- * @param klazz the klazz entry
- * @param name extra name of the entry
- */
-
- public <T> void removeContextValue(Class<T> klazz, String name);
-
- /**
- * Seek for a unamed entry in the context
- * <p/>
- * This is an exemple to call a method in JAXX :
- * <p/>
- * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
- *
- * @param <T> type of data to obtain from context
- * @param clazz the class of unamed entry to seek in context
- * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
- */
- public <T> T getContextValue(Class<T> clazz);
-
- /**
- * Seek for a named entry in the context
- *
- * @param <T> type of data to obtain from context
- * @param clazz the class of named entry to seek in context
- * @param name the name of the entry to seek in context
- * @return the value of the named entry for the given class, or <code>null</code> if no such entry.
- */
- public <T> T getContextValue(Class<T> clazz, String name);
-
- /**
- * Return parent's container corresponding to the Class clazz
- *
- * @param <O> type of container to obtain from context
- * @param clazz clazz desired
- * @return parent's container
- */
- public <O extends Container> O getParentContainer(Class<O> clazz);
-
- /**
- * Return parent's container corresponding to the Class clazz
- *
- * @param <O> type of container to obtain from context
- * @param top the top container
- * @param clazz desired
- * @return parent's container
- */
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import java.util.Collections;
import java.util.List;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import java.awt.Container;
import java.util.Map.Entry;
import jaxx.runtime.JAXXObject;
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,61 +0,0 @@
-package jaxx.runtime.swing;
-
-import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JComponent;
-import javax.swing.JLabel;
-import javax.swing.JPanel;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.BorderLayout;
-import java.awt.Color;
-import java.awt.Component;
-
-/** @author chemit
- * @since 1.5
- */
-public class BooleanCellRenderer extends JPanel implements TableCellRenderer {
-
- private static final long serialVersionUID = 1L;
- protected TableCellRenderer defaultDelegate;
- protected JCheckBox checkBox;
-
- public BooleanCellRenderer(TableCellRenderer delegate) {
- //super(new BorderLayout());
- this.checkBox = new JCheckBox();
- add(checkBox, BorderLayout.CENTER);
- checkBox.setHorizontalAlignment(JLabel.CENTER);
- checkBox.setBorderPainted(true);
- this.defaultDelegate = delegate;
- }
-
- public BooleanCellRenderer(TableCellRenderer delegate, Icon icon) {
- //super(new BorderLayout());
- this.checkBox = new JCheckBox(icon);
- add(checkBox, BorderLayout.NORTH);
- checkBox.setHorizontalAlignment(JLabel.CENTER);
- checkBox.setVerticalTextPosition(JLabel.TOP);
- checkBox.setBorderPainted(true);
- this.defaultDelegate = delegate;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- ((JComponent) defaultDelegate).setBackground(null);
- JComponent render = (JComponent) defaultDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- if (isSelected) {
- setForeground(table.getSelectionForeground());
- setBackground(table.getSelectionBackground());
- } else {
- setForeground(render.getForeground());
- setBackground(render.getBackground());
- //fixme make this works... and remove the test
- if (row % 2 == 1) {
- setBackground(Color.WHITE);
- }
- }
- checkBox.setSelected((value != null && (Boolean) value));
- setBorder(render.getBorder());
- return this;
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,37 +0,0 @@
-package jaxx.runtime.swing;
-
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-import javax.swing.table.DefaultTableCellRenderer;
-
-/**
- * A {@link TableCellRenderer} which does not display numbers when they are
- * equals to 0.
- *
- * @author chemit
- * @since 1.5
- */
-public class EmptyNumberTableCellRenderer implements TableCellRenderer {
-
- protected final Integer ZERO = 0;
- protected final Float ZEROF = 0F;
- protected final Double ZEROD = 0D;
- private TableCellRenderer delegate;
-
- public EmptyNumberTableCellRenderer() {
- this(new DefaultTableCellRenderer());
- }
-
- public EmptyNumberTableCellRenderer(TableCellRenderer delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
- if (value == null || ZERO.equals(value) || ZEROF.equals(value) || ZEROD.equals(value)) {
- value = null;
- }
- return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,47 +0,0 @@
-package jaxx.runtime.swing;
-
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Component;
-import java.util.EnumSet;
-
-/**
- *
- *
- * A {@link TableCellRenderer} which displays enum values from their ordinal value.
- *
- * @param <E> le type de l'énumération.
- *
- * @author chemit
- * @since 1.5
- */
-public class EnumTableCellRenderer<E extends Enum<E>> implements TableCellRenderer {
-
- private TableCellRenderer delegate;
- private EnumSet<E> enumValues;
-
- public EnumTableCellRenderer(TableCellRenderer delegate, Class<E> enumClass) {
- this.delegate = delegate;
- this.enumValues = EnumSet.allOf(enumClass);
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
-
- if (value != null) {
- //FIXME : should be also able to read it by name ?
- Integer ordinal = Integer.valueOf(value + "");
- if (ordinal == -1) {
- value = null;
- } else {
- for (E enumValue : enumValues) {
- if (ordinal == enumValue.ordinal()) {
- value = enumValue;
- break;
- }
- }
- }
- }
- return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,66 +0,0 @@
-package jaxx.runtime.swing;
-
-import static org.nuiton.i18n.I18n._;
-
-import javax.swing.JComponent;
-import javax.swing.JTable;
-import javax.swing.table.TableCellRenderer;
-import javax.swing.table.TableColumn;
-import java.awt.Component;
-
-/**
- * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
- * the text is I18nalize.
- *
- * @author chemit
- */
-public class I18nTableCellRenderer implements TableCellRenderer {
-
- /** i18n keys of libelles to display */
- protected final String[] keys;
-
- /** i18n keys of toolTipTexts to display */
- protected final String[] tips;
-
- /** the delegate cell renderer */
- protected TableCellRenderer delegate;
-
- public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
- this.delegate = delegate;
- if (keysAndTips.length == 0) {
- throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
- }
- if (keysAndTips.length % 2 == 1) {
- throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
- }
- int size = keysAndTips.length / 2;
- this.keys = new String[size];
- this.tips = new String[size];
- for (int i = 0; i < size; i++) {
- this.keys[i] = keysAndTips[2 * i];
- this.tips[i] = keysAndTips[2 * i + 1];
- }
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
- if (column > keys.length) {
- throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
- }
- TableColumn col = table.getColumn(table.getColumnName(column));
- int index = col.getModelIndex();
- value = _(keys[index]);
- JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
- rendererComponent.setToolTipText(_(tips[index]));
- return rendererComponent;
- }
-
- public String[] getKeys() {
- return keys;
- }
-
- public String[] getTips() {
- return tips;
- }
-
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -11,6 +11,7 @@
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Hashtable;
+import java.util.Locale;
import java.util.Map;
import java.util.Vector;
import javax.help.CSH;
@@ -19,7 +20,7 @@
import javax.swing.AbstractButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
@@ -35,34 +36,68 @@
public abstract class JaxxHelpBroker<B extends JaxxHelpBroker<?>> {
public static final String JAXX_CONTEXT_ENTRY = "jaxxcontext";
- /** to use log facility, just put in your code: log.info(\"...\"); */
+ /**
+ * Logger
+ */
static private Log log = LogFactory.getLog(JaxxHelpBroker.class);
+ /**
+ * name of helpset
+ */
protected final String helpsetName;
+ /**
+ * default id to use if none given
+ */
protected final String defaultID;
+ /**
+ * help key
+ */
protected final String helpKey;
- // Main HelpSet & Broker
- protected final HelpSet helpset;
- protected final HelpBroker helpBroker;
+ /**
+ * helpset to use
+ */
+ protected HelpSet helpset;
+ /**
+ * help broker
+ */
+ protected HelpBroker helpBroker;
+ /**
+ * current locale used
+ */
+ protected Locale locale;
+ /**
+ * cache of cursors modified when in context-sensitive mode
+ */
protected Hashtable<Component, Cursor> cursors;
+ /**
+ * cursor to use in context-sensitive mode
+ */
protected Cursor onItemCursor;
+ /**
+ * cache of component which cursor have been modified
+ */
protected final Map<Component, String> cache;
protected JaxxHelpBroker(String helpsetName, String helpKey, String defaultID) {
+ this(null, helpsetName, helpKey, defaultID);
+ }
+
+ protected JaxxHelpBroker(Locale locale, String helpsetName, String helpKey, String defaultID) {
if (helpsetName == null) {
throw new NullPointerException("parameter helpsetName can not be null!");
}
+ this.locale = locale;
this.helpsetName = helpsetName;
this.helpKey = helpKey;
this.defaultID = defaultID;
cache = new HashMap<Component, String>();
- try {
- ClassLoader cl = getClass().getClassLoader();
- URL url = HelpSet.findHelpSet(cl, helpsetName);
- helpset = new HelpSet(cl, url);
- helpBroker = helpset.createHelpBroker();
- } catch (Exception ee) {
- throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
- }
+// try {
+// ClassLoader cl = getClass().getClassLoader();
+// URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
+// helpset = new HelpSet(cl, url);
+// helpBroker = helpset.createHelpBroker();
+// } catch (Exception ee) {
+// throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+// }
}
public void prepareUI(JAXXObject c) {
@@ -96,6 +131,9 @@
}
public HelpBroker getHelpBroker() {
+ if (helpBroker == null) {
+ helpBroker = getHelpset().createHelpBroker();
+ }
return helpBroker;
}
@@ -104,6 +142,15 @@
}
public HelpSet getHelpset() {
+ if (helpset == null) {
+ try {
+ ClassLoader cl = getClass().getClassLoader();
+ URL url = HelpSet.findHelpSet(cl, helpsetName, this.locale);
+ helpset = new HelpSet(cl, url);
+ } catch (Exception ee) {
+ throw new IllegalStateException("could not find help set " + helpsetName + " for reason " + ee.getMessage(), ee);
+ }
+ }
return helpset;
}
@@ -115,6 +162,15 @@
return defaultID;
}
+ public void setLocale(Locale locale) {
+ this.locale = locale;
+ // need to reload helpset and helpbroker
+ helpset = null;
+ helpBroker = null;
+ getHelpset();
+ getHelpBroker();
+ }
+
public void showHelpSet() {
if (log.isDebugEnabled()) {
log.debug(this);
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JaxxHelpUI.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpUI.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,22 @@
+package jaxx.runtime.swing;
+
+import java.awt.Component;
+
+/**
+ *
+ * Contract to be added on JAXXObject wihch wants to use javax help.
+ *
+ * @param <B> type of broker.
+ *
+ * @author tony
+ * @since 1.3
+ * @see JaxxHelpBroker
+ */
+public interface JaxxHelpUI<B extends JaxxHelpBroker<?>> {
+
+ B getBroker();
+
+ void registerHelpId(B broker, Component component, String helpId);
+
+ void showHelp(String helpId);
+}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,126 +0,0 @@
-package jaxx.runtime.swing;
-
-import java.awt.Component;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import javax.swing.DefaultListCellRenderer;
-import javax.swing.Icon;
-import javax.swing.JLabel;
-import javax.swing.JList;
-import jaxx.runtime.SwingUtil;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- *
- * @author chemit
- */
-public class LocaleListCellRenderer extends DefaultListCellRenderer {
-
- public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
- private static final long serialVersionUID = 1L;
- protected final Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
- protected boolean showIcon;
- protected boolean showText;
-
- public LocaleListCellRenderer() {
- this(true, true);
- }
-
- public LocaleListCellRenderer(boolean showIcon, boolean showText) {
- this.showIcon = showIcon;
- this.showText = showText;
- }
-
- @Override
- public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
- JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
- Locale locale = (Locale) value;
- if (locale != null) {
- Icon icon = getIcon(locale);
- comp.setIcon(icon);
- }
- String text = getText(locale);
- String tip = getToolTipText(locale);
- comp.setText(text);
- comp.setToolTipText(tip);
- return comp;
- }
-
- public String getText(Locale locale) {
- String text = null;
- if (showText) {
- text = getSafeText(locale);
- }
- return text;
- }
-
- public Icon getIcon(Locale locale) {
- if (!showIcon) {
- return null;
- }
- synchronized (cache) {
- Icon icon = getSafeIcon(locale);
- return icon;
- }
- }
-
- public String getToolTipText(Locale locale) {
- String tip = locale.getDisplayName(Locale.getDefault());
- return tip;
- }
-
- public boolean isShowText() {
- return showText;
- }
-
- public boolean isShowIcon() {
- return showIcon;
- }
-
- public void setShowIcon(boolean showIcon) {
- boolean old = this.showIcon;
- this.showIcon = showIcon;
- firePropertyChange("showIcon", old, showIcon);
- }
-
- public void setShowText(boolean showText) {
- boolean old = this.showText;
- this.showText = showText;
- firePropertyChange("showText", old, showText);
- }
-
- public String getSafeText(Locale locale) {
- String text = locale.getDisplayName(Locale.getDefault());
- return text;
- }
-
- public synchronized Icon getSafeIcon(Locale locale) {
- Icon icon = cache.get(locale);
- if (icon != null) {
- return icon;
- }
-
- icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.toString());
-
- if (icon == null) {
- log.warn("could not find icon action.i18n-" + locale.toString());
- if (locale.getCountry() != null) {
- icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.getCountry().toLowerCase());
- if (icon == null) {
- log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
-
- icon = SwingUtil.createActionIcon("i18n-" + locale.getCountry().toLowerCase());
- if (icon == null) {
- log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
- }
- }
-
- }
- }
-
- cache.put(locale, icon);
- return icon;
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,104 +0,0 @@
-package jaxx.runtime.swing;
-
-import org.nuiton.util.EnumEditor;
-
-import javax.swing.DefaultCellEditor;
-import javax.swing.Icon;
-import javax.swing.JCheckBox;
-import javax.swing.JComboBox;
-import javax.swing.JTable;
-import javax.swing.JTextField;
-import javax.swing.table.TableCellEditor;
-import java.awt.Component;
-
-/**
- * @author chemit
- * @since 1.5
- */
-public class MyDefaultCellEditor extends DefaultCellEditor {
-
- private static final long serialVersionUID = 1L;
-
- public static TableCellEditor newTextEditor() {
- return new MyDefaultCellEditor(new JTextField());
- }
-
- public static TableCellEditor newBooleanEditor() {
- return new MyDefaultCellEditor(new JCheckBox());
- }
-
- public static TableCellEditor newListEditor() {
- return newListEditor(new JComboBox());
- }
-
- public static TableCellEditor newListEditor(JComboBox editor) {
- return new MyDefaultCellEditor(editor);
- }
-
- public static TableCellEditor newEnumEditor(EnumEditor editor) {
- return new MyDefaultCellEditor(editor) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- public Object getCellEditorValue() {
- Object value = super.getCellEditorValue();
- if (value != null) {
- value = ((Enum) value).ordinal();
- } else {
- value = -1;
- }
- return value;
- }
- };
- }
-
- public static TableCellEditor newBooleanEditor(Icon icon) {
- return new MyDefaultCellEditor(new JCheckBox(icon));
- }
-
- public static TableCellEditor newBooleanEditor(Icon icon, boolean requireSelect) {
- TableCellEditor cellEditor = newBooleanEditor(icon);
- ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
- return cellEditor;
- }
-
- public static TableCellEditor newBooleanEditor(boolean requireSelect) {
- TableCellEditor cellEditor = newBooleanEditor();
- ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
- return cellEditor;
- }
- protected boolean requireSelect = true;
-
- @Override
- public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
- if (!isSelected && requireSelect) {
- // force to have select the cell before editing, a way to not modify edition for nothing...
- return null;
- }
- return super.getTableCellEditorComponent(table, value, isSelected, row, column);
- }
-
- public boolean isRequireSelect() {
- return requireSelect;
- }
-
- public void setRequireSelect(boolean requireSelect) {
- this.requireSelect = requireSelect;
- }
-
- protected MyDefaultCellEditor(JTextField textField) {
- super(textField);
- setClickCountToStart(1);
- }
-
- protected MyDefaultCellEditor(JCheckBox checkBox) {
- super(checkBox);
- setClickCountToStart(1);
- }
-
- protected MyDefaultCellEditor(JComboBox comboBox) {
- super(comboBox);
- setClickCountToStart(1);
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/MyDefaultCellEditor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/editor/MyDefaultCellEditor.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,103 @@
+package jaxx.runtime.swing.editor;
+
+import javax.swing.DefaultCellEditor;
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JComboBox;
+import javax.swing.JTable;
+import javax.swing.JTextField;
+import javax.swing.table.TableCellEditor;
+import java.awt.Component;
+import jaxx.runtime.swing.editor.EnumEditor;
+
+/**
+ * @author chemit
+ * @since 1.5
+ */
+public class MyDefaultCellEditor extends DefaultCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ public static TableCellEditor newTextEditor() {
+ return new MyDefaultCellEditor(new JTextField());
+ }
+
+ public static TableCellEditor newBooleanEditor() {
+ return new MyDefaultCellEditor(new JCheckBox());
+ }
+
+ public static TableCellEditor newListEditor() {
+ return newListEditor(new JComboBox());
+ }
+
+ public static TableCellEditor newListEditor(JComboBox editor) {
+ return new MyDefaultCellEditor(editor);
+ }
+
+ public static TableCellEditor newEnumEditor(EnumEditor<?> editor) {
+ return new MyDefaultCellEditor(editor) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Object getCellEditorValue() {
+ Object value = super.getCellEditorValue();
+ if (value != null) {
+ value = ((Enum) value).ordinal();
+ } else {
+ value = -1;
+ }
+ return value;
+ }
+ };
+ }
+
+ public static TableCellEditor newBooleanEditor(Icon icon) {
+ return new MyDefaultCellEditor(new JCheckBox(icon));
+ }
+
+ public static TableCellEditor newBooleanEditor(Icon icon, boolean requireSelect) {
+ TableCellEditor cellEditor = newBooleanEditor(icon);
+ ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
+ return cellEditor;
+ }
+
+ public static TableCellEditor newBooleanEditor(boolean requireSelect) {
+ TableCellEditor cellEditor = newBooleanEditor();
+ ((MyDefaultCellEditor) cellEditor).setRequireSelect(requireSelect);
+ return cellEditor;
+ }
+ protected boolean requireSelect = true;
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
+ if (!isSelected && requireSelect) {
+ // force to have select the cell before editing, a way to not modify edition for nothing...
+ return null;
+ }
+ return super.getTableCellEditorComponent(table, value, isSelected, row, column);
+ }
+
+ public boolean isRequireSelect() {
+ return requireSelect;
+ }
+
+ public void setRequireSelect(boolean requireSelect) {
+ this.requireSelect = requireSelect;
+ }
+
+ protected MyDefaultCellEditor(JTextField textField) {
+ super(textField);
+ setClickCountToStart(1);
+ }
+
+ protected MyDefaultCellEditor(JCheckBox checkBox) {
+ super(checkBox);
+ setClickCountToStart(1);
+ }
+
+ protected MyDefaultCellEditor(JComboBox comboBox) {
+ super(comboBox);
+ setClickCountToStart(1);
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.navigation;
import javax.swing.JTree;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
/**
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -6,7 +6,7 @@
import javax.swing.tree.DefaultTreeSelectionModel;
import javax.swing.tree.TreePath;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,6 +1,6 @@
package jaxx.runtime.swing.navigation;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.swing.CardLayout2;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import java.util.regex.Pattern;
import javax.swing.JTree;
import javax.swing.tree.TreePath;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,6 +1,6 @@
package jaxx.runtime.swing.navigation;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -2,7 +2,7 @@
import java.util.Enumeration;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.decorator.Decorator;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.TreeNode;
import jaxx.runtime.JAXXAction;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.JAXXObject;
import org.apache.commons.jxpath.JXPathContext;
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/BooleanCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/BooleanCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,61 @@
+package jaxx.runtime.swing.renderer;
+
+import javax.swing.Icon;
+import javax.swing.JCheckBox;
+import javax.swing.JComponent;
+import javax.swing.JLabel;
+import javax.swing.JPanel;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.BorderLayout;
+import java.awt.Color;
+import java.awt.Component;
+
+/** @author chemit
+ * @since 1.5
+ */
+public class BooleanCellRenderer extends JPanel implements TableCellRenderer {
+
+ private static final long serialVersionUID = 1L;
+ protected TableCellRenderer defaultDelegate;
+ protected JCheckBox checkBox;
+
+ public BooleanCellRenderer(TableCellRenderer delegate) {
+ //super(new BorderLayout());
+ this.checkBox = new JCheckBox();
+ add(checkBox, BorderLayout.CENTER);
+ checkBox.setHorizontalAlignment(JLabel.CENTER);
+ checkBox.setBorderPainted(true);
+ this.defaultDelegate = delegate;
+ }
+
+ public BooleanCellRenderer(TableCellRenderer delegate, Icon icon) {
+ //super(new BorderLayout());
+ this.checkBox = new JCheckBox(icon);
+ add(checkBox, BorderLayout.NORTH);
+ checkBox.setHorizontalAlignment(JLabel.CENTER);
+ checkBox.setVerticalTextPosition(JLabel.TOP);
+ checkBox.setBorderPainted(true);
+ this.defaultDelegate = delegate;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ ((JComponent) defaultDelegate).setBackground(null);
+ JComponent render = (JComponent) defaultDelegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ if (isSelected) {
+ setForeground(table.getSelectionForeground());
+ setBackground(table.getSelectionBackground());
+ } else {
+ setForeground(render.getForeground());
+ setBackground(render.getBackground());
+ //fixme make this works... and remove the test
+ if (row % 2 == 1) {
+ setBackground(Color.WHITE);
+ }
+ }
+ checkBox.setSelected((value != null && (Boolean) value));
+ setBorder(render.getBorder());
+ return this;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EmptyNumberTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EmptyNumberTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,37 @@
+package jaxx.runtime.swing.renderer;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import javax.swing.table.DefaultTableCellRenderer;
+
+/**
+ * A {@link TableCellRenderer} which does not display numbers when they are
+ * equals to 0.
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class EmptyNumberTableCellRenderer implements TableCellRenderer {
+
+ protected final Integer ZERO = 0;
+ protected final Float ZEROF = 0F;
+ protected final Double ZEROD = 0D;
+ private TableCellRenderer delegate;
+
+ public EmptyNumberTableCellRenderer() {
+ this(new DefaultTableCellRenderer());
+ }
+
+ public EmptyNumberTableCellRenderer(TableCellRenderer delegate) {
+ this.delegate = delegate;
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+ if (value == null || ZERO.equals(value) || ZEROF.equals(value) || ZEROD.equals(value)) {
+ value = null;
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/EnumTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/EnumTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,47 @@
+package jaxx.runtime.swing.renderer;
+
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import java.awt.Component;
+import java.util.EnumSet;
+
+/**
+ *
+ *
+ * A {@link TableCellRenderer} which displays enum values from their ordinal value.
+ *
+ * @param <E> le type de l'énumération.
+ *
+ * @author chemit
+ * @since 1.5
+ */
+public class EnumTableCellRenderer<E extends Enum<E>> implements TableCellRenderer {
+
+ private TableCellRenderer delegate;
+ private EnumSet<E> enumValues;
+
+ public EnumTableCellRenderer(TableCellRenderer delegate, Class<E> enumClass) {
+ this.delegate = delegate;
+ this.enumValues = EnumSet.allOf(enumClass);
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column) {
+
+ if (value != null) {
+ //FIXME : should be also able to read it by name ?
+ Integer ordinal = Integer.valueOf(value + "");
+ if (ordinal == -1) {
+ value = null;
+ } else {
+ for (E enumValue : enumValues) {
+ if (ordinal == enumValue.ordinal()) {
+ value = enumValue;
+ break;
+ }
+ }
+ }
+ }
+ return delegate.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/I18nTableCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/I18nTableCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,66 @@
+package jaxx.runtime.swing.renderer;
+
+import static org.nuiton.i18n.I18n._;
+
+import javax.swing.JComponent;
+import javax.swing.JTable;
+import javax.swing.table.TableCellRenderer;
+import javax.swing.table.TableColumn;
+import java.awt.Component;
+
+/**
+ * A simple TableCellRenderer using a delegate TableCellRenderer to render everything elese thant the text :
+ * the text is I18nalize.
+ *
+ * @author chemit
+ */
+public class I18nTableCellRenderer implements TableCellRenderer {
+
+ /** i18n keys of libelles to display */
+ protected final String[] keys;
+
+ /** i18n keys of toolTipTexts to display */
+ protected final String[] tips;
+
+ /** the delegate cell renderer */
+ protected TableCellRenderer delegate;
+
+ public I18nTableCellRenderer(TableCellRenderer delegate, String... keysAndTips) {
+ this.delegate = delegate;
+ if (keysAndTips.length == 0) {
+ throw new IllegalArgumentException("can not have empty keysAndTips parameters (means no column ?)");
+ }
+ if (keysAndTips.length % 2 == 1) {
+ throw new IllegalArgumentException("must have some couple (text,tooltTipText), but had a even number of data in keysAndTips parameter");
+ }
+ int size = keysAndTips.length / 2;
+ this.keys = new String[size];
+ this.tips = new String[size];
+ for (int i = 0; i < size; i++) {
+ this.keys[i] = keysAndTips[2 * i];
+ this.tips[i] = keysAndTips[2 * i + 1];
+ }
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasfocus, int row, int column) {
+ if (column > keys.length) {
+ throw new IndexOutOfBoundsException("colum can not be greater than " + keys.length);
+ }
+ TableColumn col = table.getColumn(table.getColumnName(column));
+ int index = col.getModelIndex();
+ value = _(keys[index]);
+ JComponent rendererComponent = (JComponent) delegate.getTableCellRendererComponent(table, value, isSelected, hasfocus, row, column);
+ rendererComponent.setToolTipText(_(tips[index]));
+ return rendererComponent;
+ }
+
+ public String[] getKeys() {
+ return keys;
+ }
+
+ public String[] getTips() {
+ return tips;
+ }
+
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java (from rev 1566, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/renderer/LocaleListCellRenderer.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -0,0 +1,126 @@
+package jaxx.runtime.swing.renderer;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.Locale;
+import java.util.Map;
+import javax.swing.DefaultListCellRenderer;
+import javax.swing.Icon;
+import javax.swing.JLabel;
+import javax.swing.JList;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ *
+ * @author chemit
+ */
+public class LocaleListCellRenderer extends DefaultListCellRenderer {
+
+ public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
+ private static final long serialVersionUID = 1L;
+ protected final Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
+ protected boolean showIcon;
+ protected boolean showText;
+
+ public LocaleListCellRenderer() {
+ this(true, true);
+ }
+
+ public LocaleListCellRenderer(boolean showIcon, boolean showText) {
+ this.showIcon = showIcon;
+ this.showText = showText;
+ }
+
+ @Override
+ public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
+ JLabel comp = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
+ Locale locale = (Locale) value;
+ if (locale != null) {
+ Icon icon = getIcon(locale);
+ comp.setIcon(icon);
+ }
+ String text = getText(locale);
+ String tip = getToolTipText(locale);
+ comp.setText(text);
+ comp.setToolTipText(tip);
+ return comp;
+ }
+
+ public String getText(Locale locale) {
+ String text = null;
+ if (showText) {
+ text = getSafeText(locale);
+ }
+ return text;
+ }
+
+ public Icon getIcon(Locale locale) {
+ if (!showIcon) {
+ return null;
+ }
+ synchronized (cache) {
+ Icon icon = getSafeIcon(locale);
+ return icon;
+ }
+ }
+
+ public String getToolTipText(Locale locale) {
+ String tip = locale.getDisplayName(Locale.getDefault());
+ return tip;
+ }
+
+ public boolean isShowText() {
+ return showText;
+ }
+
+ public boolean isShowIcon() {
+ return showIcon;
+ }
+
+ public void setShowIcon(boolean showIcon) {
+ boolean old = this.showIcon;
+ this.showIcon = showIcon;
+ firePropertyChange("showIcon", old, showIcon);
+ }
+
+ public void setShowText(boolean showText) {
+ boolean old = this.showText;
+ this.showText = showText;
+ firePropertyChange("showText", old, showText);
+ }
+
+ public String getSafeText(Locale locale) {
+ String text = locale.getDisplayName(Locale.getDefault());
+ return text;
+ }
+
+ public synchronized Icon getSafeIcon(Locale locale) {
+ Icon icon = cache.get(locale);
+ if (icon != null) {
+ return icon;
+ }
+
+ icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.toString());
+
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.toString());
+ if (locale.getCountry() != null) {
+ icon = SwingUtil.getUIManagerActionIcon("i18n-" + locale.getCountry().toLowerCase());
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
+
+ icon = SwingUtil.createActionIcon("i18n-" + locale.getCountry().toLowerCase());
+ if (icon == null) {
+ log.warn("could not find icon action.i18n-" + locale.getCountry().toLowerCase());
+ }
+ }
+
+ }
+ }
+
+ cache.put(locale, icon);
+ return icon;
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.wizard;
import javax.swing.SwingWorker;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import java.beans.PropertyChangeListener;
import java.util.Date;
import javax.swing.SwingWorker.StateValue;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -2,7 +2,7 @@
import java.awt.Window;
import javax.swing.ImageIcon;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.beanutils.ConstructorUtils;
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -1,5 +1,6 @@
package jaxx.runtime.context;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.*;
import org.junit.Assert;
import org.junit.Before;
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -4,7 +4,7 @@
import jaxx.runtime.swing.navigation.NavigationTreeModel;
import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
import jaxx.runtime.context.DefaultJAXXContext;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXContextEntryDef;
import org.junit.Assert;
import org.junit.Test;
@@ -85,7 +85,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
* as a bean.
* <p/>
* Tree is like this
@@ -205,7 +205,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
* as a list.
* <p/>
* Tree is like this
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/ColumnSelector.jaxx 2009-10-07 21:03:42 UTC (rev 1567)
@@ -44,7 +44,7 @@
<script><![CDATA[
import javax.swing.table.TableColumn;
import javax.swing.table.TableCellRenderer;
-import jaxx.runtime.swing.I18nTableCellRenderer;
+import jaxx.runtime.swing.renderer.I18nTableCellRenderer;
public static final String TABLE_PROPERTY = "myTable";
public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-07 21:03:42 UTC (rev 1567)
@@ -42,7 +42,7 @@
<Locale id='selectedLocale' javaBean='Locale.getDefault()'/>
- <jaxx.runtime.swing.LocaleListCellRenderer id='renderer'
+ <jaxx.runtime.swing.renderer.LocaleListCellRenderer id='renderer'
showIcon='{isShowIcon()}'
showText='{isShowText()}'
javaBean='new LocaleListCellRenderer(showIcon , showText)'/>
@@ -71,7 +71,7 @@
<script><![CDATA[
import java.util.Locale;
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.LocaleListCellRenderer;
+import jaxx.runtime.swing.renderer.LocaleListCellRenderer;
import static org.nuiton.i18n.I18n.n_;
public static final String DEFAULT_SELECTED_TOOLTIP = n_("i18neditor.selected");
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -32,7 +32,7 @@
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.SwingUtil;
@@ -59,7 +59,7 @@
* @param defaultCategory la categorie a selectionner
* @return l'ui instanciate
*/
- public static ConfigUI newConfigUI(jaxx.runtime.context.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
final ConfigUI ui = new ConfigUI(tx);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/pom.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/maven-jaxx-plugin/pom.xml 2009-10-07 21:03:42 UTC (rev 1567)
@@ -57,6 +57,11 @@
<artifactId>maven-helper-plugin</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ </dependency>
+
<!-- pour acceder aux BeansInfos swing via Introspector -->
<dependency>
<groupId>com.sun</groupId>
@@ -67,26 +72,18 @@
</dependency>
<!-- tests dependencies -->
-<!--
+
<dependency>
<groupId>org.apache.maven.shared</groupId>
- <artifactId>maven-plugin-testing-harness</artifactId>
- <version>1.1</version>
- <scope>test</scope>
- </dependency>
--->
- <dependency>
- <groupId>org.apache.maven.shared</groupId>
<artifactId>maven-verifier</artifactId>
- <version>1.0</version>
- <scope>test</scope>
</dependency>
- <dependency>
+ <!-- <dependency>
<groupId>org.apache.velocity</groupId>
<artifactId>velocity</artifactId>
<version>1.5</version>
- </dependency>
+ </dependency>-->
+
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 21:03:42 UTC (rev 1567)
@@ -25,7 +25,7 @@
import jaxx.compiler.decorators.CompiledObjectDecorator;
import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
import jaxx.compiler.tags.TagManager;
-import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXContext;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.model.Resource;
@@ -98,7 +98,7 @@
*/
protected String validatorFQN;
/**
- * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * the name of implementation of {@link jaxx.runtime.JAXXContext}
* to be used on {@link jaxx.runtime.JAXXObject}.
* <p/>
* Must not be abstract.
Modified: branches/jaxx-2.X/pom.xml
===================================================================
--- branches/jaxx-2.X/pom.xml 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/pom.xml 2009-10-07 21:03:42 UTC (rev 1567)
@@ -26,8 +26,6 @@
<module>jaxx-widgets</module>
- <!-- deprecated since 1.7.2, will be removed before 2.0.0
- <module>jaxx-example</module-->
<module>jaxx-demo</module>
</modules>
@@ -257,6 +255,26 @@
<artifactId>log4j</artifactId>
<version>1.2.14</version>
</dependency>
+
+ <dependency>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-velocity</artifactId>
+ <version>1.1.7</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-container-default</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.codehaus.plexus</groupId>
+ <artifactId>plexus-component-api</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>velocity</groupId>
+ <artifactId>velocity</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
<dependency>
<groupId>junit</groupId>
@@ -266,6 +284,13 @@
</dependency>
<dependency>
+ <groupId>org.apache.maven.shared</groupId>
+ <artifactId>maven-verifier</artifactId>
+ <version>1.0</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.maven.plugin-testing</groupId>
<artifactId>maven-plugin-testing-harness</artifactId>
<version>1.2</version>
Modified: branches/jaxx-2.X/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-07 21:03:42 UTC (rev 1567)
@@ -13,7 +13,7 @@
Le besoin initial de ce développement est de pouvoir facilement intégrer un context applicatif dans JAXX et de pouvoir
l'utiliser dans les fichiers JAXX pour injecter par exemple des données dans les widgets.
-jaxx.runtime.context.JAXXContext
+jaxx.runtime.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
Modified: branches/jaxx-2.X/src/site/rst/migration.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/migration.rst 2009-10-07 18:15:26 UTC (rev 1566)
+++ branches/jaxx-2.X/src/site/rst/migration.rst 2009-10-07 21:03:42 UTC (rev 1567)
@@ -15,7 +15,7 @@
* JList, JComboBox et JTree n'acceptent plus de fils Item (utiliser JAXXList,
JAXXComboBox, JAXXTree).
- * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.context.JAXXContext
+ * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.JAXXContext
* changement de paquetage de jaxx.runtime.\*Decorator vers jaxx.runtime.decorator.\*Decorator
1
0
r1566 - branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources
by tchemit@users.nuiton.org 07 Oct '09
by tchemit@users.nuiton.org 07 Oct '09
07 Oct '09
Author: tchemit
Date: 2009-10-07 20:15:26 +0200 (Wed, 07 Oct 2009)
New Revision: 1566
Modified:
branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties
Log:
changement logs (on veut pas voir nuiton-util en console :))
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-10-07 17:57:38 UTC (rev 1565)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/resources/log4j.properties 2009-10-07 18:15:26 UTC (rev 1566)
@@ -1,5 +1,5 @@
# Global logging configuration
-log4j.rootLogger=INFO, stdout
+log4j.rootLogger=WARN, stdout
# Console output...
log4j.appender.stdout=org.apache.log4j.ConsoleAppender
log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
1
0
Author: tchemit
Date: 2009-10-07 19:57:38 +0200 (Wed, 07 Oct 2009)
New Revision: 1565
Added:
branches/jaxx-2.X/src/site/rst/migration.rst
Modified:
branches/jaxx-2.X/src/site/rst/index.rst
branches/jaxx-2.X/src/site/site.xml
Log:
debut doc de migration 2.0
Modified: branches/jaxx-2.X/src/site/rst/index.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/index.rst 2009-10-07 17:37:55 UTC (rev 1564)
+++ branches/jaxx-2.X/src/site/rst/index.rst 2009-10-07 17:57:38 UTC (rev 1565)
@@ -1,5 +1,5 @@
-jaxx-core
-=========
+JAXX
+====
.. contents::
@@ -7,8 +7,11 @@
Présentation
------------
-Le projet Jaxx.
+TODO A faire car plus a jour...
+Le projet JAXX ...
+
+
Depuis la version 1.0, et en prévision de nouveaux générateurs s'appuyant sur Jaxx,on a revu l'architecture du projet.
Désormais, une séparation a été effectuée entre le code de compilation et le code d'exécution.
@@ -22,6 +25,13 @@
**Veuillez consulter la JavaDoc pour de plus ample détails sur les différentes
librairies.**
+Migration vers JAXX 2.0
+-----------------------
+
+La version 2.0 de JAXX n'est pas compatible avec les versions antérieures.
+
+Pour plus de détail consulter la page `Migration`_.
+
Nouvelles fonctionnalités
-------------------------
@@ -35,6 +45,8 @@
* NavigationTreeModel_
+.. _Migration: migration.html
+
.. _Core: Core.html
.. _I18n: I18n.html
Added: branches/jaxx-2.X/src/site/rst/migration.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/migration.rst (rev 0)
+++ branches/jaxx-2.X/src/site/rst/migration.rst 2009-10-07 17:57:38 UTC (rev 1565)
@@ -0,0 +1,25 @@
+Migration vers JAXX 2.0
+=======================
+
+.. contents::
+
+
+Présentation
+------------
+
+Ce document énumère les choses à migrer pour passer sur la version 2.0 de JAXX.
+
+Nouvelles fonctionnalités
+-------------------------
+
+ * JList, JComboBox et JTree n'acceptent plus de fils Item (utiliser JAXXList,
+ JAXXComboBox, JAXXTree).
+
+ * changement de paquetage de jaxx.runtime.JAXXContext vers jaxx.runtime.context.JAXXContext
+
+ * changement de paquetage de jaxx.runtime.\*Decorator vers jaxx.runtime.decorator.\*Decorator
+
+ * le framwork NavigationTree n'est plus compatible avec l'ancien... TODO
+
+TODO finish it
+
Modified: branches/jaxx-2.X/src/site/site.xml
===================================================================
--- branches/jaxx-2.X/src/site/site.xml 2009-10-07 17:37:55 UTC (rev 1564)
+++ branches/jaxx-2.X/src/site/site.xml 2009-10-07 17:57:38 UTC (rev 1565)
@@ -24,6 +24,7 @@
<menu name="Utilisateur">
<item name="Accueil" href="index.html"/>
+ <item name="Migration JAXX 2.0" href="migration.html"/>
</menu>
<menu name="Développeur">
1
0
Author: tchemit
Date: 2009-10-07 19:37:55 +0200 (Wed, 07 Oct 2009)
New Revision: 1564
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml
Log:
fix javadocs + improve messages in goal
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -14,73 +14,74 @@
/**
*
- * @return
+ * @return the class loader to use by compilers
*/
ClassLoader getClassLoader();
/**
*
- * @return
+ * @return the type of compiler to use
*/
Class<? extends JAXXCompiler> getCompilerClass();
/**
*
- * @return
+ * @return the type of default decorator to use if none specified
*/
Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass();
/**
*
- * @return
+ * @return the type of the default error UI to use for validation
*/
Class<?> getDefaultErrorUI();
/**
*
- * @return
+ * @return extra imports to add on all generated jaxx object
*/
String[] getExtraImports();
/**
*
- * @return
+ * @return the FQN of the help broker (can not directly a type since
+ * the help broker should (may?) be inside the sources.
*/
String getHelpBrokerFQN();
/**
*
- * @return
+ * @return the name of the help set to generate
*/
String getHelpSetName();
/**
*
- * @return
+ * @return the prefix of i18n keys to use in help system
*/
String getHelpsetI18nPrefix();
/**
*
- * @return
+ * @return the suffix of i18n keys to use in index of help system
*/
String getHelpsetIndexI18nSuffix();
/**
*
- * @return
+ * @return the suffix of i18n keys to use in title of the help system
*/
String getHelpsetTitleI18nSuffix();
/**
*
- * @return
+ * @return the suffix of i18n keys to use in toc of the help system
*/
String getHelpsetTocI18nSuffix();
/**
*
- * @return
+ * @return the type of context to use in each generated jaxx object
*/
Class<? extends JAXXContext> getJaxxContextClass();
@@ -92,64 +93,63 @@
boolean getOptimize();
/**
- * Returns the target directory, generally specified with the "-d" option on the command line.
+ * Returns the target directory.
*
* @return the target directory
- * @see #setTargetDirectory
*/
File getTargetDirectory();
/**
*
- * @return
+ * @return the type of validator to use
*/
Class<?> getValidatorClass();
/**
*
- * @return
+ * @return {@code true} if a logger must add on each generated jaxx object
*/
boolean isAddLogger();
/**
*
- * @return
+ * @return {@code true} if we are generating help
*/
boolean isGenerateHelp();
/**
*
- * @return
+ * @return {@code true} if we use the i18n system
*/
boolean isI18nable();
/**
*
- * @return
+ * @return {@code true} to generate optimized code
*/
boolean isOptimize();
/**
*
- * @return
+ * @return {@code true} if a profile pass must be done
*/
boolean isProfile();
/**
*
- * @return
+ * @return {@code true} if states must be reset after the compilation
*/
boolean isResetAfterCompile();
/**
*
- * @return
+ * @return {@code true} if UIManager is used to retrieve icons
*/
boolean isUseUIManagerForIcon();
/**
*
- * @return
+ * @return {@code true} if compiler is verbose
*/
boolean isVerbose();
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -7,9 +7,9 @@
import java.util.List;
/**
- * I18n methods to add {@link org.nuiton.i18n.I18n#_(String, Object[])} method on some attributes.
+ * I18n methods to add {@link org.nuiton.i18n.I18n#_(java.lang.String, java.lang.Object[])} method on some attributes.
* <p/>
- * Make sure to set an i18nable compiler to have his {@link CompilerOptions#isI18nable()} returning true.
+ * Make sure to set an i18nable compiler to have his {@link CompilerConfiguration#isI18nable()} returning true.
*
* @author chemit
*/
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -105,7 +105,7 @@
}
/**
- * Load the {@link jaxx.spi.Initializer} services found via the{@link ServiceLoader} mecanism.
+ * Load the {@link Initializer} services found via the{@link ServiceLoader} mecanism.
*
* @param verbose <ocde>true</code> to print initializers
*/
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -7,7 +7,7 @@
/**
* Thrown by <code>TagHandler</code> when an unsupported attribute is encountered.
*
- * @see jaxx.tags.TagHandler
+ * @see jaxx.compiler.tags.TagHandler
*/
public class UnsupportedAttributeException extends CompilerException {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -4,7 +4,7 @@
/**
* Mirrors the class <code>java.beans.BeanDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXBeanDescriptor extends JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -1,8 +1,10 @@
package jaxx.compiler.beans;
+import jaxx.compiler.reflect.ClassDescriptor;
+
/**
* Mirrors the class <code>java.beans.BeanInfo</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXBeanInfo {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -5,7 +5,7 @@
/**
* Mirrors the class <code>java.beans.EventSetDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXEventSetDescriptor extends JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -7,7 +7,7 @@
/**
* Mirrors the class <code>java.beans.FeatureDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -24,7 +24,7 @@
* don't believe it results in any meaningful incompatibilities.
* <p/>
* JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXIntrospector {
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -6,7 +6,7 @@
/**
* Mirrors the class <code>java.beans.PropertyDescriptor</code>. JAXX uses its own introspector rather than the built-in
- * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * <code>java.beans.Introspector</code> so that it can introspect {@link ClassDescriptor},
* not just <code>java.lang.Class</code>.
*/
public class JAXXPropertyDescriptor extends JAXXFeatureDescriptor {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -52,7 +52,7 @@
public static void main(String[] args) {
startingTime = System.nanoTime();
- log.info("Observe start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
+ log.info("JAXX Demo start at " + new java.util.Date() + " args: " + java.util.Arrays.toString(args));
try {
@@ -177,7 +177,6 @@
try {
super.run();
- //JAXXContext.get().close();
// force to kill main thread
log.info(_("jaxxdemo.init.closed", new java.util.Date()));
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -454,7 +454,7 @@
*
* Says using method {@link JTabbedPane#getComponent(int)}
* @param tabs the
- * @return
+ * @return the iterator
* @since 1.4
*/
public static TabbedPaneIterator<Component> newTabbedPaneIterator(JTabbedPane tabs) {
@@ -572,7 +572,7 @@
* @param parent
* @param x
* @param y
- * @return
+ * @return the deppest component
*/
public static Component getDeepestObjectAt(Component parent, int x, int y) {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -2,6 +2,7 @@
import java.awt.Container;
import java.util.Map.Entry;
+import jaxx.runtime.JAXXObject;
/**
* An initial context to be inject in a {@link JAXXObject}.
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/decorator/DecoratorUtils.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -24,11 +24,11 @@
* To register a new decorator, use the method {@link #register(String, Decorator)}.
* <p/>
* To obtain a registred decorator, use the method {@link #get(String)}
- * (get the decorator based on his registred name). or the method {@link #get(Class, tring)}
+ * (get the decorator based on his registred name). or the method {@link #get(Class, String)}
* (get the decorator based on the type of decorator and the registred name).
* <p/>
* To sort a list of data, using a {@link JXPathDecorator}, use the method
- * {@link #sort(JXPathDecorator, java.util.List, int)}.
+ * {@link #sort(JXPathDecorator, List, int)}.
* <p/>
*
* @author tony
@@ -43,7 +43,7 @@
/**
* Factory method to instanciate a new {@link PropertyDecorator} for the
- * given class {@link O} and a readable property name.
+ * given class {@code internlaClass} and a readable property name.
*
* @param internalClass the class of the objects decorated by the new decorator
* @param property the property
@@ -63,7 +63,7 @@
/**
* Factory method to instanciate a new {@link JXPathDecorator} for the
- * given class {@link O} and expression.
+ * given class {@code internalClass} and expression.
*
* @param internalClass the class of the objects decorated by the new decorator
* @param expression the expression to use to decorated objects
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/Item.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -148,7 +148,7 @@
/**
* Remove all childs nodes
*
- * @param list of items to remove
+ * @param items list of items to remove
*/
public void removeChilds(List<Item> items) {
if (children != null) {
@@ -181,7 +181,7 @@
/**
* Set the parent of this item
*
- * @return the item parent (or null)
+ * @param parent the item parent (or null)
*/
public void setParent(Item parent) {
this.parent = parent;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -27,7 +27,7 @@
*/
static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
/**
- * The path separator used to build the {@link #fullPath}.
+ * The path separator used to build the {@link NavigationTreeNode#fullPath}.
*
* @see NavigationTreeNode#getNodePath()
* @see NavigationTreeNode#getFullPath()
@@ -51,7 +51,7 @@
/**
* Search from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * {@link NavigationTreeNode#path} valued separated by dot.
* <p/>
* Example :
* <p/>
@@ -68,7 +68,7 @@
* Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
* <p/>
* Search then from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
* <p/>
* <p/>
* Example :
@@ -87,7 +87,7 @@
* Apply first the regex pattern to obtain the searched node.
* <p/>
* Search then from the root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
* <p/>
* Example :
* <p/>
@@ -103,7 +103,7 @@
/**
* Search from a given root node a node named by his fully path (concatenation of nodes
- * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
*
* @param root root node to be used
* @param path the fully path of the searched node.
@@ -117,7 +117,7 @@
* Apply first the regex pattern to obtain the searched node.
* <p/>
* Search then from a given root node a node named by his fully path (concatenation of nodes)
- * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
*
* @param root root node to be used
* @param path the fully path of the searched node.
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -255,8 +255,8 @@
}
/**
- * @param path the name of the {@link #path} to be matched in the cild of this node.
- * @return the child of this node with given {@link # path} value.
+ * @param path the name of the {@link #path} to be matched in the child of this node.
+ * @return the child of this node with given {@link #path} value.
*/
public NavigationTreeNode getChild(String path) {
Enumeration<?> childs = children();
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -12,7 +12,7 @@
* Thread qui réalise les opérations.
*
* Pour exécuter une nouvelle opération, on utilise la méthode
- * {@link #launchOperation(SynchroActionWorker)}.
+ * {@link #launchOperation(WizardOperationStep)}.
*
* Note: Pour bloquer (ou débloquer) le thread, on utilise la méthode {@link #setWaiting(boolean)}
*
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidator.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -328,9 +328,9 @@
* programmation, ce qui est utile par exemple si le bean ne supporte
* pas les {@link PropertyChangeListener}
*
- * TODO la methode devra repasser en protected et on preperar utiliser la
- * methode {@link #doRevalidate()} car {@link #validate()} ne modifie pas
- * les etats internes et cela en rends son utilisation delicate (le
+ * TODO la methode devra repasser en protected et on utilise la
+ * methode {@link #doValidate()} car {@link #validate()} ne modifie pas
+ * les etats internes et cela en rend son utilisation delicate (le
* validateur entre dans un etat incoherent par rapport aux messages envoyés).
*/
public void validate() {
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorListener.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -1,7 +1,7 @@
package jaxx.runtime.validator;
/**
- * The listener contract to be used on {@link BeanValidator]
+ * The listener contract to be used on {@link BeanValidator}
*
* @author chemit
* @since 1.3
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/validator/BeanValidatorMessage.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -3,7 +3,7 @@
/**
* The object to box a validation message.
*
- * @param <E> type of message (use for override {@link #compareTo(E)} method.
+ * @param <E> type of message (use for override {@link #compareTo(Object)} method.
*
* @author chemit
* @since 1.3
@@ -15,7 +15,7 @@
*/
protected BeanValidator<?> validator;
/**
- * the field thatproduce the message
+ * the field that produce the message
*/
protected BeanValidatorField<?> field;
/**
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 17:37:55 UTC (rev 1564)
@@ -53,7 +53,7 @@
import org.apache.commons.lang.builder.ToStringStyle;
/**
- * Classe permettant de transformer des sources jaxx vers du source java.
+ * Generates some java code from jaxx files.
*
* @author chemit
* @goal generate
@@ -113,8 +113,6 @@
* If not given, will use the one defined in validator
*
* @parameter expression="${jaxx.defaultErrorUIFQN}"
- *
- * @see jaxx.runtime.validator.swing.SwingValidator
*/
protected String defaultErrorUIFQN;
/**
@@ -124,7 +122,7 @@
*
* @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
*
- * @see jaxx.compiler.CompiledObjectDecorator
+ * @see jaxx.compiler.decorators.CompiledObjectDecorator
*/
protected String defaultDecoratorFQN;
/**
@@ -203,7 +201,7 @@
* <p/>
* add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
* <p/>
- * and then will be use by {@link jaxx.tags.swing.SwingInitializer#initialize()}.
+ * and then will be use by {@link jaxx.compiler.spi.DefaultInitializer#initialize()}.
* <p/>
* <p/>
* This permit to use real beanInfo of imported graphic libraries.
@@ -252,15 +250,17 @@
*/
protected String helpBrokerFQN;
/**
- *
+ * detected jaxx files in {@link #init()} method
*/
protected String[] files;
/**
+ * file updater used to detect jaxx files.
*
+ * <b>Note:</b> if {@link #verbose} flag is on, will ne be used
*/
protected MirroredFileUpdater updater;
/**
- *
+ *
*/
private Class<?> defaultErrorUIClass;
/**
@@ -283,6 +283,10 @@
*
*/
private String[] extraImports;
+ /**
+ *
+ */
+ private boolean nofiles;
@SuppressWarnings("unchecked")
@Override
@@ -295,14 +299,39 @@
}
}
- if (addSourcesToClassPath || addProjectClassPath) {
- cl = initClassLoader(project, getLog());
- Thread.currentThread().setContextClassLoader(cl);
- } else {
- cl = getClass().getClassLoader();
- //cl = Thread.currentThread().getContextClassLoader();
+ fixCompileSourceRoots();
+
+ if (includes == null || includes.length == 0) {
+ // use default includes
+ includes = INCLUDES;
}
+ updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
+ Map<File, String[]> result = new HashMap<File, String[]>();
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
+
+ this.files = result.get(src);
+
+ nofiles = files == null || files.length == 0;
+ if (nofiles) {
+ return true;
+ }
+
+// if (addSourcesToClassPath || addProjectClassPath) {
+ cl = initClassLoader(project,
+ src,
+ addSourcesToClassPath,
+ testPhase,
+ addResourcesToClassPath,
+ addCompileClassPath,
+ addProjectClassPath);
+
+ Thread.currentThread().setContextClassLoader(cl);
+// } else {
+// cl = getClass().getClassLoader();
+ //cl = Thread.currentThread().getContextClassLoader();
+// }
+
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
@@ -324,25 +353,8 @@
outJava.mkdirs();
}
- fixCompileSourceRoots();
-
- boolean noIncludes = includes == null || includes.length == 0;
-
- if (noIncludes) {
- includes = INCLUDES;
- }
- updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
-
- Map<File, String[]> result = new HashMap<File, String[]>();
- getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
-
- this.files = result.get(src);
-
- if (files == null || files.length == 0) {
- getLog().warn("No files to treate.");
- return false;
- }
-
+ // compute extra imports (can not use java classes since some of
+ // imports can not be still compiled)
if (extraImportList != null && !extraImportList.isEmpty()) {
String[] imports = extraImportList.split(",");
int i = 0;
@@ -364,16 +376,22 @@
@Override
public void doAction() throws MojoExecutionException {
- getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
+ if (nofiles) {
+ getLog().info("No files to treate.");
+ return;
+ }
+ getLog().info("Detects " + files.length + " modify jaxx file(s). ");
+
try {
// force compiler init from here, not in a static block
TagManager.reset(verbose);
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
+ JAXXCompilerLaunchor launchor;
+ launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
boolean success = launchor.compile();
- getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
+ getLog().info("Generated " + launchor.getCompilerCount() + " file(s). ");
if (!success) {
throw new MojoExecutionException("Aborting due to errors reported by jaxxc");
@@ -596,7 +614,7 @@
//TODO use the AbstractPublig method
@SuppressWarnings({"unchecked"})
- protected URLClassLoader initClassLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
+ protected URLClassLoader initClasLoader(MavenProject project, org.apache.maven.plugin.logging.Log log) throws MalformedURLException {
URLClassLoader loader = null;
if (project != null) {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-07 14:23:35 UTC (rev 1563)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-07 17:37:55 UTC (rev 1564)
@@ -17,6 +17,9 @@
<!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<jaxxContextFQN>java.lang.String</jaxxContextFQN>
<force>true</force>
+ <includes>
+ <value>**/Evolution74Test/ok/*.jaxx</value>
+ </includes>
</configuration>
</plugin>
</plugins>
1
0
r1563 - in branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler: . decorators generators
by tchemit@users.nuiton.org 07 Oct '09
by tchemit@users.nuiton.org 07 Oct '09
07 Oct '09
Author: tchemit
Date: 2009-10-07 16:23:35 +0200 (Wed, 07 Oct 2009)
New Revision: 1563
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java
Log:
refactor jaxx 2.x
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,155 @@
+package jaxx.compiler;
+
+import java.io.File;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.runtime.context.JAXXContext;
+
+/**
+ * TODO javadoc.
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public interface CompilerConfiguration {
+
+ /**
+ *
+ * @return
+ */
+ ClassLoader getClassLoader();
+
+ /**
+ *
+ * @return
+ */
+ Class<? extends JAXXCompiler> getCompilerClass();
+
+ /**
+ *
+ * @return
+ */
+ Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass();
+
+ /**
+ *
+ * @return
+ */
+ Class<?> getDefaultErrorUI();
+
+ /**
+ *
+ * @return
+ */
+ String[] getExtraImports();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpBrokerFQN();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpSetName();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetI18nPrefix();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetIndexI18nSuffix();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetTitleI18nSuffix();
+
+ /**
+ *
+ * @return
+ */
+ String getHelpsetTocI18nSuffix();
+
+ /**
+ *
+ * @return
+ */
+ Class<? extends JAXXContext> getJaxxContextClass();
+
+ /**
+ * Returns whether or not optimization should be performed.
+ *
+ * @return whether or not optimizations should be performed
+ */
+ boolean getOptimize();
+
+ /**
+ * Returns the target directory, generally specified with the "-d" option on the command line.
+ *
+ * @return the target directory
+ * @see #setTargetDirectory
+ */
+ File getTargetDirectory();
+
+ /**
+ *
+ * @return
+ */
+ Class<?> getValidatorClass();
+
+ /**
+ *
+ * @return
+ */
+ boolean isAddLogger();
+
+ /**
+ *
+ * @return
+ */
+ boolean isGenerateHelp();
+
+ /**
+ *
+ * @return
+ */
+ boolean isI18nable();
+
+ /**
+ *
+ * @return
+ */
+ boolean isOptimize();
+
+ /**
+ *
+ * @return
+ */
+ boolean isProfile();
+
+ /**
+ *
+ * @return
+ */
+ boolean isResetAfterCompile();
+
+ /**
+ *
+ * @return
+ */
+ boolean isUseUIManagerForIcon();
+
+ /**
+ *
+ * @return
+ */
+ boolean isVerbose();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerConfiguration.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,30 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompiledObject.ChildRef;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaFile;
+import jaxx.runtime.SwingUtil;
+
+/**
+ * A decorator to surround a compiled object (should be a component at least)
+ * with a JXLayer.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+ CompiledObject parent = object.getParent();
+ for (ChildRef child : parent.getChilds()) {
+ if (child.getChild() == object) {
+ String javaCode = child.getChildJavaCode();
+ child.setChildJavaCode(SwingUtil.class.getName() + ".boxComponentWithJxLayer(" + javaCode + ")");
+ break;
+ }
+ }
+ super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/BoxedCompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,26 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaFile;
+
+/**
+ *
+ * Contract of compiled object decorator at generation time.
+ *
+ * Note : The implementation of this class must be stateless.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public interface CompiledObjectDecorator {
+
+ String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings);
+
+ boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall);
+
+ void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName);
+
+ String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException;
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,59 @@
+package jaxx.compiler.decorators;
+
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public class CompiledObjectDecoratorManager {
+
+ protected static Map<String, CompiledObjectDecorator> cache;
+
+ public static void registerDecorator(String key, Class<? extends CompiledObjectDecorator> klass) {
+ synchronized (getCache()) {
+ if (getCache().containsKey(key)) {
+ throw new IllegalArgumentException("the decorator with key [" + key + "] is already registred! use another key name");
+ }
+ try {
+ getCache().put(key, klass.newInstance());
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
+ }
+ }
+ }
+
+ public static CompiledObjectDecorator getDecorator(String name) {
+ CompiledObjectDecorator decorator = getCache().get(name);
+ if (decorator == null) {
+ throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + getCache().keySet());
+ }
+ return decorator;
+ }
+
+ public static CompiledObjectDecorator getDecorator(Class<?> type) {
+ for (CompiledObjectDecorator decorator : getCache().values()) {
+ if (type == decorator.getClass()) {
+ return decorator;
+ }
+ }
+ return null;
+ }
+
+ protected static synchronized Map<String, CompiledObjectDecorator> getCache() {
+ if (cache == null) {
+ cache = new TreeMap<String, CompiledObjectDecorator>();
+ }
+ return cache;
+ }
+
+ public static void reset() {
+ if (cache != null) {
+ cache.clear();
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/CompiledObjectDecoratorManager.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,131 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaField;
+import jaxx.compiler.JavaFile;
+import jaxx.compiler.JavaMethod;
+import jaxx.compiler.ScriptInitializer;
+import jaxx.compiler.types.TypeManager;
+
+import java.lang.reflect.Modifier;
+import java.util.Map.Entry;
+
+/**
+ * The default compiledObjectDecorator.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class DefaultCompiledObjectDecorator implements CompiledObjectDecorator {
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+
+ if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
+ String id = object.getId();
+ int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
+ if (object == root) {
+ javaFile.addField(new JavaField(access, fullClassName, id, "this"));
+ } else {
+ //TC -20081017 can have generic on compiled Object
+ javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
+ }
+ }
+
+ if (!compiler.inlineCreation(object) && object != root) {
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
+ }
+ }
+
+ @Override
+ public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
+ if (object instanceof ScriptInitializer) {
+ return object.getInitializationCode(compiler);
+ }
+ StringBuffer result = new StringBuffer();
+ if (object.isOverride() && object.getOverrideType() == object.getObjectClass()) {
+ //TC-20090309 on utilise le super code quand l'objet est de meme type
+ result.append("super.").append(object.getCreationMethodName()).append("();");
+ } else {
+ result.append(object.getId());
+ result.append(" = ");
+ if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
+ result.append(object.getJavaBeanInitCode()).append(";");
+ } else {
+ String constructorParams = object.getConstructorParams();
+ if (constructorParams != null) {
+ //TC - 20081017 compiledObject can have generics
+ result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
+ //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ } else {
+ //TC - 20081017 compiledObject can have generics
+ result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ }
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ String initCode = object.getInitializationCode(compiler);
+ if (initCode != null && initCode.length() > 0) {
+ result.append(initCode);
+ }
+
+ return result.toString();
+ }
+
+ @Override
+ public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) {
+ StringBuffer code = new StringBuffer();
+ //TC-20090327 generate client properties
+ if (object.hasClientProperties()) {
+ // generate putClientProperty invocations
+ for (Entry<String, String> entry : object.getClientProperties().entrySet()) {
+ object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");");
+ }
+
+ }
+ //TC - 20081017 only generate the method if not empty ?
+ if (object.getId().startsWith("$")) {
+ code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
+ } else {
+ String additionCode = object.getAdditionCode();
+ if (additionCode.length() > 0) {
+ code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
+ additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
+ }
+ }
+ //code.append(getLineSeparator());
+ return code.toString();
+ }
+
+ @Override
+ public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) {
+ if (object == root) {
+ String rootCode = root.getInitializationCode(compiler);
+ if (rootCode != null && rootCode.length() > 0) {
+ code.append(rootCode);
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ } else {
+ if (!object.isOverride()) {
+ if (compiler.inlineCreation(object)) {
+ if (lastWasMethodCall) {
+ lastWasMethodCall = false;
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append(getCreationCode(compiler, object));
+ code.append(JAXXCompiler.getLineSeparator());
+ } else {
+ code.append(object.getCreationMethodName()).append("();");
+ code.append(JAXXCompiler.getLineSeparator());
+ lastWasMethodCall = true;
+ }
+ }
+ }
+ return lastWasMethodCall;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/DefaultCompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,100 @@
+package jaxx.compiler.decorators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.CompilerConfiguration;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaArgument;
+import jaxx.compiler.JavaFile;
+import jaxx.compiler.JavaMethod;
+
+import java.lang.reflect.Modifier;
+import java.util.Iterator;
+import java.util.Set;
+
+/**
+ * A decorator to place on a root compiled object to process javaHelp on the file.
+ *
+ * @author tony
+ * @since 1.2
+ */
+public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
+
+ /**
+ * the list of discovered helpId
+ */
+ protected static Set<String> helpIds = new java.util.HashSet<String>();
+
+ protected String getBrokerFQN(JAXXCompiler compiler) {
+ String helpBrokerFQN = compiler.getConfiguration().getHelpBrokerFQN();
+ return helpBrokerFQN;
+ }
+
+ protected String getHelpId(CompiledObject o) {
+ String helpID = null;
+ if (o.hasClientProperties()) {
+ helpID = o.getClientProperty("help");
+ }
+ return helpID;
+ }
+
+ @Override
+ public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
+ super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+ CompilerConfiguration options = compiler.getConfiguration();
+
+ if (options.isGenerateHelp()) {
+
+ // add JaxxHelpUI interface
+ Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
+ String helpBrokerFQN = getBrokerFQN(compiler);
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "registerHelpId",
+ "broker.installUI(component, helpId);",
+ new JavaArgument(helpBrokerFQN, "broker"),
+ new JavaArgument("Component", "component"),
+ new JavaArgument("String", "helpId")));
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "showHelp",
+ "getBroker().showHelp(this, helpId);",
+ new JavaArgument("String", "helpId")));
+
+ StringBuilder buffer = new StringBuilder();
+
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+
+ if (options.isGenerateHelp()) {
+
+ // add code to init javax help system
+ Iterator<CompiledObject> itr = compiler.getObjectCreationOrder();
+
+ for (; itr.hasNext();) {
+ CompiledObject o = itr.next();
+ String helpID = getHelpId(o);
+ if (helpID != null) {
+ buffer.append(lineSeparator);
+ // detects a helpId to register
+ buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");");
+ //keep the helpID for helpSet generation
+ helpIds.add(helpID);
+ }
+ }
+ }
+ if (buffer.length() > 0) {
+
+ StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();");
+
+ buffer.append(lineSeparator).append("_broker.prepareUI(this);");
+ buffer.append(lineSeparator);
+
+ // add the calls
+ compiler.appendLateInitializer(extraCode.toString());
+ compiler.appendLateInitializer(buffer.toString());
+ }
+ }
+ }
+
+ public static Set<String> getHelpIds() {
+ return helpIds;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/decorators/HelpRootCompiledObjectDecorator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,42 @@
+package jaxx.compiler.generators;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ServiceLoader;
+
+/**
+ *
+ * @author chemit
+ * @since 2.0.0
+ */
+public class GeneratorManager {
+
+ protected static List<Generator> generators;
+
+ public static List<Generator> getGenerators() {
+ if (generators == null) {
+ loadGenerators();
+ }
+ return generators;
+ }
+
+ public static void addGenerator(Generator g) {
+ getGenerators().add(g);
+ }
+
+ public static void clear() {
+ if (generators != null) {
+ generators.clear();
+ generators = null;
+ }
+ }
+
+ protected static void loadGenerators() {
+ if (generators == null) {
+ generators = new ArrayList<Generator>();
+ for (Generator generator : ServiceLoader.load(Generator.class)) {
+ generators.add(generator);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/GeneratorManager.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,604 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.*;
+import jaxx.runtime.Base64Coder;
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXObjectDescriptor;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.Util;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import static java.lang.reflect.Modifier.FINAL;
+import static java.lang.reflect.Modifier.PROTECTED;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}.
+ * <p/>
+ * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the
+ * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files.
+ *
+ * @author chemit
+ */
+public class JAXXObjectGenerator implements Generator {
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(JAXXObjectGenerator.class);
+ protected static final JavaField ACTIVE_BINDINGS_FIELD = JavaField.newField(PROTECTED,
+ "java.util.List<Object>", "$activeBindings", "new ArrayList<Object>()");
+ protected static final JavaField BINDING_SOURCES_FIELD = JavaField.newField(PROTECTED,
+ "java.util.Map<String,Object>", "$bindingSources", "new HashMap<String,Object>()");
+ protected static final JavaField OBJECT_MAP_FIELD = JavaField.newField(PROTECTED,
+ "Map<String,Object>", "$objectMap", "new HashMap<String,Object>()");
+ protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
+ "boolean", "allComponentsCreated");
+ protected static final JavaField CONTEXT_INITIALIZED = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
+ "boolean", "contextInitialized", "true");
+ protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
+ "java.util.Map", "$previousValues", "new java.util.HashMap()");
+ protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED,
+ "jaxx.runtime.context.JAXXContext", "delegateContext");
+ protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = JavaField.newField(0,
+ "java.beans.PropertyChangeSupport", "$propertyChangeSupport");
+ protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
+ "return delegateContext.getContextValue(clazz, null);",
+ new JavaArgument("Class<T>", "clazz"));
+ protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
+ "return delegateContext.getContextValue(clazz, name);",
+ new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
+ protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
+ "delegateContext.setContextValue(o, name);",
+ new JavaArgument("T", "o"), new JavaArgument("String", "name"));
+ protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
+ "delegateContext.setContextValue(o, null);",
+ new JavaArgument("T", "o"));
+ protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
+ "delegateContext.removeContextValue(clazz, name);",
+ new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
+ protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
+ "delegateContext.removeContextValue(clazz, null);",
+ new JavaArgument("Class<T>", "clazz"));
+ protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
+ "return delegateContext.getParentContainer(source, clazz);",
+ new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz"));
+ protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
+ "return delegateContext.getParentContainer(clazz);",
+ new JavaArgument("Class<O>", "clazz"));
+ protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "java.lang.Object", "getObjectById",
+ "return $objectMap.get(id);",
+ new JavaArgument("String", "id"));
+ protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC, "jaxx.runtime.JAXXObjectDescriptor", "$getJAXXObjectDescriptor",
+ "return jaxx.runtime.Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);");
+ protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "processDataBinding",
+ "processDataBinding(dest, false);",
+ new JavaArgument("String", "dest"));
+ protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
+ "super.firePropertyChange(propertyName, oldValue, newValue);",
+ new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
+ protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
+ "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);",
+ new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
+ protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(0, "java.beans.PropertyChangeSupport", "$getPropertyChangeSupport",
+ "if ($propertyChangeSupport == null)\n" +
+ " $propertyChangeSupport = new PropertyChangeSupport(this);\n" +
+ "return $propertyChangeSupport;");
+ protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
+ "$getPropertyChangeSupport().addPropertyChangeListener(listener);",
+ new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+ protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
+ "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);",
+ new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+ protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
+ "$getPropertyChangeSupport().removePropertyChangeListener(listener);",
+ new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+ protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
+ "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);",
+ new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
+
+ @Override
+ public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
+
+ String fullClassName = packageName != null ? packageName + "." + className : className;
+ if (root == null) {
+ throw new CompilerException("root tag must be a class tag");
+ }
+ //Map<String, CompiledObject> objects = compiler.getObjects();
+ ClassDescriptor superclass = root.getObjectClass();
+ boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass);
+ javaFile.setModifiers(Modifier.PUBLIC);
+ javaFile.setClassName(fullClassName);
+ javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass));
+ javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject);
+
+ javaFile.addInterfaces(compiler.getExtraInterfaces());
+ javaFile.setAbstractClass(compiler.isAbstractClass());
+ javaFile.setGenericType(compiler.getGenericType());
+ javaFile.setSuperGenericType(compiler.getSuperGenericType());
+
+ for (CompiledObject object : compiler.getObjects().values()) {
+ CompiledObjectDecorator decorator = object.getDecorator();
+ decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
+
+ /*if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
+ String id = object.getId();
+ int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
+ if (object == root) {
+ javaFile.addField(new JavaField(access, fullClassName, id, "this"));
+ } else {
+ //TC -20081017 can have generic on compiled Object
+ javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
+ }
+ }
+
+ if (!compiler.inlineCreation(object) && object != root) {
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
+ }*/
+ }
+
+ // DataBinding
+ for (DataBinding dataBinding : compiler.getDataBindings()) {
+ if (dataBinding.compile(true)) {
+ compiler.getInitDataBindings().append("applyDataBinding(").append(TypeManager.getJavaCode(dataBinding.getId())).append(");").append(JAXXCompiler.getLineSeparator());
+ }
+ }
+
+ if (superclassIsJAXXObject) {
+ boolean hasBind = compiler.getApplyDataBinding().length() > 0;
+ if (hasBind) {
+ compiler.appendApplyDataBinding(" else {");
+ compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
+ compiler.appendApplyDataBinding(" ");
+ }
+ compiler.appendApplyDataBinding("super.applyDataBinding($binding);");
+ compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
+
+ if (hasBind) {
+ compiler.appendApplyDataBinding(" return;");
+ compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
+ compiler.appendApplyDataBinding("}");
+ }
+
+
+ hasBind = compiler.getRemoveDataBinding().length() > 0;
+ if (hasBind) {
+ compiler.appendRemoveDataBinding(" else {");
+ compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
+ compiler.appendRemoveDataBinding(" ");
+ }
+ compiler.appendRemoveDataBinding("super.removeDataBinding($binding);");
+ compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
+
+ if (hasBind) {
+ compiler.appendRemoveDataBinding("}");
+ }
+ } else {
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(JAXXObject.class));
+ }
+ }
+
+ @Override
+ public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
+
+ String fullClassName = javaFile.getClassName();
+
+ String jaxxContextImplementorClass = compiler.getConfiguration().getJaxxContextClass().getName();
+ boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject();
+ if (!superclassIsJAXXObject) {
+ // add logger
+ if (compiler.getConfiguration().isAddLogger()) {
+ javaFile.addImport(Log.class);
+ javaFile.addImport(LogFactory.class);
+ javaFile.addField(JavaField.newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)"));
+ }
+
+ // JAXXObject
+ javaFile.addField(OBJECT_MAP_FIELD);
+ javaFile.addMethod(GET_OBJECT_BY_ID_METHOD);
+ javaFile.addField(BINDING_SOURCES_FIELD);
+ javaFile.addField(ACTIVE_BINDINGS_FIELD);
+
+ // JAXXContext
+ javaFile.addField(JavaField.newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", "new " + jaxxContextImplementorClass + "(this);"));
+ javaFile.addMethod(SET_CONTEXT_VALUE_METHOD);
+ javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD);
+ javaFile.addMethod(GET_CONTEXT_VALUE_METHOD);
+ javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD);
+ javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD);
+ javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD);
+ javaFile.addMethod(GET_PARENT_CONTAINER_METHOD);
+ javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD);
+
+ // PropertyChangeSupport
+ addPropertyChangeSupport(root, javaFile);
+
+ // DataBinding
+ javaFile.addMethod(PROCESS_DATA_BINDING_METHOD);
+ }
+
+ javaFile.addField(ALL_COMPONENTS_CREATED_FIELD);
+ boolean overrideContextInitialized = false;
+ FieldDescriptor[] scriptFields = compiler.getScriptFields();
+ for (FieldDescriptor f : scriptFields) {
+ if ("contextInitialized".equals(f.getName())) {
+ overrideContextInitialized = true;
+ break;
+ }
+ }
+ if (!overrideContextInitialized) {
+ javaFile.addField(CONTEXT_INITIALIZED);
+ }
+ javaFile.addField(createJAXXObjectDescriptorField(compiler, javaFile));
+
+ if (compiler.getStylesheet() != null) {
+ javaFile.addField(PREVIOUS_VALUES_FIELD);
+ }
+ /*for (CompiledObject object : compiler.getObjects().values()) {
+ List<CompiledObject.ChildRef> refList = object.getChilds();
+ if (refList==null || refList.isEmpty()) {
+ continue;
+ }
+ for (ChildRef childRef : refList) {
+ childRef.addToAdditionCode(buffer);
+ }
+ }*/
+ //TC 20090228 - only generate constructors if not done in scripts
+ boolean constructorDetected = false;
+ MethodDescriptor[] methods = compiler.getScriptMethods();
+ for (MethodDescriptor m : methods) {
+ try {
+ m.getReturnType();
+ if (className.equals(m.getName())) {
+ constructorDetected = true;
+ break;
+ }
+ } catch (Exception e) {
+ log.warn("could not find return type " + m);
+ }
+ }
+ if (!constructorDetected) {
+ javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject));
+ javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject));
+ }
+
+ javaFile.addMethod(createInitializer(compiler));
+ javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD);
+
+ javaFile.addBodyCode(compiler.getBodyCode().toString());
+
+ javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, compiler.getInitDataBindings()));
+
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "applyDataBinding",
+ compiler.getApplyDataBinding().toString() + JAXXCompiler.getLineSeparator() + "processDataBinding($binding);",
+ new JavaArgument("String", "$binding")));
+
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "removeDataBinding",
+ compiler.getRemoveDataBinding().toString(), new JavaArgument("String", "$binding")));
+
+ javaFile.addMethod(createProcessDataBindingMethod(compiler, superclassIsJAXXObject));
+
+ addEventHandlers(compiler, javaFile);
+
+ }
+
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- Create fields ----------------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+ protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) {
+ try {
+ JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor();
+ String data = Base64Coder.serialize(descriptor, true);
+ /*ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer));
+ out.writeObject(descriptor);
+ out.close();
+ // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String
+ // in the compiled class file, since byte array initialization is horribly inefficient compared to
+ // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1
+ // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely
+ // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String
+ // type, but if we could efficiently store a byte[] we wouldn't have to do this.
+ String data = new String(buffer.toByteArray(), 0);*/
+
+ int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit
+ if (data.length() < sizeLimit) {
+ return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", TypeManager.getJavaCode(data));
+ } else {
+ StringBuffer initializer = new StringBuffer();
+ for (int i = 0; i < data.length(); i += sizeLimit) {
+ String name = "$jaxxObjectDescriptor" + i;
+ javaFile.addField(new JavaField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", name,
+ TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length())))));
+ if (initializer.length() > 0) {
+ initializer.append(" + ");
+ }
+ initializer.append("String.valueOf(").append(name).append(")");
+ }
+ return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", initializer.toString());
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Internal error: can't-happen error", e);
+ }
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- Create methods ---------------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+ protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) {
+ ClassDescriptor currentClass = root.getObjectClass();
+ MethodDescriptor firePropertyChange = null;
+ while (firePropertyChange == null && currentClass != null) {
+ try {
+ firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class),
+ ClassDescriptorLoader.getClassDescriptor(Object.class),
+ ClassDescriptorLoader.getClassDescriptor(Object.class));
+
+ } catch (NoSuchMethodException e) {
+ currentClass = currentClass.getSuperclass();
+ }
+ }
+
+ int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0;
+ if (Modifier.isPublic(modifiers)) {
+ // we have all the support we need
+ }
+ if (Modifier.isProtected(modifiers)) {
+ // there is property change support but the firePropertyChange method is protected
+ javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD);
+ } else {
+ // either no support at all or firePropertyChange isn't accessible
+ javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD);
+ javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD);
+ javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD);
+ javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
+ javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD);
+ javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
+ javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD);
+ }
+ }
+
+ protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) {
+ for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) {
+ // outer loop is iterating over different objects (well, technically, different Java expressions)
+ for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) {
+ // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.)
+ for (EventHandler handler : e2.getValue()) {
+ // iterate over individual event handlers of a single type
+ String methodName = compiler.getEventHandlerMethodName(handler);
+ MethodDescriptor listenerMethod = handler.getListenerMethod();
+ if (listenerMethod.getParameterTypes().length != 1) {
+ throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument");
+ }
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", methodName, handler.getJavaCode(),
+ new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event")));
+ }
+ }
+ }
+ }
+
+ protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
+ StringBuffer code = new StringBuffer();
+ String constructorParams = compiler.getRootObject().getConstructorParams();
+ if (constructorParams != null) {
+ code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
+ } else {
+ if (superclassIsJAXXObject) {
+ code.append(" super();").append(JAXXCompiler.getLineSeparator());
+ }
+ }
+ code.append("$initialize();");
+ code.append(JAXXCompiler.getLineSeparator());
+ return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString());
+ }
+
+ protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
+ StringBuffer code = new StringBuffer();
+ String constructorParams = compiler.getRootObject().getConstructorParams();
+ if (constructorParams != null) {
+ code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
+ } else {
+ if (superclassIsJAXXObject) {
+ code.append(" super(parentContext);").append(JAXXCompiler.getLineSeparator());
+ }
+ }
+ if (!superclassIsJAXXObject) {
+ code.append(Util.class.getName() + ".initContext(this, parentContext);");
+ code.append(JAXXCompiler.getLineSeparator());
+
+// code.append("if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) {");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append(" ((jaxx.runtime.context.JAXXInitialContext)parentContext).to(this);");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append("} else {");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append(" setContextValue(parentContext);");
+// code.append(JAXXCompiler.getLineSeparator());
+// code.append("}");
+// code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append("$initialize();");
+ code.append(JAXXCompiler.getLineSeparator());
+ return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.context.JAXXContext", "parentContext"));
+ }
+
+ public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
+ StringBuffer code = new StringBuffer();
+ CompiledObject root = compiler.getRootObject();
+ code.append("if (allComponentsCreated || !contextInitialized) {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" return;");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);");
+ code.append(JAXXCompiler.getLineSeparator());
+
+ Iterator<CompiledObject> i = compiler.getObjectCreationOrder();
+ boolean lastWasMethodCall = false;
+ while (i.hasNext()) {
+ CompiledObject object = i.next();
+ if (object == root) {
+ continue;
+ }
+ CompiledObjectDecorator decorator = object.getDecorator();
+ lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall);
+ /*if (object != root && !object.isOverride()) {
+ if (compiler.inlineCreation(object)) {
+ if (lastWasMethodCall) {
+ lastWasMethodCall = false;
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append(getCreationCode(compiler, object));
+ code.append(JAXXCompiler.getLineSeparator());
+ } else {
+ code.append(object.getCreationMethodName()).append("();");
+ code.append(JAXXCompiler.getLineSeparator());
+ lastWasMethodCall = true;
+ }
+ }*/
+ }
+ root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall);
+ /*String rootCode = root.getInitializationCode(compiler);
+ if (rootCode != null && rootCode.length() > 0) {
+ code.append(rootCode);
+ code.append(JAXXCompiler.getLineSeparator());
+ }*/
+ code.append(JAXXCompiler.getLineSeparator());
+ if (compiler.getInitializer().length() > 0) {
+ code.append(compiler.getInitializer());
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append("$completeSetup();");
+ code.append(JAXXCompiler.getLineSeparator());
+ return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$initialize", code.toString());
+ }
+
+ protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, StringBuffer initDataBindings) {
+ StringBuffer code = new StringBuffer();
+ code.append("allComponentsCreated = true;");
+ code.append(JAXXCompiler.getLineSeparator());
+ for (CompiledObject object : compiler.getObjects().values()) {
+ CompiledObjectDecorator decorator = object.getDecorator();
+ code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile, initDataBindings));
+
+ /*//TC - 20081017 only generate the method if not empty ?
+ if (object.getId().startsWith("$")) {
+ code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
+ } else {
+ String additionCode = object.getAdditionCode();
+ if (additionCode.length() > 0) {
+ code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
+ additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
+ }
+ }*/
+ //code.append(getLineSeparator());
+ }
+
+ code.append(initDataBindings);
+
+ if (compiler.getLateInitializer().length() > 0) {
+ code.append(compiler.getLateInitializer());
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ //TC-20090313 add an extra method after complete setup
+ MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup");
+ if (method != null) {
+ code.append("$afterCompleteSetup();").append(JAXXCompiler.getLineSeparator());
+ }
+ return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString());
+ }
+
+ protected JavaMethod createProcessDataBindingMethod(JAXXCompiler compiler, boolean superclassIsJAXXObject) {
+ StringBuffer code = new StringBuffer();
+ //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass());
+ // the force parameter forces the update to happen even if it is already in activeBindings. This
+ // is used on superclass invocations b/c by the time the call gets to the superclass, it is already
+ // marked active and would otherwise be skipped
+ if (compiler.getProcessDataBinding().length() > 0) {
+ code.append(" if (!$force && $activeBindings.contains($dest)) { ");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" return;");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("$activeBindings.add($dest);");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("try {");
+ code.append(JAXXCompiler.getLineSeparator());
+ if (compiler.getProcessDataBinding().length() > 0) {
+ code.append(compiler.getProcessDataBinding().toString());
+ //code.append(JAXXCompiler.getLineSeparator());
+ }
+ if (superclassIsJAXXObject) {
+ code.append(" else {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" super.processDataBinding($dest, true);");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" }");
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ code.append("} finally {");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append(" $activeBindings.remove($dest);");
+ code.append(JAXXCompiler.getLineSeparator());
+ code.append("}");
+ code.append(JAXXCompiler.getLineSeparator());
+ } else if (superclassIsJAXXObject) {
+ code.append("super.processDataBinding($dest, true);");
+ code.append(JAXXCompiler.getLineSeparator());
+ }
+ return JavaMethod.newMethod(Modifier.PUBLIC, "void", "processDataBinding", code.toString(),
+ new JavaArgument("String", "$dest"), new JavaArgument("boolean", "$force"));
+ }
+
+ /*---------------------------------------------------------------------------------*/
+ /*-- Create methods code ----------------------------------------------------------*/
+ /*---------------------------------------------------------------------------------*/
+
+ /* protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
+ if (object instanceof ScriptInitializer) {
+ return object.getInitializationCode(compiler);
+ }
+ CompiledObjectDecorator decorator = object.getDecorator();
+ String result = decorator.getCreationCode(compiler, object);
+ return result;*/
+ /*StringBuffer result = new StringBuffer();
+ result.append(object.getId());
+ result.append(" = ");
+ if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
+ result.append(object.getJavaBeanInitCode()).append(";");
+ } else {
+ String constructorParams = object.getConstructorParams();
+ if (constructorParams != null) {
+ //TC - 20081017 compiledObject can have generics
+ result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
+ //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
+ } else {
+ //TC - 20081017 compiledObject can have generics
+ result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
+ }
+ }
+ result.append(JAXXCompiler.getLineSeparator());
+ String initCode = object.getInitializationCode(compiler);
+ if (initCode != null && initCode.length() > 0) {
+ result.append(initCode);
+ }
+ result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
+
+ return result.toString();*/
+// }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/JAXXObjectGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,27 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.*;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Application;
+
+import java.lang.reflect.Modifier;
+
+/** @author chemit */
+public class SwingGenerator implements Generator {
+
+ @Override
+ public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
+ }
+
+ @Override
+ public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
+
+ //TODO : move this to jaxx-compiler-swing generator
+ if (ClassDescriptorLoader.getClassDescriptor(Application.class.getName()).isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) {
+ // TODO: check for existing main method first
+ javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC | Modifier.STATIC, "void", "main",
+ "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });",
+ new JavaArgument("String[]", "arg")));
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/SwingGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java 2009-10-07 14:23:35 UTC (rev 1563)
@@ -0,0 +1,88 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.*;
+import jaxx.compiler.CompiledObject.ChildRef;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.validator.BeanValidatorHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import jaxx.compiler.types.TypeManager;
+
+import java.util.List;
+import jaxx.runtime.SwingUtil;
+
+/** @author chemit */
+public class ValidatorGenerator implements Generator {
+
+ protected static final JavaField VALIDATOR_IDS_FIELD = JavaField.newField(java.lang.reflect.Modifier.PROTECTED,
+ "java.util.List<String>", "validatorIds", "new ArrayList<String>()");
+
+ @Override
+ public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
+
+ if (!BeanValidatorHandler.hasValidator(compiler)) {
+ return;
+ }
+
+ for (CompiledObject object : compiler.getObjects().values()) {
+ List<ChildRef> childs = object.getChilds();
+ if (childs == null || childs.isEmpty()) {
+ continue;
+ }
+ for (ChildRef child : childs) {
+ String javaCode = child.getChildJavaCode();
+ // some validators are defined on this object
+ boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId());
+ if (found) {
+ // box the child component in a JxLayer
+ child.setChildJavaCode(SwingUtil.class.getName() + ".boxComponentWithJxLayer(" + javaCode + ")");
+ }
+ }
+ }
+ // register validator
+ for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) {
+ String id = TypeManager.getJavaCode(validator.getId());
+ compiler.appendLateInitializer("validatorIds.add(" + id + ");");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ compiler.appendLateInitializer("getValidator(" + id + ").installUIs();");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();");
+ //compiler.appendLateInitializer("getValidator(" + id + ").validate();");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ }
+ compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
+ compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
+ }
+
+ @Override
+ public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
+ if (!BeanValidatorHandler.hasValidator(compiler)) {
+ return;
+ }
+ Class<?> validatorClass = compiler.getConfiguration().getValidatorClass();
+ String validatorFQN = validatorClass.getName();
+ javaFile.addImport(validatorFQN);
+
+ //TODO use the specific JAXXValidator interface (swing, gwt,...)
+ Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class;
+
+ if (javaFile.isSuperclassIsJAXXObject()) {
+ ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass());
+ boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass);
+
+ if (parentIsValidator) {
+ // nothing to generate (use the parent directly)
+ return;
+ }
+ }
+
+ // add JAXXValidator interface
+ javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface));
+
+ // implements JAXXValidator
+ javaFile.addField(VALIDATOR_IDS_FIELD);
+ javaFile.addMethod(JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, validatorFQN + "<?>", "getValidator",
+ "return (" + validatorFQN + ") (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);",
+ new JavaArgument("String", "validatorId")));
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/ValidatorGenerator.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
1
0
Author: tchemit
Date: 2009-10-07 16:22:07 +0200 (Wed, 07 Oct 2009)
New Revision: 1562
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/
Removed:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/spi/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator
branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/
branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/runtime/
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java
branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml
branches/jaxx-2.X/src/site/rst/JAXXContext.rst
Log:
refactor jaxx 2.x
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,96 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps
- * in that it takes subclasses into account; mapping a class to a value also maps all subclasses of
- * that class to the value.
- * <p/>
- * A <code>get</code> operation will return the value associated with the class itself, or failing
- * that, with its nearest ancestor for which there exists a mapping.
- * @param <T> type of the class
- */
-public class ClassMap<T> extends HashMap<ClassDescriptor, T> {
- /** log */
- protected static final Log log = LogFactory.getLog(ClassMap.class);
-
- /**
- * Keeps track of automatically-added Classes so we can distinguish them from user-added
- * Classes. Unknown Classes are automatically added to the map during <code>get</code>
- * calls to speed up subsequent requests, but they must be updated when the mappings
- * for their superclasses are modified.
- */
- private List<ClassDescriptor> autoKeys = new ArrayList<ClassDescriptor>();
- private static final long serialVersionUID = 5149779660675529037L;
-
-
- /**
- * Returns the value associated with the key <code>Class</code>. If the class itself does not have
- * a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is
- * located. If none of the class' ancestors have a mapping, <code>null</code> is returned.
- *
- * @param key the class to check
- * @return the mapping for the class
- */
- @Override
- public T get(Object key) {
- T result = null;
- ClassDescriptor c = (ClassDescriptor) key;
- while (c != null) {
- result = super.get(c);
- if (result != null) {
- break;
- }
- c = c.getSuperclass();
- }
-
- if (result == null && ((ClassDescriptor) key).isInterface()) {
- result = get(ClassDescriptorLoader.getClassDescriptor(Object.class));
- }
-
- if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass
- put((ClassDescriptor) key, result);
- autoKeys.add((ClassDescriptor) key);
- }
- return result;
- }
-
-
- /**
- * Associates a value with a class and all of its descendents.
- *
- * @param key the class to map
- * @param value the value to map to the class
- * @return the old value associated with the class
- */
- @Override
- public T put(ClassDescriptor key, T value) {
- //if (!(key instanceof ClassDescriptor)) {
- // throw new IllegalArgumentException("expected ClassDescriptor, got " + key);
- //}
- if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified
- Iterator<ClassDescriptor> i = autoKeys.iterator();
- while (i.hasNext()) {
- ClassDescriptor auto = i.next();
- if (key.isAssignableFrom(auto)) {
- i.remove();
- remove(auto);
- }
- }
- }
- return super.put(key, value);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/** Thrown by the compiler when an error occurs. */
-public class CompilerException extends RuntimeException {
- private static final long serialVersionUID = -9099889519671482440L;
-
- /** Creates a new <code>ParseException</code>. */
- public CompilerException() {
- }
-
-
- /**
- * Creates a new <code>ParseException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public CompilerException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>ParseException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public CompilerException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>ParseException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public CompilerException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-
-
- public void printStackTrace() {
- super.printStackTrace();
- System.err.println("CompilerException printed from:");
- Thread.dumpStack();
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,52 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultComponentHandler;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.ScriptHandler;
-import jaxx.tags.StyleHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.PrimitiveConverter;
-import jaxx.types.TypeManager;
-
-import java.awt.Component;
-import jaxx.compiler.CompiledObjectDecorator;
-import jaxx.compiler.DefaultCompiledObjectDecorator;
-
-/** Initializes support for java. */
-public class DefaultInitializer implements jaxx.spi.Initializer {
-
- @Override
- public void initialize() {
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Object.class), DefaultObjectHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Component.class), DefaultComponentHandler.class);
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler());
-
- PrimitiveConverter primitiveConverter = new PrimitiveConverter();
- TypeManager.registerTypeConverter(boolean.class, primitiveConverter);
- TypeManager.registerTypeConverter(Boolean.class, primitiveConverter);
- TypeManager.registerTypeConverter(byte.class, primitiveConverter);
- TypeManager.registerTypeConverter(Byte.class, primitiveConverter);
- TypeManager.registerTypeConverter(short.class, primitiveConverter);
- TypeManager.registerTypeConverter(Short.class, primitiveConverter);
- TypeManager.registerTypeConverter(int.class, primitiveConverter);
- TypeManager.registerTypeConverter(Integer.class, primitiveConverter);
- TypeManager.registerTypeConverter(long.class, primitiveConverter);
- TypeManager.registerTypeConverter(Long.class, primitiveConverter);
- TypeManager.registerTypeConverter(float.class, primitiveConverter);
- TypeManager.registerTypeConverter(Float.class, primitiveConverter);
- TypeManager.registerTypeConverter(double.class, primitiveConverter);
- TypeManager.registerTypeConverter(Double.class, primitiveConverter);
- TypeManager.registerTypeConverter(char.class, primitiveConverter);
- TypeManager.registerTypeConverter(Character.class, primitiveConverter);
- TypeManager.registerTypeConverter(String.class, primitiveConverter);
-
- CompiledObjectDecorator.registerDecorator("default", DefaultCompiledObjectDecorator.class);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,118 +0,0 @@
-package jaxx;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.introspection.JAXXPropertyDescriptor;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-
-import java.io.BufferedWriter;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.io.OutputStreamWriter;
-
-/** Generates information about a tag for use on the jaxxframework.org web site. */
-public class PrintTagInfo {
- /**
- * Displays information about the class name in arg[0].
- *
- * @param arg command-line arguments
- * @throws Exception if an error occurs
- */
- public static void main(String[] arg) throws Exception {
- if (arg.length < 1) {
- throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate");
- }
- String firstarg = arg[0];
- boolean toFile = false;
- BufferedWriter w;
- if (firstarg.startsWith("file:")) {
- w = new BufferedWriter(new FileWriter(firstarg.substring(5)));
- toFile = true;
- } else {
- w = new BufferedWriter(new OutputStreamWriter(System.out));
- }
-
- try {
- JAXXCompilerLaunchor.loadLibraries(false);
- for (int i = toFile ? 1 : 0; i < arg.length; i++) {
- String className = arg[i];
- treateClass(w, className);
- }
- } finally {
- w.flush();
- w.close();
- }
-
- }
-
- protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException {
-
- ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className);
- DefaultObjectHandler handler = TagManager.getTagHandler(beanClass);
-
- DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass());
-
- // dump all bean properties
- w.append("Properties in ").append(String.valueOf(beanClass));
- w.newLine();
- JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
- JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
- for (JAXXPropertyDescriptor property : properties) {
- if (property.getWriteMethodDescriptor() == null) {
- continue;
- }
-
- boolean found = false;
- String name = property.getName();
- for (JAXXPropertyDescriptor superProperty : superProperties) {
- if (superProperty.getName().equals(name)) {
- found = true;
- break;
- }
- }
- if (!found) {
- if (property.getPropertyType() == null) {
- System.err.println(name + " has null type");
- } else {
- w.append("{{EquivalentAttribute|");
- w.append(name);
- w.append("|");
- w.append(className.replace('.', '/'));
- w.append("|set");
- w.append(org.apache.commons.lang.StringUtils.capitalize(name));
- w.append("|");
- w.append(JAXXCompiler.getCanonicalName(property.getPropertyType()));
- w.append("}}");
- w.append("|-");
- w.newLine();
- }
- }
- }
-
- w.newLine();
- w.newLine();
-
- // dump all bound methods
- dumpMethods(w, beanClass, handler);
- }
-
- protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException {
- MethodDescriptor[] methods = beanClass.getMethodDescriptors();
- w.append("Bound methods in ").append(String.valueOf(beanClass));
- w.newLine();
- for (MethodDescriptor method : methods) {
- try {
- if (handler.isMemberBound(method.getName())) {
- w.append("* <tt>").append(method.getName()).append("()</tt>");
- w.newLine();
- }
- } catch (Throwable e) {
- // ignore ?
- }
- }
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ScriptException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/** Thrown by the runtime engine when a script error occurs. */
-public class ScriptException extends RuntimeException {
- private static final long serialVersionUID = 5687529939397610336L;
-
- /** Creates a new <code>ScriptException</code>. */
- public ScriptException() {
- }
-
-
- /**
- * Creates a new <code>ScriptException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public ScriptException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>ScriptException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public ScriptException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>ScriptException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public ScriptException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,107 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-import jaxx.beaninfos.BeanInfoUtil;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.BoxedCompiledObjectDecorator;
-import jaxx.compiler.CompiledObjectDecorator;
-import jaxx.compiler.HelpRootCompiledObjectDecorator;
-
-import jaxx.reflect.ClassDescriptorLoader;
-
-import jaxx.runtime.swing.editor.EnumEditor;
-import jaxx.runtime.swing.editor.LocaleEditor;
-
-import jaxx.spi.Initializer;
-
-import jaxx.runtime.swing.*;
-import jaxx.tags.*;
-import jaxx.tags.swing.*;
-import jaxx.types.*;
-
-import java.awt.*;
-import javax.swing.text.JTextComponent;
-import javax.swing.*;
-
-public class SwingInitializer implements Initializer {
-
- @Override
- public void initialize() {
-
- BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos");
-
- //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing
- TagManager.registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
-// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
-
- // check boxes
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
-
- // combo boxes
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class);
-
- // radio boxes
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
-
- // Lists
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JList.class), JListHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JAXXListHandler.class);
-
- // Trees
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTree.class), JTreeHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JAXXTreeHandler.class);
-
- // Windows
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class);
-
- TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*");
- TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JPasswordField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextArea", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextField", "javax.swing.*");
- TagManager.registerDefaultNamespace("JTextPane", "javax.swing.*");
-
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler());
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Table.class), TableHandler.class);
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler());
- TagManager.registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
-
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTab.class), JAXXTabHandler.class);
-
- TypeManager.registerTypeConverter(Color.class, new ColorConverter());
- TypeManager.registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter());
- TypeManager.registerTypeConverter(Insets.class, new InsetsConverter());
- TypeManager.registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
-
- CompiledObjectDecorator.registerDecorator("boxed", BoxedCompiledObjectDecorator.class);
- CompiledObjectDecorator.registerDecorator("help", HelpRootCompiledObjectDecorator.class);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/**
- * Thrown by <code>TagHandler</code> when an unsupported attribute is encountered.
- *
- * @see jaxx.tags.TagHandler
- */
-public class UnsupportedAttributeException extends CompilerException {
- private static final long serialVersionUID = -6919583037172920343L;
-
- /** Creates a new <code>UnsupportedAttributeException</code>. */
- public UnsupportedAttributeException() {
- }
-
-
- /**
- * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public UnsupportedAttributeException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>UnsupportedAttributeException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public UnsupportedAttributeException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public UnsupportedAttributeException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,45 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx;
-
-/** Thrown by the compiler when an unregistered tag is encountered. */
-public class UnsupportedTagException extends CompilerException {
- private static final long serialVersionUID = 3199732135804426699L;
-
- /** Creates a new <code>UnsupportedTagException</code>. */
- public UnsupportedTagException() {
- }
-
-
- /**
- * Creates a new <code>UnsupportedTagException</code> with the specified detail message.
- *
- * @param msg the exception's detail message
- */
- public UnsupportedTagException(String msg) {
- super(msg);
- }
-
-
- /**
- * Creates a new <code>UnsupportedTagException</code> with the specified cause.
- *
- * @param initCause the exception's initCause
- */
- public UnsupportedTagException(Throwable initCause) {
- super(initCause);
- }
-
-
- /**
- * Creates a new <code>UnsupportedTagException</code> with the specified detail message and cause.
- *
- * @param msg the exception's detail message
- * @param initCause the exception's initCause
- */
- public UnsupportedTagException(String msg, Throwable initCause) {
- super(msg, initCause);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/BoxedCompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,27 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.compiler.CompiledObject.ChildRef;
-import jaxx.runtime.SwingUtil;
-
-/**
- * A decorator to surround a compiled object (should be a component at least)
- * with a JXLayer.
- *
- * @author tony
- * @since 1.2
- */
-public class BoxedCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
-
- @Override
- public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
- CompiledObject parent = object.getParent();
- for (ChildRef child : parent.getChilds()) {
- if (child.getChild() == object) {
- String javaCode = child.getChildJavaCode();
- child.setChildJavaCode(SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")");
- break;
- }
- }
- super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
- }
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/ClassMap.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * A Map implementation which uses Classes as keys. <code>ClassMap</code> differs from typical maps
+ * in that it takes subclasses into account; mapping a class to a value also maps all subclasses of
+ * that class to the value.
+ * <p/>
+ * A <code>get</code> operation will return the value associated with the class itself, or failing
+ * that, with its nearest ancestor for which there exists a mapping.
+ * @param <T> type of the class
+ */
+public class ClassMap<T> extends HashMap<ClassDescriptor, T> {
+
+ private static final long serialVersionUID = 5149779660675529037L;
+ /**
+ * Logger
+ */
+ protected static final Log log = LogFactory.getLog(ClassMap.class);
+ /**
+ * Keeps track of automatically-added Classes so we can distinguish them from user-added
+ * Classes. Unknown Classes are automatically added to the map during <code>get</code>
+ * calls to speed up subsequent requests, but they must be updated when the mappings
+ * for their superclasses are modified.
+ */
+ private List<ClassDescriptor> autoKeys = new ArrayList<ClassDescriptor>();
+
+ /**
+ * Returns the value associated with the key <code>Class</code>. If the class itself does not have
+ * a mapping, its superclass will be checked, and so on until an ancestor class with a mapping is
+ * located. If none of the class' ancestors have a mapping, <code>null</code> is returned.
+ *
+ * @param key the class to check
+ * @return the mapping for the class
+ */
+ @Override
+ public T get(Object key) {
+ T result = null;
+ ClassDescriptor c = (ClassDescriptor) key;
+ while (c != null) {
+ result = super.get(c);
+ if (result != null) {
+ break;
+ }
+ c = c.getSuperclass();
+ }
+
+ if (result == null && ((ClassDescriptor) key).isInterface()) {
+ result = get(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ }
+
+ if (c != key && result != null) { // no mapping for the class itself, but found one for a superclass
+ put((ClassDescriptor) key, result);
+ autoKeys.add((ClassDescriptor) key);
+ }
+ return result;
+ }
+
+ /**
+ * Associates a value with a class and all of its descendents.
+ *
+ * @param key the class to map
+ * @param value the value to map to the class
+ * @return the old value associated with the class
+ */
+ @Override
+ public T put(ClassDescriptor key, T value) {
+ //if (!(key instanceof ClassDescriptor)) {
+ // throw new IllegalArgumentException("expected ClassDescriptor, got " + key);
+ //}
+ if (autoKeys.size() > 0) { // remove all automatic keys which descend from the class being modified
+ Iterator<ClassDescriptor> i = autoKeys.iterator();
+ while (i.hasNext()) {
+ ClassDescriptor auto = i.next();
+ if (key.isAssignableFrom(auto)) {
+ i.remove();
+ remove(auto);
+ }
+ }
+ }
+ return super.put(key, value);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ClassMap.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObject.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,14 +4,14 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.DefaultComponentHandler;
-import jaxx.tags.TagHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.TypeManager;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.types.TypeManager;
import java.awt.Container;
import java.lang.reflect.Method;
@@ -69,13 +69,13 @@
/** the type of the override object (can be null if no oveeride) */
private ClassDescriptor overrideType;
/**
- * the decorator (if null will use {@link DefaultCompiledObjectDecorator}).
+ * the decorator
*/
private CompiledObjectDecorator decorator;
/**
* client properties
*/
- private Map<String,String> clientProperties;
+ private Map<String, String> clientProperties;
public class ChildRef {
@@ -459,14 +459,13 @@
return clientProperties;
}
-
/**
* Returns all properties which have been set for this object.
*
* @return a <code>Map</code> containing all properties defined for this object
* @see #addProperty
*/
- public Map/*<String, String>*/ getProperties() {
+ public Map<?, ?>/*<String, String>*/ getProperties() {
return properties;
}
@@ -558,6 +557,7 @@
public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException {
compiler.registerDataBinding(src, getId() + "." + property, assignment);
}
+
public String getGenericTypes() {
if (getGenericTypesLength() == 0) {
// not using it
@@ -635,4 +635,4 @@
public int getGenericTypesLength() {
return genericTypes == null ? 0 : genericTypes.length;
}
-}
\ No newline at end of file
+}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,76 +0,0 @@
-package jaxx.compiler;
-
-import java.util.Map;
-import java.util.TreeMap;
-import jaxx.CompilerException;
-
-/**
- *
- * A class to decorate a compiled object at generation time.
- *
- * Contains also a cache of decorator in a dictonnary indexed by fqn of decorator.
- *
- * Use the {@link #getDecorator(java.lang.String)} to obtain the cached decorator.
- *
- * Note : The implementation of this class must be stateless.
- *
- * @author tony
- * @since 1.2
- */
-public abstract class CompiledObjectDecorator {
-
- protected static Map<String, CompiledObjectDecorator> cache;
-
- public static void registerDecorator(String key, Class<? extends CompiledObjectDecorator> klass) {
- synchronized (getCache()) {
- if (getCache().containsKey(key)) {
- throw new IllegalArgumentException("the decorator with key [" + key + "] is already registred! use another key name");
- }
- try {
- getCache().put(key, klass.newInstance());
- } catch (InstantiationException ex) {
- throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException("could not create decorator " + klass + " for reason " + ex.getMessage(), ex);
- }
- }
- }
-
- public static CompiledObjectDecorator getDecorator(String name) {
- CompiledObjectDecorator decorator = getCache().get(name);
- if (decorator == null) {
- throw new IllegalArgumentException("could not find decorator with key " + name + " (known decorators : " + getCache().keySet());
- }
- return decorator;
- }
-
- public static CompiledObjectDecorator getDecorator(Class<?> type) {
- for (CompiledObjectDecorator decorator : getCache().values()) {
- if (type == decorator.getClass()) {
- return decorator;
- }
- }
- return null;
- }
-
- protected static synchronized Map<String, CompiledObjectDecorator> getCache() {
- if (cache == null) {
- cache = new TreeMap<String, CompiledObjectDecorator>();
- }
- return cache;
- }
-
- public static void reset() {
- if (cache != null) {
- cache.clear();
- }
- }
-
- public abstract void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName);
-
- public abstract String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException;
-
- public abstract boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall);
-
- public abstract String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings);
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/CompilerException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+/** Thrown by the compiler when an error occurs. */
+public class CompilerException extends RuntimeException {
+
+ private static final long serialVersionUID = -9099889519671482440L;
+
+ /** Creates a new <code>ParseException</code>. */
+ public CompilerException() {
+ }
+
+ /**
+ * Creates a new <code>ParseException</code> with the specified detail message.
+ *
+ * @param msg the exception's detail message
+ */
+ public CompilerException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a new <code>ParseException</code> with the specified cause.
+ *
+ * @param initCause the exception's initCause
+ */
+ public CompilerException(Throwable initCause) {
+ super(initCause);
+ }
+
+ /**
+ * Creates a new <code>ParseException</code> with the specified detail message and cause.
+ *
+ * @param msg the exception's detail message
+ * @param initCause the exception's initCause
+ */
+ public CompilerException(String msg, Throwable initCause) {
+ super(msg, initCause);
+ }
+
+ @Override
+ public void printStackTrace() {
+ super.printStackTrace();
+ System.err.println("CompilerException printed from:");
+ Thread.dumpStack();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,406 +0,0 @@
-package jaxx.compiler;
-
-import org.apache.commons.lang.builder.ToStringBuilder;
-
-import java.io.File;
-
-/**
- * Stores options which affect the jaxxc tool's operation. These options are generally specified by the
- * user on the command line.
- */
-public class CompilerOptions {
- private File targetDirectory;
- private File javacTargetDirectory;
- private String classPath;
- private String javacOpts;
- private boolean keepJavaFiles;
- private boolean optimize;
- private boolean verbose;
- private boolean profile;
- /** a flag to enable or disable i18n generation */
- private boolean i18nable;
-
- /** a flag to add or not logger on generated jaxx files */
- private boolean addLogger;
-
- /** a flag to not reset compiler after a compile */
- private boolean resetAfterCompile;
-
- /** the name of implementation of {@link jaxx.runtime.JAXXContext} to be used on {@link jaxx.runtime.JAXXObject}. */
- protected String jaxxContextImplementorClass;
-
- /** list of fqn of class toimport for all generated jaxx files */
- protected String[] extraImports;
-
- /** default error ui */
- private Class<?> defaultErrorUI;
-
- private ClassLoader classLoader;
-
- private Class<? extends JAXXCompiler> compilerClass;
-
- /**
- * @deprecated prefer use {@link #validatorClass}
- */
- @Deprecated
- private String validatorFQN;
- /**
- * the validator class to use.
- *
- * @since 1.6.0
- */
- private Class<?> validatorClass;
-
- /** a flag to use {@link javax.swing.UIManager} to retreave icons. */
- private boolean useUIManagerForIcon;
-
- /** a flag to generate javax help for any */
- private boolean generateHelp;
-
- private String helpBrokerFQN;
- /**
- * The prefix to add to i18n key for any help i18n key.
- *
- * @since 1.3
- */
- protected String helpsetI18nPrefix;
- /**
- * The suffix to add to i18n key for an help Id.
- *
- * @since 1.3
- */
- protected String helpsetTitleI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetTocI18nSuffix;
- /**
- * The suffix to add to i18n key for an toc Id.
- *
- * @since 1.3
- */
- protected String helpsetIndexI18nSuffix;
- /**
- * The helpset name
- *
- * @since 1.3
- */
- protected String helpSetName;
- /** the default compiled object decorator to use if none specifed via decorator attribute */
- private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
-
- /**
- * Returns the target directory, generally specified with the "-d" option on the command line.
- *
- * @return the target directory
- * @see #setTargetDirectory
- */
- public File getJavacTargetDirectory() {
- if (javacTargetDirectory == null) {
- // to use the old way : if javacTargetDirectory not specified,
- // use same directory as targetDirectory (says where the java sources
- // are generated)
- return targetDirectory;
- }
- return javacTargetDirectory;
- }
-
- /**
- * Returns the target directory, generally specified with the "-d" option on the command line.
- *
- * @return the target directory
- * @see #setTargetDirectory
- */
- public File getTargetDirectory() {
- return targetDirectory;
- }
-
-
- /**
- * Sets the target directory into which compiled classes will be placed.
- *
- * @param targetDirectory the target directory
- * @see #getTargetDirectory
- */
- public void setTargetDirectory(File targetDirectory) {
- this.targetDirectory = targetDirectory;
- }
-
- public void setJavacTargetDirectory(File javacTargetDirectory) {
- this.javacTargetDirectory = javacTargetDirectory;
- }
-
- /**
- * Returns the class path to be used during compilation.
- *
- * @return the class path to be used during compilation
- * @see #setClassPath
- */
- public String getClassPath() {
- return classPath;
- }
-
- /**
- * Sets the class path to be used during compilation.
- *
- * @param classPath the compilation class path
- * @see #getClassPath
- */
- public void setClassPath(String classPath) {
- this.classPath = classPath;
- }
-
-
- /**
- * Returns the options to be passed into <code>javac</code>.
- *
- * @return options to be passed into <code>javac</code>
- * @see #setJavacOpts
- */
- public String getJavacOpts() {
- return javacOpts;
- }
-
-
- /**
- * Sets options to be passed into <code>javac</code>.
- *
- * @param javacOpts options to be passed into <code>javac</code>
- * @see #getJavacOpts
- */
- public void setJavacOpts(String javacOpts) {
- this.javacOpts = javacOpts;
- }
-
-
- /**
- * Returns whether or not generated Java files should be preserved after compilation.
- *
- * @return <code>true</code> if generated Java files should be preserved, <code>false</code> to delete
- * @see #setKeepJavaFiles
- */
- public boolean getKeepJavaFiles() {
- return keepJavaFiles;
- }
-
-
- /**
- * Sets whether or not generated Java files should be preserved after compilation.
- *
- * @param keepJavaFiles <code>true</code> if generated Java files should be preserved, <code>false</code> to delete
- * @see #getKeepJavaFiles
- */
- public void setKeepJavaFiles(boolean keepJavaFiles) {
- this.keepJavaFiles = keepJavaFiles;
- }
-
-
- /**
- * Returns whether or not optimization should be performed.
- *
- * @return whether or not optimizations should be performed
- */
- public boolean getOptimize() {
- return optimize;
- }
-
-
- /**
- * Sets whether or not optimizations should be performed.
- *
- * @param optimize <code>true</code> to perform optimizations during compilation
- * @see #getOptimize
- */
- public void setOptimize(boolean optimize) {
- this.optimize = optimize;
- }
-
- public boolean isVerbose() {
- return verbose;
- }
-
- public void setVerbose(boolean verbose) {
- this.verbose = verbose;
- }
-
- public boolean isI18nable() {
- return i18nable;
- }
-
- public boolean isUseUIManagerForIcon() {
- return useUIManagerForIcon;
- }
-
- public void setI18nable(boolean i18nable) {
- this.i18nable = i18nable;
- }
-
- public boolean isAddLogger() {
- return addLogger;
- }
-
- public void setAddLogger(boolean addLogger) {
- this.addLogger = addLogger;
- }
-
- public String getJaxxContextImplementorClass() {
- return jaxxContextImplementorClass;
- }
-
- public void setJaxxContextImplementorClass(String jaxxContextImplementorClass) {
- this.jaxxContextImplementorClass = jaxxContextImplementorClass;
- }
-
- public String[] getExtraImports() {
- return extraImports;
- }
-
- public void setExtraImports(String[] extraImports) {
- this.extraImports = extraImports;
- }
-
- public boolean isResetAfterCompile() {
- return resetAfterCompile;
- }
-
- public void setResetAfterCompile(boolean resetAfterCompile) {
- this.resetAfterCompile = resetAfterCompile;
- }
-
- public void setUseUIManagerForIcon(boolean useUIManagerForIcon) {
- this.useUIManagerForIcon = useUIManagerForIcon;
- }
-
- @Override
- public String toString() {
- return ToStringBuilder.reflectionToString(this);
- }
-
-
- public void setDefaultErrorUI(Class<?> defaultErrorUI) {
- this.defaultErrorUI = defaultErrorUI;
- }
-
- public boolean isKeepJavaFiles() {
- return keepJavaFiles;
- }
-
- public boolean isOptimize() {
- return optimize;
- }
-
- public Class<?> getDefaultErrorUI() {
- return defaultErrorUI;
- }
-
- public ClassLoader getClassLoader() {
- return classLoader;
- }
-
- public void setClassLoader(ClassLoader classLoader) {
- this.classLoader = classLoader;
- }
-
- public Class<? extends JAXXCompiler> getCompilerClass() {
- return compilerClass;
- }
-
- public void setCompilerClass(Class<? extends JAXXCompiler> compilerClass) {
- this.compilerClass = compilerClass;
- }
-
- @Deprecated
- public String getValidatorFQN() {
- return validatorClass.getName();
- }
-
- @Deprecated
- public void setValidatorFQN(String validatorFQN) {
- this.validatorFQN = validatorFQN;
- }
-
- public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
- return defaultDecoratorClass;
- }
-
- public void setDefaultDecoratorClass(Class<? extends CompiledObjectDecorator> defaultDecoratorClass) {
- this.defaultDecoratorClass = defaultDecoratorClass;
- }
-
- public boolean isProfile() {
- return profile;
- }
-
- public void setProfile(boolean profile) {
- this.profile = profile;
- }
-
- public boolean isGenerateHelp() {
- return generateHelp;
- }
-
- public void setGenerateHelp(boolean generateHelp) {
- this.generateHelp = generateHelp;
- }
-
- public String getHelpBrokerFQN() {
- return helpBrokerFQN;
- }
-
- public void setHelpBrokerFQN(String helpBrokerFQN) {
- this.helpBrokerFQN = helpBrokerFQN;
- }
-
- public String getHelpsetIndexI18nSuffix() {
- return helpsetIndexI18nSuffix;
- }
-
- public void setHelpsetIndexI18nSuffix(String helpsetIndexI18nSuffix) {
- this.helpsetIndexI18nSuffix = helpsetIndexI18nSuffix;
- }
-
- public String getHelpsetTitleI18nSuffix() {
- return helpsetTitleI18nSuffix;
- }
-
- public void setHelpsetTitleI18nSuffix(String helpsetTitleI18nSuffix) {
- this.helpsetTitleI18nSuffix = helpsetTitleI18nSuffix;
- }
-
- public String getHelpsetTocI18nSuffix() {
- return helpsetTocI18nSuffix;
- }
-
- public void setHelpsetTocI18nSuffix(String helpsetTocI18nSuffix) {
- this.helpsetTocI18nSuffix = helpsetTocI18nSuffix;
- }
-
- public String getHelpSetName() {
- return helpSetName;
- }
-
- public void setHelpSetName(String helpSetName) {
- this.helpSetName = helpSetName;
- }
-
- public String getHelpsetI18nPrefix() {
- return helpsetI18nPrefix;
- }
-
- public void setHelpsetI18nPrefix(String helpsetI18nPrefix) {
- this.helpsetI18nPrefix = helpsetI18nPrefix;
- }
-
- public Class<?> getValidatorClass() {
- return validatorClass;
- }
-
- public void setValidatorClass(Class<?> validatorClass) {
- this.validatorClass = validatorClass;
- }
-
-
-
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataBinding.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,32 +4,27 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.types.TypeManager;
+import jaxx.compiler.types.TypeManager;
/**
* Represents a data binding in a JAXX file. <code>DataBinding</code> uses {@link DataSource} to
* track changes to a source expression and update the destination.
*/
public class DataBinding {
- private String id;
+ private String id;
/** The DatSource which tracks source expression changes. */
private DataSource dataSource;
-
/** The data binding destination in the form <code><id>.<propertyName></code>. */
private String dest;
-
/**
* A Java snippet which will cause the destination property to be updated with the current value of
* the binding.
*/
private String assignment;
-
/** The current <code>JAXXCompiler</code>. */
private JAXXCompiler compiler;
-
/**
* Creates a new data binding.
*
@@ -46,12 +41,10 @@
this.compiler = compiler;
}
-
public String getId() {
return id;
}
-
/**
* Compiles the data binding expression. This method calls methods in <code>JAXXCompiler</code>
* to add the Java code that performs the data binding setup.
@@ -89,4 +82,4 @@
compiler.appendProcessDataBinding(JAXXCompiler.getLineSeparator() + " }");
return true;
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DataSource.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,19 +4,17 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.UnsupportedAttributeException;
-import jaxx.parser.JavaParser;
-import jaxx.parser.JavaParserConstants;
-import jaxx.parser.JavaParserTreeConstants;
-import jaxx.parser.SimpleNode;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagManager;
-import jaxx.types.TypeManager;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserConstants;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.types.TypeManager;
import java.beans.Introspector;
import java.beans.PropertyChangeListener;
@@ -34,24 +32,19 @@
* changed but no event was fired).
*/
public class DataSource {
+
private class NULL {
} // type attached to "null" constants in parsed expressions
-
private String id;
-
/** The Java source code for the expression. */
private String source;
-
/** The current <code>JAXXCompiler</code>. */
private JAXXCompiler compiler;
-
/** List of symbols which this data source expression depends on. */
private List<String> dependencySymbols = new ArrayList<String>();
-
private StringBuffer addListenerCode = new StringBuffer();
private StringBuffer removeListenerCode = new StringBuffer();
private boolean compiled;
-
/** the delegate of property to be required */
private String objectCode;
@@ -69,7 +62,6 @@
this.compiler = compiler;
}
-
public String getId() {
return id;
}
@@ -97,17 +89,17 @@
if (compiled) {
throw new IllegalStateException(this + " has already been compiled");
}
- String id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(getClass()));
+ String autoId = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(getClass()));
JavaParser p = new JavaParser(new StringReader(source + ";"));
while (!p.Line()) {
SimpleNode node = p.popNode();
- scanNode(node, id);
+ scanNode(node, autoId);
}
if (dependencySymbols.size() > 0) {
//TC 20081108 prefer add a real JavaField instead of raw code
//compiler.appendBodyCode("private PropertyChangeListener " + id + " = " + propertyChangeListenerCode + ";\n");
- compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getName(), id, propertyChangeListenerCode));
+ compiler.addSimpleField(new JavaField(Modifier.PRIVATE, PropertyChangeListener.class.getName(), autoId, propertyChangeListenerCode));
}
compileListeners();
@@ -126,7 +118,7 @@
*
* @param node node to scan
* @param listenerId id of listener
- * @throws jaxx.CompilerException ?
+ * @throws CompilerException ?
*/
private void scanNode(SimpleNode node, String listenerId) throws CompilerException {
switch (node.getId()) {
@@ -147,17 +139,17 @@
private ClassDescriptor determineLiteralType(SimpleNode node) {
assert node.getId() == JavaParserTreeConstants.JJTLITERAL;
if (node.jjtGetNumChildren() == 1) {
- int id = node.getChild(0).getId();
- if (id == JavaParserTreeConstants.JJTBOOLEANLITERAL) {
+ int childId = node.getChild(0).getId();
+ if (childId == JavaParserTreeConstants.JJTBOOLEANLITERAL) {
return ClassDescriptorLoader.getClassDescriptor(boolean.class);
}
- if (id == JavaParserTreeConstants.JJTNULLLITERAL) {
+ if (childId == JavaParserTreeConstants.JJTNULLLITERAL) {
return ClassDescriptorLoader.getClassDescriptor(NULL.class);
}
- throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[id]);
+ throw new RuntimeException("Expected BooleanLiteral or NullLiteral, found " + JavaParserTreeConstants.jjtNodeName[childId]);
}
- int id = node.firstToken.kind;
- switch (id) {
+ int nodeId = node.firstToken.kind;
+ switch (nodeId) {
case JavaParserConstants.INTEGER_LITERAL:
if (node.firstToken.image.toLowerCase().endsWith("l")) {
return ClassDescriptorLoader.getClassDescriptor(long.class);
@@ -173,7 +165,7 @@
case JavaParserConstants.STRING_LITERAL:
return ClassDescriptorLoader.getClassDescriptor(String.class);
default:
- throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[id]);
+ throw new RuntimeException("Expected literal token, found " + JavaParserConstants.tokenImage[nodeId]);
}
}
@@ -221,8 +213,7 @@
currentSymbol.setLength(0);
accepted = true;
recognizeClassNames = false;
- }
- catch (NoSuchFieldException e) {
+ } catch (NoSuchFieldException e) {
if (j == 0 || j == 1 && tokens[0].equals(compiler.getRootObject().getId())) { // still in root context
FieldDescriptor[] newFields = compiler.getScriptFields();
for (FieldDescriptor newField : newFields) {
@@ -301,20 +292,19 @@
return null;
}
int dotPos = lastNode.lastIndexOf(".");
- String objectCode = dotPos == -1 ? "" : lastNode.substring(0, dotPos);
+ String code = dotPos == -1 ? "" : lastNode.substring(0, dotPos);
for (int j = i - 2; j >= 0; j--) {
- objectCode = expression.getChild(j).getText() + objectCode;
+ code = expression.getChild(j).getText() + code;
}
- if (objectCode.length() == 0) {
- objectCode = compiler.getRootObject().getJavaCode();
+ if (code.length() == 0) {
+ code = compiler.getRootObject().getJavaCode();
}
String methodName = lastNode.substring(dotPos + 1).trim();
try {
MethodDescriptor method = contextClass.getMethodDescriptor(methodName);
- trackMemberIfPossible(objectCode, contextClass, method.getName(), true, listenerId);
+ trackMemberIfPossible(code, contextClass, method.getName(), true, listenerId);
return method.getReturnType();
- }
- catch (NoSuchMethodException e) {
+ } catch (NoSuchMethodException e) {
// happens for methods defined in the current JAXX file via scripts
String propertyName = null;
if (methodName.startsWith("is")) {
@@ -361,8 +351,7 @@
handler.getAddMemberListenerCode(objectCode, id, memberName, listenerId, compiler),
handler.getRemoveMemberListenerCode(objectCode, id, memberName, listenerId, compiler));
}
- }
- catch (UnsupportedAttributeException e) {
+ } catch (UnsupportedAttributeException e) {
// ignore -- this is thrown for methods like toString(), for which there is no tracking and
// no setting support
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,128 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package jaxx.compiler;
-
-import java.lang.reflect.Modifier;
-import java.util.Map.Entry;
-import jaxx.CompilerException;
-import jaxx.types.TypeManager;
-
-/**
- * The default compiledObjectDecorator.
- *
- * @author tony
- * @since 1.2
- */
-public class DefaultCompiledObjectDecorator extends CompiledObjectDecorator {
-
- @Override
- public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
-
- if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
- String id = object.getId();
- int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
- if (object == root) {
- javaFile.addField(new JavaField(access, fullClassName, id, "this"));
- } else {
- //TC -20081017 can have generic on compiled Object
- javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
- }
- }
-
- if (!compiler.inlineCreation(object) && object != root) {
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
- }
- }
-
- @Override
- public String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
- if (object instanceof ScriptInitializer) {
- return object.getInitializationCode(compiler);
- }
- StringBuffer result = new StringBuffer();
- if (object.isOverride() && object.getOverrideType()==object.getObjectClass()) {
- //TC-20090309 on utilise le super code quand l'objet est de meme type
- result.append("super.").append(object.getCreationMethodName()).append("();");
- } else {
- result.append(object.getId());
- result.append(" = ");
- if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
- result.append(object.getJavaBeanInitCode()).append(";");
- } else {
- String constructorParams = object.getConstructorParams();
- if (constructorParams != null) {
- //TC - 20081017 compiledObject can have generics
- result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
- //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
- } else {
- //TC - 20081017 compiledObject can have generics
- result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
- }
- }
- result.append(JAXXCompiler.getLineSeparator());
- result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
- }
- result.append(JAXXCompiler.getLineSeparator());
- String initCode = object.getInitializationCode(compiler);
- if (initCode != null && initCode.length() > 0) {
- result.append(initCode);
- }
-
- return result.toString();
- }
-
- @Override
- public String createCompleteSetupMethod(JAXXCompiler compiler, CompiledObject object, JavaFile javaFile, StringBuffer initDataBindings) {
- StringBuffer code = new StringBuffer();
- //TC-20090327 generate client properties
- if (object.hasClientProperties()) {
- // generate putClientProperty invocations
- for (Entry<String,String> entry : object.getClientProperties().entrySet()) {
- object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + entry.getKey() + "\", " + entry.getValue() + ");");
- }
-
- }
- //TC - 20081017 only generate the method if not empty ?
- if (object.getId().startsWith("$")) {
- code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
- } else {
- String additionCode = object.getAdditionCode();
- if (additionCode.length() > 0) {
- code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
- additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
- }
- }
- //code.append(getLineSeparator());
- return code.toString();
- }
-
- @Override
- public boolean createInitializer(JAXXCompiler compiler, CompiledObject root, CompiledObject object, StringBuffer code, boolean lastWasMethodCall) {
- if (object == root) {
- String rootCode = root.getInitializationCode(compiler);
- if (rootCode != null && rootCode.length() > 0) {
- code.append(rootCode);
- code.append(JAXXCompiler.getLineSeparator());
- }
- } else {
- if (!object.isOverride()) {
- if (compiler.inlineCreation(object)) {
- if (lastWasMethodCall) {
- lastWasMethodCall = false;
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append(getCreationCode(compiler, object));
- code.append(JAXXCompiler.getLineSeparator());
- } else {
- code.append(object.getCreationMethodName()).append("();");
- code.append(JAXXCompiler.getLineSeparator());
- lastWasMethodCall = true;
- }
- }
- }
- return lastWasMethodCall;
- }
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/CompilerOptions.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,247 @@
+package jaxx.compiler;
+
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+import java.io.File;
+import jaxx.runtime.context.JAXXContext;
+
+/**
+ * Options of the {@link JAXXCompiler} and {@link JAXXCompilerLaunchor}.
+ *
+ */
+public class DefaultCompilerConfiguration implements CompilerConfiguration {
+
+// private File javacTargetDirectory;
+// private String classPath;
+// private String javacOpts;
+// private boolean keepJavaFiles;
+ /**
+ *
+ */
+ private File targetDirectory;
+ /**
+ *
+ */
+ private boolean optimize;
+ /**
+ *
+ */
+ private boolean verbose;
+ /**
+ *
+ */
+ private boolean profile;
+ /**
+ * a flag to enable or disable i18n generation
+ */
+ private boolean i18nable;
+ /**
+ * a flag to add or not logger on generated jaxx files
+ */
+ private boolean addLogger;
+ /**
+ * a flag to not reset compiler after a compile
+ */
+ private boolean resetAfterCompile;
+ /**
+ * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * to be used on {@link jaxx.runtime.JAXXObject}.
+ */
+ protected Class<? extends JAXXContext> jaxxContextClass;
+ /**
+ * list of fqn of class to import for all generated jaxx files
+ */
+ protected String[] extraImports;
+ /**
+ * default error ui
+ */
+ private Class<?> defaultErrorUI;
+ /**
+ *
+ */
+ private ClassLoader classLoader;
+ /**
+ *
+ */
+ private Class<? extends JAXXCompiler> compilerClass;
+ /**
+ * the validator class to use.
+ *
+ * @since 1.6.0
+ */
+ private Class<?> validatorClass;
+ /**
+ * the default compiled object decorator to use if none specifed via
+ * decorator attribute
+ */
+ private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
+ /**
+ * a flag to use {@link javax.swing.UIManager} to retreave icons.
+ */
+ private boolean useUIManagerForIcon;
+ /**
+ * a flag to generate javax help for any
+ */
+ private boolean generateHelp;
+ /**
+ * Fully qualified name of help broker, can not use a class here
+ * since this class should be in sources (so not yet compiled)
+ */
+ private String helpBrokerFQN;
+ /**
+ * The prefix to add to i18n key for any help i18n key.
+ *
+ * @since 1.3
+ */
+ protected String helpsetI18nPrefix;
+ /**
+ * The suffix to add to i18n key for an help Id.
+ *
+ * @since 1.3
+ */
+ protected String helpsetTitleI18nSuffix;
+ /**
+ * The suffix to add to i18n key for an toc Id.
+ *
+ * @since 1.3
+ */
+ protected String helpsetTocI18nSuffix;
+ /**
+ * The suffix to add to i18n key for an toc Id.
+ *
+ * @since 1.3
+ */
+ protected String helpsetIndexI18nSuffix;
+ /**
+ * The helpset name
+ *
+ * @since 1.3
+ */
+ protected String helpSetName;
+
+ @Override
+ public File getTargetDirectory() {
+ return targetDirectory;
+ }
+
+ @Override
+ public boolean getOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public boolean isVerbose() {
+ return verbose;
+ }
+
+ public void setVerbose(boolean verbose) {
+ this.verbose = verbose;
+ }
+
+ @Override
+ public boolean isI18nable() {
+ return i18nable;
+ }
+
+ @Override
+ public boolean isUseUIManagerForIcon() {
+ return useUIManagerForIcon;
+ }
+
+ @Override
+ public boolean isAddLogger() {
+ return addLogger;
+ }
+
+ @Override
+ public Class<? extends JAXXContext> getJaxxContextClass() {
+ return jaxxContextClass;
+ }
+
+ @Override
+ public String[] getExtraImports() {
+ return extraImports;
+ }
+
+ @Override
+ public boolean isResetAfterCompile() {
+ return resetAfterCompile;
+ }
+
+ @Override
+ public boolean isOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public Class<?> getDefaultErrorUI() {
+ return defaultErrorUI;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ @Override
+ public Class<? extends JAXXCompiler> getCompilerClass() {
+ return compilerClass;
+ }
+
+ @Override
+ public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
+ return defaultDecoratorClass;
+ }
+
+ @Override
+ public boolean isProfile() {
+ return profile;
+ }
+
+ @Override
+ public boolean isGenerateHelp() {
+ return generateHelp;
+ }
+
+ @Override
+ public String getHelpBrokerFQN() {
+ return helpBrokerFQN;
+ }
+
+ @Override
+ public String getHelpsetIndexI18nSuffix() {
+ return helpsetIndexI18nSuffix;
+ }
+
+ @Override
+ public String getHelpsetTitleI18nSuffix() {
+ return helpsetTitleI18nSuffix;
+ }
+
+ @Override
+ public String getHelpsetTocI18nSuffix() {
+ return helpsetTocI18nSuffix;
+ }
+
+ @Override
+ public String getHelpSetName() {
+ return helpSetName;
+ }
+
+ @Override
+ public String getHelpsetI18nPrefix() {
+ return helpsetI18nPrefix;
+ }
+
+ @Override
+ public Class<?> getValidatorClass() {
+ return validatorClass;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/DefaultCompilerConfiguration.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/EventHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,10 +4,11 @@
*/
package jaxx.compiler;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.MethodDescriptor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
public class EventHandler {
+
private String eventId;
private String objectCode;
private ClassDescriptor listenerClass;
@@ -24,38 +25,32 @@
this.javaCode = javaCode;
}
-
public String getEventId() {
return eventId;
}
-
public String getObjectCode() {
return objectCode;
}
-
public MethodDescriptor getAddMethod() {
return addMethod;
}
-
public ClassDescriptor getListenerClass() {
return listenerClass;
}
-
public MethodDescriptor getListenerMethod() {
return listenerMethod;
}
-
public String getJavaCode() {
return javaCode;
}
-
+ @Override
public String toString() {
return "EventHandler[" + eventId + ", " + listenerClass.getName() + ", " + objectCode + ", " + javaCode + "]";
}
-}
\ No newline at end of file
+}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,14 +0,0 @@
-package jaxx.compiler;
-
-/**
- * TODO javadoc!
- *
- * @author chemit
- */
-public interface Generator {
-
- void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className);
-
- void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException;
-
-}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/HelpRootCompiledObjectDecorator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,93 +0,0 @@
-package jaxx.compiler;
-
-import java.lang.reflect.Modifier;
-import java.util.Iterator;
-import java.util.Set;
-
-/**
- * A decorator to place on a root compiled object to process javaHelp on the file.
- *
- * @author tony
- * @since 1.2
- */
-public class HelpRootCompiledObjectDecorator extends DefaultCompiledObjectDecorator {
-
- /**
- * the list of discovered helpId
- */
- protected static Set<String> helpIds = new java.util.HashSet<String>();
-
- protected String getBrokerFQN(JAXXCompiler compiler) {
- String helpBrokerFQN = compiler.getOptions().getHelpBrokerFQN();
- return helpBrokerFQN;
- }
-
- protected String getHelpId(CompiledObject o) {
- String helpID = null;
- if (o.hasClientProperties()) {
- helpID = o.getClientProperty("help");
- }
- return helpID;
- }
-
- @Override
- public void finalizeCompiler(JAXXCompiler compiler, CompiledObject root, CompiledObject object, JavaFile javaFile, String packageName, String className, String fullClassName) {
- super.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
- CompilerOptions options = compiler.getOptions();
-
- if (options.isGenerateHelp()) {
-
- // add JaxxHelpUI interface
- Class<?> validatorInterface = jaxx.runtime.JaxxHelpUI.class;
- String helpBrokerFQN = getBrokerFQN(compiler);
- javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface) + "<" + helpBrokerFQN + ">");
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "registerHelpId",
- "broker.installUI(component, helpId);",
- new JavaArgument(helpBrokerFQN, "broker"),
- new JavaArgument("Component", "component"),
- new JavaArgument("String", "helpId")));
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "showHelp",
- "getBroker().showHelp(this, helpId);",
- new JavaArgument("String", "helpId")));
-
- StringBuilder buffer = new StringBuilder();
-
- String lineSeparator = JAXXCompiler.getLineSeparator();
-
- if (options.isGenerateHelp()) {
-
- // add code to init javax help system
- Iterator<CompiledObject> itr = compiler.getObjectCreationOrder();
-
- for (; itr.hasNext();) {
- CompiledObject o = itr.next();
- String helpID = getHelpId(o);
- if (helpID != null) {
- buffer.append(lineSeparator);
- // detects a helpId to register
- buffer.append("registerHelpId(_broker, " + o.getJavaCode() + ", " + helpID + ");");
- //keep the helpID for helpSet generation
- helpIds.add(helpID);
- }
- }
- }
- if (buffer.length() > 0) {
-
- StringBuilder extraCode = new StringBuilder(helpBrokerFQN).append(" _broker = getBroker();");
-
- buffer.append(lineSeparator).append("_broker.prepareUI(this);");
- buffer.append(lineSeparator);
-
- // add the calls
- compiler.appendLateInitializer(extraCode.toString());
- compiler.appendLateInitializer(buffer.toString());
- }
- }
- }
-
- public static Set<String> getHelpIds() {
- return helpIds;
- }
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/I18nHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,5 @@
package jaxx.compiler;
-import jaxx.tags.DefaultComponentHandler;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -16,8 +15,7 @@
*/
public class I18nHelper {
- protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
-
+ protected static final Log log = LogFactory.getLog(I18nHelper.class);
public static final List<String> I18N_ATTRIBUTES = Arrays.asList("text", "title", "toolTipText");
/**
@@ -28,7 +26,7 @@
* @return <code>true</code> if wa have an active i18n attribute, <code>false</code> otherwise.
*/
public static boolean isI18nableAttribute(String attributeName, JAXXCompiler compiler) {
- return compiler.getOptions().isI18nable() && isI18nAttribute(attributeName);
+ return compiler.getConfiguration().isI18nable() && isI18nAttribute(attributeName);
}
/**
@@ -40,6 +38,7 @@
public static boolean isI18nAttribute(String attributeName) {
return I18N_ATTRIBUTES.contains(attributeName);
}
+
/**
* Add the i18n on a attribute.
* <p/>
@@ -60,7 +59,7 @@
log.debug(" try i18n support for [" + widgetId + ":" + attributeName + "] : " + attributeValueCode);
}
if (attributeValueCode.contains("_(") && attributeValueCode.contains(")")) {
- compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + attributeName + "' in component '" + widgetId + "' : ["+attributeValueCode+"]");
+ compiler.reportWarning("\n\tjaxx supports i18n, no need to add explicit call to I18n._ for attribute '" + attributeName + "' in component '" + widgetId + "' : [" + attributeValueCode + "]");
} else {
attributeValueCode = "_(" + attributeValueCode + ")";
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompiler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,22 +4,21 @@
*/
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.UnsupportedAttributeException;
-import jaxx.UnsupportedTagException;
-import jaxx.css.Rule;
-import jaxx.css.Stylesheet;
-import jaxx.css.StylesheetHelper;
-import jaxx.parser.ParseException;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.generators.Generator;
+import jaxx.compiler.parser.java.ParseException;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.TagManager;
import jaxx.runtime.ComponentDescriptor;
import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.tags.DefaultObjectHandler;
-import jaxx.tags.TagHandler;
-import jaxx.tags.TagManager;
+import jaxx.runtime.css.Rule;
+import jaxx.runtime.css.Stylesheet;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.w3c.dom.Document;
@@ -50,9 +49,7 @@
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Modifier;
-import java.net.MalformedURLException;
import java.net.URL;
-import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Arrays;
@@ -76,7 +73,6 @@
/** log */
protected static final Log log = LogFactory.getLog(JAXXCompiler.class);
-
/**
* True to throw exceptions when we encounter unresolvable classes, false to ignore.
* This is currently set to false until JAXX has full support for inner classes
@@ -84,158 +80,225 @@
* generally compile without error anyway).
*/
public static final boolean STRICT_CHECKS = false;
+ /**
+ *
+ */
public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/";
+ /**
+ *
+ */
public static final String JAXX_INTERNAL_NAMESPACE = "http://www.jaxxframework.org/internal";
-
- /** Maximum length of an inlinable creation method. */
+ /**
+ * Maximum length of an inlinable creation method.
+ */
public static final int INLINE_THRESHOLD = 300;
-
+ /**
+ *
+ */
protected final DefaultObjectHandler firstPassClassTagHandler;
-
+ /**
+ *
+ */
protected List<String> staticImports = new ArrayList<String>();
/*---------------------------------------------------------------------------------*/
/*-- compiler fields --------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
- /** flag to detec if an error occurs while compiling jaxx file */
+ /**
+ * flag to detec if an error occurs while compiling jaxx file
+ */
protected boolean failed;
-
- /** Object corresponding to the root tag in the document. */
+ /**
+ * Object corresponding to the root tag in the document.
+ */
protected CompiledObject root;
-
- /** Contains strings of the form "javax.swing." */
+ /**
+ * Contains strings of the form "javax.swing."
+ */
protected Set<String> importedPackages = new HashSet<String>();
-
- /** Contains strings of the form "javax.swing.Timer" */
+ /**
+ * Contains strings of the form "javax.swing.Timer"
+ */
protected Set<String> importedClasses = new HashSet<String>();
-
- /** Keeps track of open components (components still having children added). */
+ /**
+ * Keeps track of open components (components still having children added).
+ */
protected Stack<CompiledObject> openComponents = new Stack<CompiledObject>();
-
- /** Sequence number used to create automatic variable names. */
+ /**
+ * Sequence number used to create automatic variable names.
+ */
protected int autogenID = 0;
-
+ /**
+ *
+ */
protected List<DataBinding> dataBindings = new ArrayList<DataBinding>();
-
+ /**
+ *
+ */
protected SymbolTable symbolTable = new SymbolTable();
-
- /** Base directory used for path resolution (normally the directory in which the .jaxx file resides). */
+ /**
+ * Base directory used for path resolution (normally the directory in
+ * which the .jaxx file resides).
+ */
protected File baseDir;
-
- /** .jaxx file being compiled. */
+ /**
+ * .jaxx file being compiled.
+ */
protected File src;
-
- /** Parsed XML of src file. */
+ /**
+ * Parsed XML of src file.
+ */
protected Document document;
-
- /** Name of class being compiled. */
+ /**
+ * Name of class being compiled.
+ */
protected String outputClassName;
-
+ /**
+ *
+ */
protected ScriptManager scriptManager = new ScriptManager(this);
-
- /** Combination of all stylesheets registered using {@link #registerStylesheet}. */
+ /**
+ * Combination of all stylesheets registered using
+ * {@link #registerStylesheet}.
+ */
protected Stylesheet stylesheet;
-
- /** Contains all attributes defined inline on class tags. */
+ /**
+ * Contains all attributes defined inline on class tags.
+ */
protected List<Rule> inlineStyles = new ArrayList<Rule>();
-
/**
* Maps objects (expressed in Java code) to event listener classes (e.g. MouseListener) to Lists of EventHandlers. The final list
* contains all event handlers of a particular type attached to a particular object (again, as represented by a Java expression).
*/
protected Map<String, Map<ClassDescriptor, List<EventHandler>>> eventHandlers = new HashMap<String, Map<ClassDescriptor, List<EventHandler>>>();
-
- /** Maps of uniqued id for objects used in compiler */
+ /**
+ * Maps of uniqued id for objects used in compiler
+ */
protected Map<Object, String> uniqueIds = new HashMap<Object, String>();
-
- /** Map of event handler method names used in compiler */
+ /**
+ * Map of event handler method names used in compiler
+ */
protected Map<EventHandler, String> eventHandlerMethodNames = new HashMap<EventHandler, String>();
-
- /** ClassLoader which searches the user-specified class path in addition to the normal class path */
+ /**
+ * ClassLoader which searches the user-specified class path in addition to the normal class path
+ */
protected ClassLoader classLoader;
-
/**
* A list of Runnables which will be run after the first compilation pass. This is primarily used
* to trigger the creation of CompiledObjects, which cannot be created during the first pass and must be
* created in document order.
*/
protected List<Runnable> initializers = new ArrayList<Runnable>();
-
- /** left brace matcher */
+ /**
+ * left brace matcher
+ */
protected Matcher leftBraceMatcher = Pattern.compile("^(\\{)|[^\\\\](\\{)").matcher("");
-
- /** right brace matcher */
+ /**
+ * right brace matcher
+ */
protected Matcher rightBraceMatcher = Pattern.compile("^(\\})|[^\\\\](\\})").matcher("");
-
- /** extra interfaces which can by passed to root object via the 'implements' attribute */
+ /**
+ * extra interfaces which can by passed to root object via the 'implements' attribute
+ */
private String[] extraInterfaces;
-
- /** a flag to generate a abstract class */
+ /**
+ * a flag to generate a abstract class
+ */
private boolean abstractClass;
-
- /** the possible generic type of the class */
+ /**
+ * the possible generic type of the class
+ */
private String genericType;
-
- /** thepossible generic type of the super class */
+ /**
+ * the possible generic type of the super class
+ */
private String superGenericType;
-
- /** Extra code to be added to the instance initializer. */
+ /**
+ * Extra code to be added to the instance initializer.
+ */
protected StringBuffer initializer = new StringBuffer();
-
- /** Extra code to be added at the end of the instance initializer. */
+ /**
+ * Extra code to be added at the end of the instance initializer.
+ */
protected StringBuffer lateInitializer = new StringBuffer();
-
- /** Extra code to be added to the class body. */
+ /**
+ * Extra code to be added to the class body.
+ */
protected StringBuffer bodyCode = new StringBuffer();
-
- /** Code to initialize data bindings. */
+ /**
+ * Code to initialize data bindings.
+ */
protected StringBuffer initDataBindings = new StringBuffer();
-
- /** Body of the applyDataBinding method. */
+ /**
+ * Body of the applyDataBinding method.
+ */
protected StringBuffer applyDataBinding = new StringBuffer();
-
- /** Body of the removeDataBinding method. */
+ /**
+ * Body of the removeDataBinding method.
+ */
protected StringBuffer removeDataBinding = new StringBuffer();
-
- /** Body of the processDataBinding method. */
+ /**
+ * Body of the processDataBinding method.
+ */
protected StringBuffer processDataBinding = new StringBuffer();
-
- /** true if a main() method has been declared in a script */
+ /**
+ * true if a main() method has been declared in a script
+ */
protected boolean mainDeclared;
-
- /** the file to be generated */
+ /**
+ * the file to be generated
+ */
protected JavaFile javaFile;
-
-
- protected CompilerOptions options;
-
- /** Used for error reporting purposes, so we can report the right line number. */
+ /**
+ *
+ */
+ protected CompilerConfiguration configuration;
+ /**
+ * Used for error reporting purposes, so we can report the right line number.
+ */
protected Stack<Element> tagsBeingCompiled = new Stack<Element>();
-
- /** Used for error reporting purposes, so we can report the right source file. */
+ /**
+ * Used for error reporting purposes, so we can report the right source file.
+ */
protected Stack<File> sourceFiles = new Stack<File>();
-
- /** Maps object ID strings to the objects themselves. These are created during the second compilation pass. */
+ /**
+ * Maps object ID strings to the objects themselves. These are created during the second compilation pass.
+ */
protected Map<String, CompiledObject> objects = new LinkedHashMap<String, CompiledObject>();
-
- /** Maps objects to their ID strings. These are created during the second compilation pass. */
+ /**
+ * Maps objects to their ID strings. These are created during the second compilation pass.
+ */
protected Map<CompiledObject, String> ids = new LinkedHashMap<CompiledObject, String>();
+ /**
+ *
+ */
+ protected CompiledObjectDecorator defaultDecorator;
- protected CompiledObjectDecorator defaultDecorator;
-
/*---------------------------------------------------------------------------------*/
/*-- Constructor methods ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
+ protected JAXXCompiler(ClassLoader classLoader) {
- protected JAXXCompiler(ClassLoader classLoader, DefaultObjectHandler firstPassClassTagHandler, String... staticImports) {
- this.firstPassClassTagHandler = firstPassClassTagHandler;
- this.options = new CompilerOptions();
+ this.firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ this.configuration = new DefaultCompilerConfiguration();
this.classLoader = classLoader;
- if (staticImports == null || staticImports.length == 0) {
- staticImports = new String[0];
- }
- this.staticImports = Arrays.asList(staticImports);
+// this.staticImports = Arrays.asList(new String[]{
+// "java.awt.*",
+// "java.awt.event.*",
+// "java.beans.*",
+// "java.io.*",
+// "java.lang.*",
+// "java.util.*",
+// "javax.swing.*",
+// "javax.swing.border.*",
+// "javax.swing.event.*",
+// "jaxx.runtime.swing.JAXXButtonGroup",
+// "jaxx.runtime.swing.HBox",
+// "jaxx.runtime.swing.VBox",
+// "jaxx.runtime.swing.Table",
+// "static org.nuiton.i18n.I18n._",
+// "static jaxx.runtime.Util.createImageIcon"
+// });
addImport("java.lang.*");
}
@@ -245,42 +308,52 @@
* @param baseDir classpath location
* @param src location of file to compile
* @param outputClassName the out file name
- * @param options options to pass to javac
- * @param firstPassClassTagHandler handler to use for first pass
- * @param staticImports statics imports
+ * @param configuration configuration to pass to javac
*/
- protected JAXXCompiler(File baseDir, File src, String outputClassName, CompilerOptions options, DefaultObjectHandler firstPassClassTagHandler, String... staticImports) {
+ public JAXXCompiler(File baseDir, File src, String outputClassName, CompilerConfiguration configuration) {
this.baseDir = baseDir;
this.src = src;
- this.firstPassClassTagHandler = firstPassClassTagHandler;
- this.staticImports = Arrays.asList(staticImports);
+ this.firstPassClassTagHandler = new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ this.staticImports = Arrays.asList(new String[]{
+ "java.awt.*",
+ "java.awt.event.*",
+ "java.beans.*",
+ "java.io.*",
+ "java.lang.*",
+ "java.util.*",
+ "javax.swing.*",
+ "javax.swing.border.*",
+ "javax.swing.event.*",
+ "jaxx.runtime.swing.JAXXButtonGroup",
+ "jaxx.runtime.swing.HBox",
+ "jaxx.runtime.swing.VBox",
+ "jaxx.runtime.swing.Table",
+ "static org.nuiton.i18n.I18n._",
+ "static jaxx.runtime.Util.createImageIcon"
+ });
sourceFiles.push(src);
this.outputClassName = outputClassName;
- this.options = options;
+ this.configuration = configuration;
addImport(outputClassName.substring(0, outputClassName.lastIndexOf(".") + 1) + "*");
- if (staticImports == null || staticImports.length == 0) {
- staticImports = new String[]{"java.lang.*"};
- }
for (Object staticImport : staticImports) {
addImport((String) staticImport);
}
- // add extra imports from options
- if (options.getExtraImports() != null) {
- for (String extraImport : options.getExtraImports()) {
+ // add extra imports from configuration
+ if (configuration.getExtraImports() != null) {
+ for (String extraImport : configuration.getExtraImports()) {
addImport(extraImport);
}
}
- defaultDecorator = CompiledObjectDecorator.getDecorator(options.getDefaultDecoratorClass());
+ defaultDecorator = CompiledObjectDecoratorManager.getDecorator(configuration.getDefaultDecoratorClass());
if (defaultDecorator == null) {
- log.error("could not find default decorator : "+options.getDefaultDecoratorClass());
- throw new IllegalArgumentException("could not find default decorator : " + options.getDefaultDecoratorClass());
+ log.error("could not find default decorator : " + configuration.getDefaultDecoratorClass());
+ throw new IllegalArgumentException("could not find default decorator : " + configuration.getDefaultDecoratorClass());
}
}
/*---------------------------------------------------------------------------------*/
/*-- Initializer methods -----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void runInitializers() {
for (Runnable runnable : initializers) {
if (log.isDebugEnabled()) {
@@ -297,7 +370,6 @@
initializers.clear();
}
-
/**
* Registers a <code>Runnable</code> which will be executed after the first
* compilation pass is complete.
@@ -311,7 +383,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Compile methods --------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void compileFirstPass(final Element tag) throws IOException {
tagsBeingCompiled.push(tag);
@@ -322,13 +393,14 @@
// resolve class tags into fully-qualified class name
if (namespace != null && namespace.endsWith("*")) {
String packageName = namespace.substring(0, namespace.length() - 1);
- if (localName.startsWith(packageName)) // class name is fully-qualified already
- {
+ if (localName.startsWith(packageName)) {
+ // class name is fully-qualified already
fullClassName = TagManager.resolveClassName(localName, this);
- } else { // namespace not included in class name, probably need the namespace to resolve
+ } else {
+ // namespace not included in class name, probably need the namespace to resolve
fullClassName = TagManager.resolveClassName(packageName + localName, this);
- if (fullClassName == null && !namespacePrefix) // it was just a default namespace, try again without using the namespace
- {
+ if (fullClassName == null && !namespacePrefix) {
+ // it was just a default namespace, try again without using the namespace
fullClassName = TagManager.resolveClassName(localName, this);
}
}
@@ -336,7 +408,8 @@
fullClassName = TagManager.resolveClassName(localName, this);
}
- if (fullClassName != null) { // we are definitely dealing with a class tag
+ if (fullClassName != null) {
+ // we are definitely dealing with a class tag
addDependencyClass(fullClassName);
namespace = fullClassName.substring(0, fullClassName.lastIndexOf(".") + 1) + "*";
if (symbolTable.getSuperclassName() == null) {
@@ -369,7 +442,8 @@
}
if (handler == firstPassClassTagHandler) {
final String finalClassName = fullClassName;
- registerInitializer(new Runnable() { // register an initializer which will create the CompiledObject after pass 1
+ registerInitializer(new Runnable() {
+ // register an initializer which will create the CompiledObject after pass 1
@Override
public void run() {
@@ -384,8 +458,7 @@
if (handler != null) {
try {
handler.compileFirstPass(tag, this);
- }
- catch (CompilerException e) {
+ } catch (CompilerException e) {
reportError(e);
}
} else {
@@ -399,7 +472,6 @@
}
}
-
public void compileSecondPass(Element tag) throws IOException {
tagsBeingCompiled.push(tag);
@@ -425,11 +497,9 @@
document = parseDocument(in);
in.close();
compileFirstPass(document.getDocumentElement());
- }
- catch (SAXParseException e) {
+ } catch (SAXParseException e) {
reportError(e.getLineNumber(), "Invalid XML: " + e.getMessage());
- }
- catch (SAXException e) {
+ } catch (SAXException e) {
reportError(null, "Error parsing XML document: " + e);
}
}
@@ -444,7 +514,6 @@
/*---------------------------------------------------------------------------------*/
/*-- CompiledObject methods -------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void openComponent(CompiledObject component) throws CompilerException {
openComponent(component, null);
}
@@ -504,7 +573,6 @@
return objects.get(id);
}
-
public boolean inlineCreation(CompiledObject object) {
return object.getId().startsWith("$") && object.getInitializationCode(this).length() < INLINE_THRESHOLD;
}
@@ -526,8 +594,7 @@
object.setOverride(true);
object.setOverrideType(f.getType());
break;
- }
- catch (NoSuchFieldException e) {
+ } catch (NoSuchFieldException e) {
ancestor = ancestor.getSuperclass();
}
}
@@ -536,7 +603,6 @@
/*---------------------------------------------------------------------------------*/
/*-- DataBinding methods ----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
/**
* Examine an attribute value for data binding expressions. Returns a 'cooked' expression which
* can be used to determine the resulting value. It is expected that this expression will be used
@@ -546,7 +612,7 @@
* @param stringValue the string value of the property from the XML
* @param type the type of the property, from the <code>JAXXPropertyDescriptor</code>
* @return a processed version of the expression
- * @throws jaxx.CompilerException ?
+ * @throws CompilerException ?
*/
public String processDataBindings(String stringValue, ClassDescriptor type) throws CompilerException {
int pos = getNextLeftBrace(stringValue, 0);
@@ -596,13 +662,11 @@
return null;
}
-
public void registerDataBinding(String src, String dest, String assignment) {
try {
src = checkJavaCode(src);
dataBindings.add(new DataBinding(src, dest, assignment, this));
- }
- catch (CompilerException e) {
+ } catch (CompilerException e) {
reportError("While parsing data binding for '" + dest.substring(dest.lastIndexOf(".") + 1) + "': " + e.getMessage());
}
}
@@ -626,13 +690,13 @@
public String getEventHandlerMethodName(EventHandler handler) {
String result = eventHandlerMethodNames.get(handler);
if (result == null) {
- if (getOptions().isOptimize()) {
+ if (getConfiguration().isOptimize()) {
result = "$ev" + eventHandlerMethodNames.size();
} else {
//TC-20090309 must get the goal property from the event id
// to make possible inheritance
- String id = handler.getEventId().substring(0,handler.getEventId().indexOf("."));
-
+ String id = handler.getEventId().substring(0, handler.getEventId().indexOf("."));
+
result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + id;
//result = "do" + org.apache.commons.lang.StringUtils.capitalize(handler.getListenerMethod().getName()) + "__on__" + handler.getObjectCode();
}
@@ -644,7 +708,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Script methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void addScriptField(FieldDescriptor field) {
symbolTable.getScriptFields().add(field);
}
@@ -685,7 +748,6 @@
/*---------------------------------------------------------------------------------*/
/*-- StyleSheet methods -----------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void applyStylesheets() {
for (Object o : new ArrayList<CompiledObject>(objects.values())) {
CompiledObject object = (CompiledObject) o;
@@ -708,7 +770,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Report methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void reportWarning(String warning) {
Element currentTag = null;
if (!tagsBeingCompiled.isEmpty()) {
@@ -717,7 +778,6 @@
reportWarning(currentTag, warning, 0);
}
-
public void reportWarning(Element tag, String warning, int lineOffset) {
String lineNumber = null;
if (tag != null) {
@@ -729,8 +789,7 @@
File srcFile = sourceFiles.peek();
try {
srcFile = srcFile.getCanonicalFile();
- }
- catch (IOException e) {
+ } catch (IOException e) {
// ignore ?
}
@@ -742,7 +801,6 @@
JAXXCompilerLaunchor.get().warningCount++;
}
-
public void reportError(String error) {
Element currentTag = null;
if (!tagsBeingCompiled.isEmpty()) {
@@ -795,8 +853,7 @@
if (errorFile != null) {
errorFile = errorFile.getCanonicalFile();
}
- }
- catch (IOException e) {
+ } catch (IOException e) {
// ignore ?
}
@@ -812,7 +869,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Getter methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public Map<String, CompiledObject> getObjects() {
return objects;
}
@@ -822,15 +878,14 @@
}
/*public List<CompiledBeanValidator> getValidators() {
- return validators;
+ return validators;
}*/
-
public Map<String, Map<ClassDescriptor, List<EventHandler>>> getEventHandlers() {
return eventHandlers;
}
- public CompilerOptions getOptions() {
- return options;
+ public CompilerConfiguration getConfiguration() {
+ return configuration;
}
public String getOutputClassName() {
@@ -889,10 +944,10 @@
}
public MethodDescriptor getScriptMethod(String methodName) {
- for (MethodDescriptor m :symbolTable.getScriptMethods()) {
- if (methodName.equals(m.getName())) {
- return m;
- }
+ for (MethodDescriptor m : symbolTable.getScriptMethods()) {
+ if (methodName.equals(m.getName())) {
+ return m;
+ }
}
return null;
}
@@ -909,24 +964,24 @@
*/
public ClassLoader getClassLoader() {
if (classLoader == null) {
- if (options.getClassLoader() != null) {
- classLoader = options.getClassLoader();
+ if (configuration.getClassLoader() != null) {
+ classLoader = configuration.getClassLoader();
} else {
- String classPath = options.getClassPath();
- if (classPath == null) {
- classPath = ".";
- }
- String[] paths = classPath.split(File.pathSeparator);
- URL[] urls = new URL[paths.length];
- for (int i = 0; i < paths.length; i++) {
- try {
- urls[i] = new File(paths[i]).toURI().toURL();
- }
- catch (MalformedURLException e) {
- throw new RuntimeException(e);
- }
- }
- classLoader = new URLClassLoader(urls, getClass().getClassLoader());
+ throw new NullPointerException("compiler configuration requires a classLoader! :\n" + configuration);
+// String classPath = configuration.getClassPath();
+// if (classPath == null) {
+// classPath = ".";
+// }
+// String[] paths = classPath.split(File.pathSeparator);
+// URL[] urls = new URL[paths.length];
+// for (int i = 0; i < paths.length; i++) {
+// try {
+// urls[i] = new File(paths[i]).toURI().toURL();
+// } catch (MalformedURLException e) {
+// throw new RuntimeException(e);
+// }
+// }
+// classLoader = new URLClassLoader(urls, getClass().getClassLoader());
}
}
@@ -945,7 +1000,8 @@
CompiledObject parent = components[i].getParent();
while (parent != null) {
boolean found = false;
- for (int j = i + 1; j < components.length; j++) { // found parent after component, swap them
+ for (int j = i + 1; j < components.length; j++) {
+ // found parent after component, swap them
if (components[j] == parent) {
components[j] = components[i];
components[i] = parent;
@@ -967,7 +1023,8 @@
}
}
}
- descriptors[i] = new ComponentDescriptor(components[i].getId(), components[i] == root ? outputClassName : components[i].getObjectClass().getName(),
+ descriptors[i] = new ComponentDescriptor(
+ components[i].getId(), components[i] == root ? outputClassName : components[i].getObjectClass().getName(),
components[i].getStyleClass(), parentIndex != -1 ? descriptors[parentIndex] : null);
}
@@ -982,7 +1039,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Setter methods ---------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void setFailed(boolean failed) {
this.failed = failed;
}
@@ -990,7 +1046,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Buffer ------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public StringBuffer getInitializer() {
return initializer;
}
@@ -1084,7 +1139,6 @@
/*---------------------------------------------------------------------------------*/
/*-- Other methods ----------------------------------------------------------------*/
/*---------------------------------------------------------------------------------*/
-
public void addImport(String text) {
if (text.endsWith("*")) {
importedPackages.add(text.substring(0, text.length() - 1));
@@ -1098,6 +1152,7 @@
}
public void addDependencyClass(String className) {
+
if (!JAXXCompilerLaunchor.get().jaxxFileClassNames.contains(className)) {
URL jaxxURL = getClassLoader().getResource(className.replace('.', '/') + ".jaxx");
URL classURL = getClassLoader().getResource(className.replace('.', '/') + ".class");
@@ -1108,8 +1163,7 @@
if (classFile.lastModified() > jaxxFile.lastModified()) {
return; // class file is newer, no need to recompile
}
- }
- catch (Exception e) {
+ } catch (Exception e) {
// do nothing
}
}
@@ -1118,8 +1172,7 @@
File jaxxFile = URLtoFile(jaxxURL);
try {
jaxxFile = jaxxFile.getCanonicalFile();
- }
- catch (IOException ex) {
+ } catch (IOException ex) {
// ignore ?
}
assert jaxxFile.getName().equalsIgnoreCase(className.substring(className.lastIndexOf(".") + 1) + ".jaxx") :
@@ -1141,7 +1194,7 @@
*
* @param javaCode the Java code snippet to test
* @return a "cooked" version of the string which has enclosing curly braces removed.
- * @throws jaxx.CompilerException if the code cannot be parsed
+ * @throws CompilerException if the code cannot be parsed
*/
public String checkJavaCode(String javaCode) {
javaCode = scriptManager.trimScript(javaCode);
@@ -1265,7 +1318,7 @@
}
public String getAutoId(ClassDescriptor objectClass) {
- if (options.getOptimize()) {
+ if (configuration.getOptimize()) {
return "$" + Integer.toString(autogenID++, 36);
} else {
String name = objectClass.getName();
@@ -1328,8 +1381,8 @@
public void generateCode(Iterable<Generator> generatorIterator) throws IOException {
File dest;
- if (getOptions().getTargetDirectory() != null) {
- dest = new File(getOptions().getTargetDirectory(), getOutputClassName().replace('.', File.separatorChar) + ".java");
+ if (getConfiguration().getTargetDirectory() != null) {
+ dest = new File(getConfiguration().getTargetDirectory(), getOutputClassName().replace('.', File.separatorChar) + ".java");
} else {
dest = new File(getBaseDir(), getOutputClassName().substring(getOutputClassName().lastIndexOf(".") + 1) + ".java");
}
@@ -1369,7 +1422,6 @@
throw new CompilerException(e);
}
}
-
/** line separator cached value */
protected static String lineSeparator = System.getProperty("line.separator", "\n");
@@ -1471,8 +1523,7 @@
}
try {
return new File(URLDecoder.decode(urlString.replace('/', File.separatorChar), "utf-8"));
- }
- catch (UnsupportedEncodingException e) {
+ } catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
@@ -1484,11 +1535,9 @@
SAXParser parser;
parser = factory.newSAXParser();
return parser;
- }
- catch (SAXException e) {
+ } catch (SAXException e) {
throw new RuntimeException(e);
- }
- catch (ParserConfigurationException e) {
+ } catch (ParserConfigurationException e) {
throw new RuntimeException(e);
}
}
@@ -1498,6 +1547,7 @@
TransformerFactory factory = TransformerFactory.newInstance();
Transformer transformer = factory.newTransformer();
transformer.setErrorListener(new ErrorListener() {
+
@Override
public void warning(TransformerException ex) throws TransformerException {
throw ex;
@@ -1516,6 +1566,7 @@
DOMResult result = new DOMResult();
transformer.transform(new SAXSource(new XMLFilterImpl(getSAXParser().getXMLReader()) {
+
Locator locator;
@Override
@@ -1531,11 +1582,9 @@
}
}, new InputSource(in)), result);
return (Document) result.getNode();
- }
- catch (TransformerConfigurationException e) {
+ } catch (TransformerConfigurationException e) {
throw new RuntimeException(e);
- }
- catch (TransformerException e) {
+ } catch (TransformerException e) {
Throwable ex = e;
while (ex.getCause() != null) {
ex = ex.getCause();
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXCompilerLaunchor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,9 +1,7 @@
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.spi.Initializer;
-import jaxx.tags.DefaultObjectHandler;
+import jaxx.compiler.generators.Generator;
+import jaxx.compiler.spi.Initializer;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -16,6 +14,7 @@
import java.util.List;
import java.util.Map;
import java.util.ServiceLoader;
+import jaxx.compiler.generators.GeneratorManager;
/** @author chemit */
public class JAXXCompilerLaunchor {
@@ -53,10 +52,10 @@
*
* @param base the directory against which to resolve relative paths
* @param relativePaths a list of relative paths to .jaxx files being compiled
- * @param options the compiler options to use
+ * @param configuration the compiler configuration to use
* @return the new instanciated launchor
*/
- public static synchronized JAXXCompilerLaunchor newLaunchor(File base, String[] relativePaths, CompilerOptions options) {
+ public static synchronized JAXXCompilerLaunchor newLaunchor(File base, String[] relativePaths, CompilerConfiguration configuration) {
File[] files = new File[relativePaths.length];
String[] classNames = new String[relativePaths.length];
for (int i = 0; i < files.length; i++) {
@@ -67,7 +66,7 @@
classNames[i] = classNames[i].replace('\\', '.');
classNames[i] = classNames[i].replace(':', '.');
}
- return newLaunchor(files, classNames, options);
+ return newLaunchor(files, classNames, configuration);
}
/**
@@ -78,14 +77,14 @@
*
* @param files the .jaxx files to compile
* @param classNames the names of the classes being compiled
- * @param options the compiler options to use
+ * @param configuration the compiler configuration to use
* @return the new instanciated launchor
*/
- public static synchronized JAXXCompilerLaunchor newLaunchor(File[] files, String[] classNames, CompilerOptions options) {
+ public static synchronized JAXXCompilerLaunchor newLaunchor(File[] files, String[] classNames, CompilerConfiguration configuration) {
if (singleton != null) {
singleton.reset();
}
- singleton = new JAXXCompilerLaunchor(files, classNames, options);
+ singleton = new JAXXCompilerLaunchor(files, classNames, configuration);
return singleton;
}
@@ -124,8 +123,8 @@
initializer.initialize();
}
}
- /** options of the launchor and underlines compilers */
- protected CompilerOptions options;
+ /** configuration of the launchor and underlines compilers */
+ protected CompilerConfiguration configuration;
/** original list of files to compile */
protected final File[] files;
/** original list of classes to compile */
@@ -144,14 +143,14 @@
protected int compilerCount;
protected JAXXProfile profiler;
- protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerOptions options) {
- this.options = options == null ? new CompilerOptions() : options;
+ protected JAXXCompilerLaunchor(File[] files, String[] classNames, CompilerConfiguration options) {
+ this.configuration = options == null ? new DefaultCompilerConfiguration() : options;
this.files = files;
this.classNames = classNames;
- if (this.options.isVerbose()) {
+ if (this.configuration.isVerbose()) {
log.info("files : " + Arrays.toString(files));
}
- if (this.options.isProfile()) {
+ if (this.configuration.isProfile()) {
profiler = new JAXXProfile();
}
}
@@ -173,7 +172,7 @@
}
public String getVersion() {
- return "1.0.4";
+ return "2.0.0";
}
/**
@@ -192,7 +191,7 @@
* @return the compiler
*/
public static JAXXCompiler createDummyCompiler(ClassLoader classLoader) {
- return new JAXXCompiler(classLoader, new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class))) {
+ return new JAXXCompiler(classLoader) {
};
}
@@ -262,7 +261,7 @@
throw new CompilerException("Internal error: " + className + " is already being compiled, attempting to compile it again");
}
- File destDir = options.getTargetDirectory();
+ File destDir = configuration.getTargetDirectory();
if (destDir != null) {
int dotPos = className.lastIndexOf(".");
if (dotPos != -1) {
@@ -342,10 +341,7 @@
return false;
}
assert jaxxFiles.size() == jaxxFileClassNames.size();
- List<Generator> generators = new ArrayList<Generator>();
- for (Generator generator : ServiceLoader.load(Generator.class)) {
- generators.add(generator);
- }
+ List<Generator> generators = GeneratorManager.getGenerators();
for (String className : jaxxFileClassNames) {
JAXXCompiler compiler = getCompiler(className, "Internal error: could not find compiler for " + className + " during code generation");
addProfileTime(compiler, currentPass.name() + "_start");
@@ -357,7 +353,7 @@
}
}
- if (options.isProfile()) {
+ if (configuration.isProfile()) {
// profile pass (only if succes compile)
if (!nextStep(LifeCycle.profile_pass, success)) {
return false;
@@ -379,7 +375,7 @@
} finally {
compilerCount = compilers.size();
//TC - 20081018 only reset when no error was detected
- if (options.isResetAfterCompile() && errorCount == 0) {
+ if (configuration.isResetAfterCompile() && errorCount == 0) {
reset();
}
}
@@ -420,8 +416,8 @@
}
protected JAXXCompiler newCompiler(File parentFile, File file, String className) throws InvocationTargetException, IllegalAccessException, InstantiationException, NoSuchMethodException {
- Constructor<? extends JAXXCompiler> cons = options.getCompilerClass().getConstructor(File.class, File.class, String.class, CompilerOptions.class);
- return cons.newInstance(parentFile, file, className, options);
+ Constructor<? extends JAXXCompiler> cons = configuration.getCompilerClass().getConstructor(File.class, File.class, String.class, CompilerConfiguration.class);
+ return cons.newInstance(parentFile, file, className, configuration);
}
public static void addProfileTime(JAXXCompiler compiler, String key) {
@@ -430,22 +426,4 @@
p.addTime(compiler, key);
}
}
-
- protected static void showUsage() {
- System.out.println("Usage: jaxxc <options> <source files>");
- System.out.println();
- System.out.println("Source files must end in extension .jaxx");
- System.out.println("Use JAXX_OPTS environment variable to pass arguments to Java runtime");
- System.out.println();
- System.out.println("Supported options include:");
- System.out.println(" -classpath <paths> paths to search for user classes");
- System.out.println(" -cp <paths> same as -classpath");
- System.out.println(" -d <directory> target directory for generated class files");
- System.out.println(" -java or -j produce .java files, but do not compile them");
- System.out.println(" -keep or -k preserve generated .java files after compilation");
- System.out.println(" -optimize or -o optimize during compilation");
- System.out.println(" -version display version information");
- System.out.println();
- System.out.println("See http://www.jaxxframework.org/ for full documentation.");
- }
}
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JAXXObjectGenerator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,598 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.Base64Coder;
-import jaxx.CompilerException;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.JAXXObjectDescriptor;
-import jaxx.types.TypeManager;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.io.IOException;
-import java.lang.reflect.Modifier;
-import static java.lang.reflect.Modifier.FINAL;
-import static java.lang.reflect.Modifier.PROTECTED;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-
-/**
- * This class is a refactoring of the {@link jaxx.compiler.JAXXCompiler}.
- * <p/>
- * We delegate now the generation of a {@link jaxx.runtime.JAXXObject} to this class, the
- * {@link jaxx.compiler.JAXXCompiler} now only deals with the compilation of files.
- *
- * @author chemit
- */
-public class JAXXObjectGenerator implements Generator {
-
- /** log */
- protected static final Log log = LogFactory.getLog(JAXXObjectGenerator.class);
- protected static final JavaField ACTIVE_BINDINGS_FIELD = JavaField.newField(PROTECTED,
- "java.util.List<Object>", "$activeBindings", "new ArrayList<Object>()");
- protected static final JavaField BINDING_SOURCES_FIELD = JavaField.newField(PROTECTED,
- "java.util.Map<String,Object>", "$bindingSources", "new HashMap<String,Object>()");
- protected static final JavaField OBJECT_MAP_FIELD = JavaField.newField(PROTECTED,
- "Map<String,Object>", "$objectMap", "new HashMap<String,Object>()");
- protected static final JavaField ALL_COMPONENTS_CREATED_FIELD = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
- "boolean", "allComponentsCreated");
- protected static final JavaField CONTEXT_INITIALIZED = JavaField.newField(java.lang.reflect.Modifier.PRIVATE,
- "boolean", "contextInitialized", "true");
- protected static final JavaField PREVIOUS_VALUES_FIELD = JavaField.newField(0,
- "java.util.Map", "$previousValues", "new java.util.HashMap()");
- protected static final JavaField DELEGATE_CONTEXT_FIELD = JavaField.newField(PROTECTED,
- "jaxx.runtime.JAXXContext", "delegateContext");
- protected static final JavaField PROPERTY_CHANGE_SUPPORT_FIELD = JavaField.newField(0,
- "java.beans.PropertyChangeSupport", "$propertyChangeSupport");
- protected static final JavaMethod GET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
- "return delegateContext.getContextValue(clazz, null);",
- new JavaArgument("Class<T>", "clazz"));
- protected static final JavaMethod GET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> T", "getContextValue",
- "return delegateContext.getContextValue(clazz, name);",
- new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
- protected static final JavaMethod SET_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
- "delegateContext.setContextValue(o, name);",
- new JavaArgument("T", "o"), new JavaArgument("String", "name"));
- protected static final JavaMethod SET_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "setContextValue",
- "delegateContext.setContextValue(o, null);",
- new JavaArgument("T", "o"));
- protected static final JavaMethod REMOVE_CONTEXT_VALUE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
- "delegateContext.removeContextValue(clazz, name);",
- new JavaArgument("Class<T>", "clazz"), new JavaArgument("String", "name"));
- protected static final JavaMethod REMOVE_CONTEXT_VALUE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<T> void", "removeContextValue",
- "delegateContext.removeContextValue(clazz, null);",
- new JavaArgument("Class<T>", "clazz"));
- protected static final JavaMethod GET_PARENT_CONTAINER_MORE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
- "return delegateContext.getParentContainer(source, clazz);",
- new JavaArgument("Object", "source"), new JavaArgument("Class<O>", "clazz"));
- protected static final JavaMethod GET_PARENT_CONTAINER_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "<O extends Container> O", "getParentContainer",
- "return delegateContext.getParentContainer(clazz);",
- new JavaArgument("Class<O>", "clazz"));
- protected static final JavaMethod GET_OBJECT_BY_ID_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "java.lang.Object", "getObjectById",
- "return $objectMap.get(id);",
- new JavaArgument("String", "id"));
- protected static final JavaMethod GET_JAXX_OBJECT_DESCRIPTOR_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC | java.lang.reflect.Modifier.STATIC, "jaxx.runtime.JAXXObjectDescriptor", "$getJAXXObjectDescriptor",
- "return jaxx.runtime.Util.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);");
- protected static final JavaMethod PROCESS_DATA_BINDING_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "processDataBinding",
- "processDataBinding(dest, false);",
- new JavaArgument("String", "dest"));
- protected static final JavaMethod FIRE_PROPERTY_CHANGE_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
- "super.firePropertyChange(propertyName, oldValue, newValue);",
- new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
- protected static final JavaMethod FIRE_PROPERTY_CHANGE_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "firePropertyChange",
- "$getPropertyChangeSupport().firePropertyChange(propertyName, oldValue, newValue);",
- new JavaArgument("String", "propertyName"), new JavaArgument("Object", "oldValue"), new JavaArgument("Object", "newValue"));
- protected static final JavaMethod GET_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(0, "java.beans.PropertyChangeSupport", "$getPropertyChangeSupport",
- "if ($propertyChangeSupport == null)\n" +
- " $propertyChangeSupport = new PropertyChangeSupport(this);\n" +
- "return $propertyChangeSupport;");
- protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
- "$getPropertyChangeSupport().addPropertyChangeListener(listener);",
- new JavaArgument("java.beans.PropertyChangeListener", "listener"));
- protected static final JavaMethod ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "addPropertyChangeListener",
- "$getPropertyChangeSupport().addPropertyChangeListener(property, listener);",
- new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
- protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
- "$getPropertyChangeSupport().removePropertyChangeListener(listener);",
- new JavaArgument("java.beans.PropertyChangeListener", "listener"));
- protected static final JavaMethod REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD = JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, "void", "removePropertyChangeListener",
- "$getPropertyChangeSupport().removePropertyChangeListener(property, listener);",
- new JavaArgument("String", "property"), new JavaArgument("java.beans.PropertyChangeListener", "listener"));
-
- @Override
- public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
-
- String fullClassName = packageName != null ? packageName + "." + className : className;
- if (root == null) {
- throw new CompilerException("root tag must be a class tag");
- }
- //Map<String, CompiledObject> objects = compiler.getObjects();
- ClassDescriptor superclass = root.getObjectClass();
- boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(superclass);
- javaFile.setModifiers(Modifier.PUBLIC);
- javaFile.setClassName(fullClassName);
- javaFile.setSuperClass(JAXXCompiler.getCanonicalName(superclass));
- javaFile.setSuperclassIsJAXXObject(superclassIsJAXXObject);
-
- javaFile.addInterfaces(compiler.getExtraInterfaces());
- javaFile.setAbstractClass(compiler.isAbstractClass());
- javaFile.setGenericType(compiler.getGenericType());
- javaFile.setSuperGenericType(compiler.getSuperGenericType());
-
- for (CompiledObject object : compiler.getObjects().values()) {
- CompiledObjectDecorator decorator = object.getDecorator();
- decorator.finalizeCompiler(compiler, root, object, javaFile, packageName, className, fullClassName);
-
- /*if (!object.isOverride() && !(object instanceof ScriptInitializer)) {
- String id = object.getId();
- int access = id.startsWith("$") ? Modifier.PRIVATE : Modifier.PROTECTED;
- if (object == root) {
- javaFile.addField(new JavaField(access, fullClassName, id, "this"));
- } else {
- //TC -20081017 can have generic on compiled Object
- javaFile.addField(JavaField.newField(access, JAXXCompiler.getCanonicalName(object), id), object.isJavaBean());
- }
- }
-
- if (!compiler.inlineCreation(object) && object != root) {
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getCreationMethodName(), getCreationCode(compiler, object)));
- }*/
- }
-
- // DataBinding
- for (DataBinding dataBinding : compiler.getDataBindings()) {
- if (dataBinding.compile(true)) {
- compiler.getInitDataBindings().append("applyDataBinding(").append(TypeManager.getJavaCode(dataBinding.getId())).append(");").append(JAXXCompiler.getLineSeparator());
- }
- }
-
- if (superclassIsJAXXObject) {
- boolean hasBind = compiler.getApplyDataBinding().length() > 0;
- if (hasBind) {
- compiler.appendApplyDataBinding(" else {");
- compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
- compiler.appendApplyDataBinding(" ");
- }
- compiler.appendApplyDataBinding("super.applyDataBinding($binding);");
- compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
-
- if (hasBind) {
- compiler.appendApplyDataBinding(" return;");
- compiler.appendApplyDataBinding(JAXXCompiler.getLineSeparator());
- compiler.appendApplyDataBinding("}");
- }
-
-
- hasBind = compiler.getRemoveDataBinding().length() > 0;
- if (hasBind) {
- compiler.appendRemoveDataBinding(" else {");
- compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
- compiler.appendRemoveDataBinding(" ");
- }
- compiler.appendRemoveDataBinding("super.removeDataBinding($binding);");
- compiler.appendRemoveDataBinding(JAXXCompiler.getLineSeparator());
-
- if (hasBind) {
- compiler.appendRemoveDataBinding("}");
- }
- } else {
- javaFile.addInterface(JAXXCompiler.getCanonicalName(JAXXObject.class));
- }
- }
-
- @Override
- public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
-
- String fullClassName = javaFile.getClassName();
-
- String jaxxContextImplementorClass = compiler.getOptions().getJaxxContextImplementorClass();
- boolean superclassIsJAXXObject = javaFile.isSuperclassIsJAXXObject();
- if (!superclassIsJAXXObject) {
- // add logger
- if (compiler.getOptions().isAddLogger()) {
- javaFile.addImport(Log.class);
- javaFile.addImport(LogFactory.class);
- javaFile.addField(JavaField.newField(Modifier.PUBLIC + Modifier.STATIC + FINAL, "Log", "log", "LogFactory.getLog(" + fullClassName + ".class)"));
- }
-
- // JAXXObject
- javaFile.addField(OBJECT_MAP_FIELD);
- javaFile.addMethod(GET_OBJECT_BY_ID_METHOD);
- javaFile.addField(BINDING_SOURCES_FIELD);
- javaFile.addField(ACTIVE_BINDINGS_FIELD);
-
- // JAXXContext
- javaFile.addField(JavaField.newField(PROTECTED | FINAL, JAXXContext.class.getName(), "delegateContext", "new " + jaxxContextImplementorClass + "(this);"));
- javaFile.addMethod(SET_CONTEXT_VALUE_METHOD);
- javaFile.addMethod(SET_CONTEXT_VALUE_NAMED_METHOD);
- javaFile.addMethod(GET_CONTEXT_VALUE_METHOD);
- javaFile.addMethod(GET_CONTEXT_VALUE_NAMED_METHOD);
- javaFile.addMethod(REMOVE_CONTEXT_VALUE_METHOD);
- javaFile.addMethod(REMOVE_CONTEXT_VALUE_NAMED_METHOD);
- javaFile.addMethod(GET_PARENT_CONTAINER_METHOD);
- javaFile.addMethod(GET_PARENT_CONTAINER_MORE_METHOD);
-
- // PropertyChangeSupport
- addPropertyChangeSupport(root, javaFile);
-
- // DataBinding
- javaFile.addMethod(PROCESS_DATA_BINDING_METHOD);
- }
-
- javaFile.addField(ALL_COMPONENTS_CREATED_FIELD);
- boolean overrideContextInitialized = false;
- FieldDescriptor[] scriptFields = compiler.getScriptFields();
- for (FieldDescriptor f : scriptFields) {
- if ("contextInitialized".equals(f.getName())) {
- overrideContextInitialized = true;
- break;
- }
- }
- if (!overrideContextInitialized) {
- javaFile.addField(CONTEXT_INITIALIZED);
- }
- javaFile.addField(createJAXXObjectDescriptorField(compiler, javaFile));
-
- if (compiler.getStylesheet() != null) {
- javaFile.addField(PREVIOUS_VALUES_FIELD);
- }
- /*for (CompiledObject object : compiler.getObjects().values()) {
- List<CompiledObject.ChildRef> refList = object.getChilds();
- if (refList==null || refList.isEmpty()) {
- continue;
- }
- for (ChildRef childRef : refList) {
- childRef.addToAdditionCode(buffer);
- }
- }*/
- //TC 20090228 - only generate constructors if not done in scripts
- boolean constructorDetected = false;
- MethodDescriptor[] methods = compiler.getScriptMethods();
- for (MethodDescriptor m : methods) {
- try {
- m.getReturnType();
- if (className.equals(m.getName())) {
- constructorDetected = true;
- break;
- }
- } catch (Exception e) {
- log.warn("could not find return type " + m);
- }
- }
- if (!constructorDetected) {
- javaFile.addMethod(createConstructor(compiler, className, superclassIsJAXXObject));
- javaFile.addMethod(createConstructorWithInitialContext(compiler, className, superclassIsJAXXObject));
- }
-
- javaFile.addMethod(createInitializer(compiler));
- javaFile.addMethod(GET_JAXX_OBJECT_DESCRIPTOR_METHOD);
-
- javaFile.addBodyCode(compiler.getBodyCode().toString());
-
- javaFile.addMethod(createCompleteSetupMethod(compiler, javaFile, compiler.getInitDataBindings()));
-
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "applyDataBinding",
- compiler.getApplyDataBinding().toString() + JAXXCompiler.getLineSeparator() + "processDataBinding($binding);",
- new JavaArgument("String", "$binding")));
-
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", "removeDataBinding",
- compiler.getRemoveDataBinding().toString(), new JavaArgument("String", "$binding")));
-
- javaFile.addMethod(createProcessDataBindingMethod(compiler, superclassIsJAXXObject));
-
- addEventHandlers(compiler, javaFile);
-
- }
-
-
- /*---------------------------------------------------------------------------------*/
- /*-- Create fields ----------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
- protected JavaField createJAXXObjectDescriptorField(JAXXCompiler compiler, JavaFile javaFile) {
- try {
- JAXXObjectDescriptor descriptor = compiler.getJAXXObjectDescriptor();
- String data = Base64Coder.serialize(descriptor, true);
- /*ByteArrayOutputStream buffer = new ByteArrayOutputStream();
- ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(buffer));
- out.writeObject(descriptor);
- out.close();
- // the use of the weird deprecated constructor is deliberate -- we need to store the data as a String
- // in the compiled class file, since byte array initialization is horribly inefficient compared to
- // String initialization. So we store the bytes in the String, and we quite explicitly want a 1:1
- // mapping between bytes and chars, with the high byte of the char set to zero. We can then safely
- // reconstitute the original byte[] at a later date. This is unquestionably an abuse of the String
- // type, but if we could efficiently store a byte[] we wouldn't have to do this.
- String data = new String(buffer.toByteArray(), 0);*/
-
- int sizeLimit = 65000; // constant strings are limited to 64K, and I'm not brave enough to push right up to the limit
- if (data.length() < sizeLimit) {
- return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", TypeManager.getJavaCode(data));
- } else {
- StringBuffer initializer = new StringBuffer();
- for (int i = 0; i < data.length(); i += sizeLimit) {
- String name = "$jaxxObjectDescriptor" + i;
- javaFile.addField(new JavaField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", name,
- TypeManager.getJavaCode(data.substring(i, Math.min(i + sizeLimit, data.length())))));
- if (initializer.length() > 0) {
- initializer.append(" + ");
- }
- initializer.append("String.valueOf(").append(name).append(")");
- }
- return JavaField.newField(Modifier.PRIVATE | Modifier.STATIC, "java.lang.String", "$jaxxObjectDescriptor", initializer.toString());
- }
- } catch (IOException e) {
- throw new RuntimeException("Internal error: can't-happen error", e);
- }
- }
-
- /*---------------------------------------------------------------------------------*/
- /*-- Create methods ---------------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
- protected void addPropertyChangeSupport(CompiledObject root, JavaFile javaFile) {
- ClassDescriptor currentClass = root.getObjectClass();
- MethodDescriptor firePropertyChange = null;
- while (firePropertyChange == null && currentClass != null) {
- try {
- firePropertyChange = currentClass.getDeclaredMethodDescriptor("firePropertyChange", ClassDescriptorLoader.getClassDescriptor(String.class),
- ClassDescriptorLoader.getClassDescriptor(Object.class),
- ClassDescriptorLoader.getClassDescriptor(Object.class));
-
- } catch (NoSuchMethodException e) {
- currentClass = currentClass.getSuperclass();
- }
- }
-
- int modifiers = firePropertyChange != null ? firePropertyChange.getModifiers() : 0;
- if (Modifier.isPublic(modifiers)) {
- // we have all the support we need
- }
- if (Modifier.isProtected(modifiers)) {
- // there is property change support but the firePropertyChange method is protected
- javaFile.addMethod(FIRE_PROPERTY_CHANGE_METHOD);
- } else {
- // either no support at all or firePropertyChange isn't accessible
- javaFile.addField(PROPERTY_CHANGE_SUPPORT_FIELD);
- javaFile.addMethod(GET_PROPERTY_CHANGE_SUPPORT_METHOD);
- javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_METHOD);
- javaFile.addMethod(ADD_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
- javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_METHOD);
- javaFile.addMethod(REMOVE_PROPERTY_CHANGE_SUPPORT_NAMED_METHOD);
- javaFile.addMethod(FIRE_PROPERTY_CHANGE_NAMED_METHOD);
- }
- }
-
- protected void addEventHandlers(JAXXCompiler compiler, JavaFile javaFile) {
- for (Map.Entry<String, Map<ClassDescriptor, List<EventHandler>>> e1 : compiler.getEventHandlers().entrySet()) {
- // outer loop is iterating over different objects (well, technically, different Java expressions)
- for (Map.Entry<ClassDescriptor, List<EventHandler>> e2 : e1.getValue().entrySet()) {
- // iterate over different types of listeners for this particular object (MouseListener, ComponentListener, etc.)
- for (EventHandler handler : e2.getValue()) {
- // iterate over individual event handlers of a single type
- String methodName = compiler.getEventHandlerMethodName(handler);
- MethodDescriptor listenerMethod = handler.getListenerMethod();
- if (listenerMethod.getParameterTypes().length != 1) {
- throw new CompilerException("Expected event handler " + listenerMethod.getName() + " of class " + handler.getListenerClass() + " to have exactly one argument");
- }
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC, "void", methodName, handler.getJavaCode(),
- new JavaArgument(JAXXCompiler.getCanonicalName(listenerMethod.getParameterTypes()[0]), "event")));
- }
- }
- }
- }
-
- protected JavaMethod createConstructor(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
- StringBuffer code = new StringBuffer();
- String constructorParams = compiler.getRootObject().getConstructorParams();
- if (constructorParams != null) {
- code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
- } else {
- if (superclassIsJAXXObject) {
- code.append(" super();").append(JAXXCompiler.getLineSeparator());
- }
- }
- code.append("$initialize();");
- code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString());
- }
-
- protected JavaMethod createConstructorWithInitialContext(JAXXCompiler compiler, String className, boolean superclassIsJAXXObject) throws CompilerException {
- StringBuffer code = new StringBuffer();
- String constructorParams = compiler.getRootObject().getConstructorParams();
- if (constructorParams != null) {
- code.append(" super(").append(constructorParams).append(");").append(JAXXCompiler.getLineSeparator());
- } else {
- if (superclassIsJAXXObject) {
- code.append(" super(parentContext);").append(JAXXCompiler.getLineSeparator());
- }
- }
- if (!superclassIsJAXXObject) {
- code.append("if (parentContext instanceof jaxx.runtime.JAXXInitialContext) {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" ((jaxx.runtime.JAXXInitialContext)parentContext).to(this);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("} else {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" setContextValue(parentContext);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append("$initialize();");
- code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PUBLIC, null, className, code.toString(), new JavaArgument("jaxx.runtime.JAXXContext", "parentContext"));
- }
-
- public JavaMethod createInitializer(JAXXCompiler compiler) throws CompilerException {
- StringBuffer code = new StringBuffer();
- CompiledObject root = compiler.getRootObject();
- code.append("if (allComponentsCreated || !contextInitialized) {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" return;");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("$objectMap.put(").append(TypeManager.getJavaCode(root.getId())).append(", this);");
- code.append(JAXXCompiler.getLineSeparator());
-
- Iterator<CompiledObject> i = compiler.getObjectCreationOrder();
- boolean lastWasMethodCall = false;
- while (i.hasNext()) {
- CompiledObject object = i.next();
- if (object == root) {
- continue;
- }
- CompiledObjectDecorator decorator = object.getDecorator();
- lastWasMethodCall = decorator.createInitializer(compiler, root, object, code, lastWasMethodCall);
- /*if (object != root && !object.isOverride()) {
- if (compiler.inlineCreation(object)) {
- if (lastWasMethodCall) {
- lastWasMethodCall = false;
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append(getCreationCode(compiler, object));
- code.append(JAXXCompiler.getLineSeparator());
- } else {
- code.append(object.getCreationMethodName()).append("();");
- code.append(JAXXCompiler.getLineSeparator());
- lastWasMethodCall = true;
- }
- }*/
- }
- root.getDecorator().createInitializer(compiler, root, root, code, lastWasMethodCall);
- /*String rootCode = root.getInitializationCode(compiler);
- if (rootCode != null && rootCode.length() > 0) {
- code.append(rootCode);
- code.append(JAXXCompiler.getLineSeparator());
- }*/
- code.append(JAXXCompiler.getLineSeparator());
- if (compiler.getInitializer().length() > 0) {
- code.append(compiler.getInitializer());
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append("$completeSetup();");
- code.append(JAXXCompiler.getLineSeparator());
- return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$initialize", code.toString());
- }
-
- protected JavaMethod createCompleteSetupMethod(JAXXCompiler compiler, JavaFile javaFile, StringBuffer initDataBindings) {
- StringBuffer code = new StringBuffer();
- code.append("allComponentsCreated = true;");
- code.append(JAXXCompiler.getLineSeparator());
- for (CompiledObject object : compiler.getObjects().values()) {
- CompiledObjectDecorator decorator = object.getDecorator();
- code.append(decorator.createCompleteSetupMethod(compiler, object, javaFile, initDataBindings));
-
- /*//TC - 20081017 only generate the method if not empty ?
- if (object.getId().startsWith("$")) {
- code.append(object.getAdditionCode()).append(JAXXCompiler.getLineSeparator());
- } else {
- String additionCode = object.getAdditionCode();
- if (additionCode.length() > 0) {
- code.append(object.getAdditionMethodName()).append("();").append(JAXXCompiler.getLineSeparator());
- additionCode = "if (!allComponentsCreated) {" + JAXXCompiler.getLineSeparator() + " return;" + JAXXCompiler.getLineSeparator() + "}" + JAXXCompiler.getLineSeparator() + additionCode;
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PROTECTED, "void", object.getAdditionMethodName(), additionCode));
- }
- }*/
- //code.append(getLineSeparator());
- }
-
- code.append(initDataBindings);
-
- if (compiler.getLateInitializer().length() > 0) {
- code.append(compiler.getLateInitializer());
- code.append(JAXXCompiler.getLineSeparator());
- }
- //TC-20090313 add an extra method after complete setup
- MethodDescriptor method = compiler.getScriptMethod("$afterCompleteSetup");
- if (method != null) {
- code.append("$afterCompleteSetup();").append(JAXXCompiler.getLineSeparator());
- }
- return JavaMethod.newMethod(Modifier.PRIVATE, "void", "$completeSetup", code.toString());
- }
-
- protected JavaMethod createProcessDataBindingMethod(JAXXCompiler compiler, boolean superclassIsJAXXObject) {
- StringBuffer code = new StringBuffer();
- //boolean superclassIsJAXXObject = ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(compiler.getRootObject().getObjectClass());
- // the force parameter forces the update to happen even if it is already in activeBindings. This
- // is used on superclass invocations b/c by the time the call gets to the superclass, it is already
- // marked active and would otherwise be skipped
- if (compiler.getProcessDataBinding().length() > 0) {
- code.append(" if (!$force && $activeBindings.contains($dest)) { ");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" return;");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("$activeBindings.add($dest);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("try {");
- code.append(JAXXCompiler.getLineSeparator());
- if (compiler.getProcessDataBinding().length() > 0) {
- code.append(compiler.getProcessDataBinding().toString());
- //code.append(JAXXCompiler.getLineSeparator());
- }
- if (superclassIsJAXXObject) {
- code.append(" else {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" super.processDataBinding($dest, true);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" }");
- code.append(JAXXCompiler.getLineSeparator());
- }
- code.append("} finally {");
- code.append(JAXXCompiler.getLineSeparator());
- code.append(" $activeBindings.remove($dest);");
- code.append(JAXXCompiler.getLineSeparator());
- code.append("}");
- code.append(JAXXCompiler.getLineSeparator());
- } else if (superclassIsJAXXObject) {
- code.append("super.processDataBinding($dest, true);");
- code.append(JAXXCompiler.getLineSeparator());
- }
- return JavaMethod.newMethod(Modifier.PUBLIC, "void", "processDataBinding", code.toString(),
- new JavaArgument("String", "$dest"), new JavaArgument("boolean", "$force"));
- }
-
- /*---------------------------------------------------------------------------------*/
- /*-- Create methods code ----------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
-
- /* protected String getCreationCode(JAXXCompiler compiler, CompiledObject object) throws CompilerException {
- if (object instanceof ScriptInitializer) {
- return object.getInitializationCode(compiler);
- }
- CompiledObjectDecorator decorator = object.getDecorator();
- String result = decorator.getCreationCode(compiler, object);
- return result;*/
- /*StringBuffer result = new StringBuffer();
- result.append(object.getId());
- result.append(" = ");
- if (object.isJavaBean() && object.getJavaBeanInitCode() != null) {
- result.append(object.getJavaBeanInitCode()).append(";");
- } else {
- String constructorParams = object.getConstructorParams();
- if (constructorParams != null) {
- //TC - 20081017 compiledObject can have generics
- result.append(" new ").append(JAXXCompiler.getCanonicalName(object)).append("(").append(constructorParams).append(");");
- //result.append("(").append(getCanonicalName(object.getObjectClass())).append(") new ").append(getCanonicalName(object.getObjectClass())).append("(").append(constructorParams).append(");");
- } else {
- //TC - 20081017 compiledObject can have generics
- result.append("new ").append(JAXXCompiler.getCanonicalName(object)).append("();");
- }
- }
- result.append(JAXXCompiler.getLineSeparator());
- String initCode = object.getInitializationCode(compiler);
- if (initCode != null && initCode.length() > 0) {
- result.append(initCode);
- }
- result.append("$objectMap.put(").append(TypeManager.getJavaCode(object.getId())).append(", ").append(object.getId()).append(");");
-
- return result.toString();*/
-// }
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaArgument.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -10,11 +10,11 @@
* @see JavaMethod
*/
public class JavaArgument {
+
private String name;
private String type;
private boolean isFinal;
-
/**
* Creates a new <code>JavaArgument</code> with the specified name and type. For example, the method <code>main()</code>
* might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>.
@@ -26,7 +26,6 @@
this(type, name, false);
}
-
/**
* Creates a new <code>JavaArgument</code> with the specified name, type, and finality. For example, the method <code>main()</code>
* might have a <code>JavaArgument</code> with a name of <code>"arg"</code> and a type of <code>"java.lang.String[]"</code>. The
@@ -42,7 +41,6 @@
this.isFinal = isFinal;
}
-
/**
* Returns the argument's name.
*
@@ -52,7 +50,6 @@
return name;
}
-
/**
* Returns the argument's type as it would be represented in Java source code.
*
@@ -62,7 +59,6 @@
return type;
}
-
/**
* Returns <code>true</code> if the <code>final</code> keyword should appear before the argument.
*
@@ -72,7 +68,6 @@
return isFinal;
}
-
/**
* Returns the Java source code for this argument.
*
@@ -83,4 +78,4 @@
String result = type + ' ' + name;
return isFinal ? "final " + result : result;
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaField.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,7 +18,6 @@
private String name;
private String initializer;
-
/**
* Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the
* constants from {@link java.lang.reflect.Modifier}, and the <code>type</code> of the field should be
@@ -32,7 +31,6 @@
this(modifiers, type, name, null);
}
-
/**
* Constructs a new <code>JavaField</code>. The <code>modifiers</code> parameter is a bit mask of the
* constants from <code>java.lang.reflect.Modifier</code>, and the <code>type</code> of the field should be
@@ -52,7 +50,6 @@
this.initializer = initializer;
}
-
/**
* Returns a bit mask describing the modifier keywords which should appear as part of this field's
* declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this
@@ -64,7 +61,6 @@
return modifiers;
}
-
/**
* Returns the field's name.
*
@@ -74,7 +70,6 @@
return name;
}
-
/**
* Returns the field's type, as it would be represented in Java source code.
*
@@ -84,7 +79,6 @@
return type;
}
-
/**
* Returns the Java source code for this field.
*
@@ -102,12 +96,13 @@
return result.toString();
}
+ @Override
public int compareTo(JavaField o) {
return COMPARATOR.compare(this, o);
}
-
public static final Comparator<JavaField> COMPARATOR = new Comparator<JavaField>() {
+ @Override
public int compare(JavaField o1, JavaField o2) {
int result;
@@ -184,4 +179,4 @@
public static JavaField newField(int modifiers, String returnType, String name, String initializer) {
return new JavaField(modifiers, returnType, name, initializer);
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaFile.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,11 +20,8 @@
public class JavaFile {
protected static final String GETTER_PATTERN = "return %1$s;";
-
protected static final String BOOLEAN_GETTER_PATTERN = "return %1$s !=null && %1$s;";
-
protected static final String SETTER_PATTERN = "%1$s oldValue = this.%2$s;\nthis.%2$s = newValue;\nfirePropertyChange(\"%2$s\", oldValue, newValue);";
-
private int modifiers;
private String className;
private List<String> imports = new ArrayList<String>();
@@ -39,16 +36,13 @@
private String genericType;
private String superGenericType;
-
public JavaFile() {
}
-
public JavaFile(int modifiers, String className, String superClass) {
this(modifiers, className, superClass, null);
}
-
public JavaFile(int modifiers, String className, String superClass, List<String> interfaces) {
this.modifiers = modifiers;
this.className = className;
@@ -56,51 +50,42 @@
this.interfaces = interfaces;
}
-
public void addImport(String importString) {
imports.add(importString);
}
- public void addImport(Class importString) {
+ public void addImport(Class<?> importString) {
imports.add(importString.getName());
}
-
public String[] getImports() {
return imports.toArray(new String[imports.size()]);
}
-
public int getModifiers() {
return modifiers;
}
-
public void setModifiers(int modifiers) {
this.modifiers = modifiers;
}
-
public String getClassName() {
return className;
}
-
public void setClassName(String className) {
this.className = className;
}
-
public String getSuperClass() {
return superClass;
}
-
public void setSuperClass(String superClass) {
this.superClass = superClass;
}
-
public List<String> getInterfaces() {
if (interfaces == null) {
interfaces = new ArrayList<String>();
@@ -108,7 +93,6 @@
return interfaces;
}
-
public void setInterfaces(List<String> interfaces) {
this.interfaces = interfaces;
}
@@ -121,7 +105,6 @@
methods.add(method);
}
-
public JavaMethod[] getMethods() {
return methods.toArray(new JavaMethod[methods.size()]);
}
@@ -156,22 +139,18 @@
fields.add(field);
}
-
public JavaField[] getFields() {
return fields.toArray(new JavaField[fields.size()]);
}
-
public static String addIndentation(String source, int indentation, String lineSeparator) {
return indent(source, indentation, false, lineSeparator);
}
-
public static String setIndentation(String source, int indentation, String lineSeparator) {
return indent(source, indentation, true, lineSeparator);
}
-
public static String indent(String source, int indentation, boolean trim, String lineSeparator) {
if (trim) {
source = source.trim();
@@ -190,12 +169,10 @@
return result.toString();
}
-
public void addBodyCode(String bodyCode) {
rawBodyCode.append(bodyCode);
}
-
public String getClassBody(String lineSeparator) {
StringBuffer result = new StringBuffer();
if (fields.size() > 0) {
@@ -237,7 +214,6 @@
return result.toString();
}
-
public String getClassDefinition(String lineSeparator) {
StringBuffer result = new StringBuffer();
result.append(getModifiersText(modifiers));
@@ -258,7 +234,7 @@
result.append(" implements ").append(interfaces.get(0));
for (int i = 1; i < interfaces.size(); i++) {
/*if (i > 0) {
- result.append(", ");
+ result.append(", ");
}*/
result.append(", ").append(interfaces.get(i));
}
@@ -270,7 +246,6 @@
return result.toString();
}
-
public static String getModifiersText(int modifiers) {
if (modifiers == 0) {
return "";
@@ -279,7 +254,6 @@
}
}
-
/**
* Returns the Java source code for this class.
*
@@ -337,8 +311,7 @@
this.abstractClass = abstractClass;
}
-
public void setSuperGenericType(String superGenericType) {
this.superGenericType = superGenericType;
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/JavaMethod.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,6 +20,7 @@
* classes and have a return type of <code>null</code>.
*/
public class JavaMethod implements Comparable<JavaMethod> {
+
private int modifiers;
private String returnType;
private String name;
@@ -27,7 +28,6 @@
private String[] exceptions;
private StringBuffer bodyCode;
-
/**
* Constructs a new no-argument <code>JavaMethod</code> which throws no checked exceptions. The
* <code>modifiers</code> parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier},
@@ -42,8 +42,6 @@
//public JavaMethod(int modifiers, String returnType, String name) {
// this(modifiers, returnType, name, null);
//}
-
-
/**
* Constructs a new <code>JavaMethod</code> which throws no checked exceptions. The <code>modifiers</code>
* parameter is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the
@@ -59,8 +57,6 @@
//public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments) {
// this(modifiers, returnType, name, arguments, null);
//}
-
-
/**
* Constructs a new <code>JavaMethod</code>. The <code>modifiers</code> parameter is a bit mask of the
* constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and <code>exceptions</code>
@@ -77,8 +73,6 @@
//public JavaMethod(int modifiers, String returnType, String name, JavaArgument[] arguments, String[] exceptions) {
// this(modifiers, returnType, name, arguments, exceptions, null);
//}
-
-
/**
* Constructs a new <code>JavaMethod</code> containing the specified body code. The <code>modifiers</code> parameter
* is a bit mask of the constants from {@link java.lang.reflect.Modifier}, and the <code>returnType</code> and
@@ -101,7 +95,6 @@
this.bodyCode = new StringBuffer(bodyCode != null ? bodyCode : "");
}
-
/**
* Returns a bit mask describing the modifier keywords which should appear as part of this method's
* declaration. See <code>java.lang.reflect.Modifier</code> for more information on decoding this
@@ -113,7 +106,6 @@
return modifiers;
}
-
/**
* Returns the method's return type, as it would be represented in Java source code.
*
@@ -123,7 +115,6 @@
return returnType;
}
-
/**
* Returns the method's name.
*
@@ -133,7 +124,6 @@
return name;
}
-
/**
* Returns a list of the method's arguments.
*
@@ -143,7 +133,6 @@
return arguments;
}
-
/**
* Returns a list of exceptions the method can throw.
*
@@ -153,7 +142,6 @@
return exceptions;
}
-
/**
* Returns the Java source code for the method's body.
*
@@ -163,7 +151,6 @@
return bodyCode.toString();
}
-
/**
* Appends additional code to the method's body.
*
@@ -180,7 +167,6 @@
bodyCode.append(extraCode);
}
-
/**
* Returns the Java source code for this method.
*
@@ -217,6 +203,7 @@
return result.toString();
}
+ @Override
public int compareTo(JavaMethod o) {
return COMPARATOR.compare(this, o);
}
@@ -232,118 +219,125 @@
public enum MethodOrder {
statics(Modifier.STATIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Statics methods --------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Statics methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
},
-
constructors(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Constructors -----------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Constructors -----------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return method.returnType == null;
}
},
-
JAXXObject(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- JAXXObject implementation ----------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- JAXXObject implementation ----------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
private List<String> methods = Arrays.asList("applyDataBinding", "firePropertyChange", "getObjectById", "get$objectMap", "processDataBinding", "removeDataBinding");
+ @Override
public boolean accept(JavaMethod method) {
return methods.contains(method.name);
}
},
-
JAXXContext(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- JAXXContext implementation ---------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- JAXXContext implementation ---------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
private List<String> methods = Arrays.asList("getContextValue", "getDelegateContext", "getParentContainer", "removeContextValue", "setContextValue");
+
+ @Override
public boolean accept(JavaMethod method) {
return methods.contains(method.name);
}
},
-
JAXXValidation(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- JAXXValidation implementation ------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- JAXXValidation implementation ------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
private List<String> methods = Arrays.asList("getValidator", "getValidatorIds");
+ @Override
public boolean accept(JavaMethod method) {
return methods.contains(method.name);
}
},
-
events(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Event methods ----------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Event methods ----------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("do") && method.name.indexOf("__") > -1);
}
},
-
publicGetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- public acessor methods -------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- public acessor methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("get") || method.name.startsWith("is"));
}
},
-
publicSetters(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- public mutator methods -------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- public mutator methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("set"));
}
},
-
otherPublic(Modifier.PUBLIC, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- public mutator methods -------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- public mutator methods -------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
@Override
public boolean accept(int mod) {
return super.accept(mod) && !Modifier.isStatic(mod);
}
},
-
protectedGetters(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- protected acessors methods ---------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- protected acessors methods ---------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return (method.name.startsWith("get") || method.name.startsWith("is"));
}
},
-
createMethod(Modifier.PROTECTED | Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- ui creation methods ----------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- ui creation methods ----------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
+ @Override
public boolean accept(JavaMethod method) {
return method.name.startsWith("create") || method.name.startsWith("add") ||
method.name.equals("$completeSetup") ||
method.name.equals("$initialize");
}
},
-
protecteds(Modifier.PROTECTED, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Other protected methods ------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Other protected methods ------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
},
-
packageLocal(0, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Package methods --------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Package methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
+
@Override
public boolean accept(int mod) {
return !Modifier.isStatic(mod) && !Modifier.isPublic(mod) && !Modifier.isProtected(mod);
- }},
-
+ }
+ },
privates(Modifier.PRIVATE, "/*---------------------------------------------------------------------------------*/\n" +
- "/*-- Private methods --------------------------------------------------------------*/\n" +
- "/*---------------------------------------------------------------------------------*/") {
+ "/*-- Private methods --------------------------------------------------------------*/\n" +
+ "/*---------------------------------------------------------------------------------*/") {
};
-
private final String header;
-
private int modifier;
MethodOrder(int modifier, String header) {
@@ -436,20 +430,20 @@
}
return constants;
}
-
public static final Comparator<JavaMethod> COMPARATOR = new Comparator<JavaMethod>() {
+ @Override
public int compare(JavaMethod o1, JavaMethod o2) {
/*int result;
if ((result = compareStatic(o1, o2)) != 0) {
- return result;
+ return result;
}
if ((result = compareConstructor(o1, o2)) != 0) {
- return result;
+ return result;
}
if ((result = compareVisibility(o1, o2)) != 0) {
- return result;
+ return result;
}*/
return o1.name.compareTo(o2.name);
}
@@ -496,4 +490,4 @@
return 0;
}
};
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,7 +4,7 @@
*/
package jaxx.compiler;
-import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
/**
* A dummy CompiledObject which serves to initialize scripted field. This is handled by
@@ -12,9 +12,10 @@
* ensure that the field is initialized in document order.
*/
public class ScriptInitializer extends CompiledObject {
- public ScriptInitializer(String initializer, JAXXCompiler compiler) {
+
+ public ScriptInitializer(String initializer, JAXXCompiler compiler) {
super(compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class)),
ClassDescriptorLoader.getClassDescriptor(ScriptInitializer.class), compiler, false);
appendInitializationCode(initializer);
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ScriptManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,12 +1,11 @@
package jaxx.compiler;
-import jaxx.CompilerException;
-import jaxx.parser.JavaParser;
-import jaxx.parser.JavaParserTreeConstants;
-import jaxx.parser.SimpleNode;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
-import jaxx.tags.TagManager;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.TagManager;
import java.io.StringReader;
import java.lang.reflect.Modifier;
@@ -15,14 +14,13 @@
import java.util.List;
public class ScriptManager {
+
private JAXXCompiler compiler;
-
ScriptManager(JAXXCompiler compiler) {
this.compiler = compiler;
}
-
/**
* Strips unnecessary curly braces from around the script, generating a warning if they are found.
*
@@ -38,7 +36,6 @@
return script;
}
-
public void checkParse(String script) throws CompilerException {
script = trimScript(script);
JavaParser p = new JavaParser(new StringReader(script));
@@ -47,7 +44,6 @@
}
}
-
public String preprocessScript(String script) throws CompilerException {
script = trimScript(script);
StringBuffer result = new StringBuffer();
@@ -63,7 +59,6 @@
return result.toString();
}
-
/**
* Scans through a compound symbol (foo.bar.baz) to identify and compile the JAXX class it refers to, if any.
*
@@ -73,8 +68,9 @@
String[] tokens = symbol.split("\\.");
StringBuffer currentSymbol = new StringBuffer();
for (String token : tokens) {
- if (currentSymbol.length() > 0)
+ if (currentSymbol.length() > 0) {
currentSymbol.append('.');
+ }
currentSymbol.append(token.trim());
String contextClass = TagManager.resolveClassName(currentSymbol.toString(), compiler);
@@ -84,17 +80,17 @@
}
}
-
private void preprocessScriptNode(SimpleNode node, boolean staticContext) throws CompilerException {
// identify static methods and initializers -- we can't fire events statically
if (node.getId() == JavaParserTreeConstants.JJTMETHODDECLARATION) {
if (node.getParent().getChild(0).getText().indexOf("static") != -1) {
staticContext = true;
}
- } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER)
+ } else if (node.getId() == JavaParserTreeConstants.JJTINITIALIZER) {
if (node.getText().trim().startsWith("static")) {
staticContext = true;
}
+ }
int count = node.jjtGetNumChildren();
for (int i = 0; i < count; i++) {
@@ -109,9 +105,7 @@
String lhs = null;
if (id == JavaParserTreeConstants.JJTASSIGNMENTEXPRESSION || (id == JavaParserTreeConstants.JJTPOSTFIXEXPRESSION && node.jjtGetNumChildren() == 2)) {
lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim();
- }
- else
- if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) {
+ } else if (id == JavaParserTreeConstants.JJTPREINCREMENTEXPRESSION || id == JavaParserTreeConstants.JJTPREDECREMENTEXPRESSION) {
lhs = ((SimpleNode) node.jjtGetChild(0)).getText().trim();
}
if (lhs != null) {
@@ -128,7 +122,6 @@
}
}
-
/**
* Examines a Line to determine its real type. As all tokens returned by the parser are Lines, and
* they are just a tiny wrapper around the real node, this method strips off the wrapper layers to identify
@@ -144,8 +137,7 @@
if (node.jjtGetNumChildren() == 1) {
return node.getChild(0).getId();
}
- } else
- if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) {
+ } else if (node.getId() == JavaParserTreeConstants.JJTCLASSORINTERFACEBODYDECLARATION) {
int id = node.getChild(0).getId();
if (id == JavaParserTreeConstants.JJTMODIFIERS) {
return node.getChild(1).getId();
@@ -159,7 +151,6 @@
return JavaParserTreeConstants.JJTLINE; // generic value implying that it's okay to put into the initializer block
}
-
private SimpleNode findExplicitConstructorInvocation(SimpleNode parent) {
if (parent.getId() == JavaParserTreeConstants.JJTEXPLICITCONSTRUCTORINVOCATION) {
return parent;
@@ -175,32 +166,28 @@
return null;
}
-
private void processConstructor(String modifiers, SimpleNode node) {
assert node.getId() == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION : "expected node to be ConstructorDeclaration, found " + JavaParserTreeConstants.jjtNodeName[node.getId()] + " instead";
assert node.getChild(0).getId() == JavaParserTreeConstants.JJTFORMALPARAMETERS : "expected node 0 to be FormalParameters, found " + JavaParserTreeConstants.jjtNodeName[node.getChild(1).getId()] + " instead";
String code = "";
if (node.getChild(0).jjtGetNumChildren() == 0) {
compiler.reportError("The default no-argument constructor may not be redefined");
- }
- else {
+ } else {
SimpleNode explicitConstructorInvocation = findExplicitConstructorInvocation(node);
if (explicitConstructorInvocation == null || explicitConstructorInvocation.getText().trim().startsWith("super(")) {
code = "$initialize();" + JAXXCompiler.getLineSeparator();
if (explicitConstructorInvocation == null) {
node.getChild(1).firstToken.image = node.getChild(1).firstToken.image;
- }
- else {
+ } else {
explicitConstructorInvocation.lastToken.image += code;
}
}
}
- compiler.appendBodyCode(modifiers + " "+ node.getText().substring(0,node.getText().length()-1) + code + "}");
+ compiler.appendBodyCode(modifiers + " " + node.getText().substring(0, node.getText().length() - 1) + code + "}");
//compiler.bodyCode.append(";\n");
}
-
private void scanScriptNode(SimpleNode node) throws CompilerException {
int nodeType = getLineType(node);
if (nodeType == JavaParserTreeConstants.JJTIMPORTDECLARATION) { // have to handle imports early so the preprocessing takes them into account
@@ -234,13 +221,11 @@
// FIXME: this check fails for inner classes defined in this file
//if (returnType == null)
// throw new CompilerException("could not find class '" + rawReturnType + "'");
- } else
- if (type == JavaParserTreeConstants.JJTMETHODDECLARATOR) {
+ } 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++)
- {
+ 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);
@@ -255,26 +240,23 @@
compiler.appendBodyCode(node.getText());
//compiler.bodyCode.append(";\n");
compiler.addScriptMethod(new MethodDescriptor(name, Modifier.PUBLIC, returnType, parameterTypes.toArray(new String[parameterTypes.size()]), compiler.getClassLoader()));
- } else
- if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION ||
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION ||
nodeType == JavaParserTreeConstants.JJTINITIALIZER) {
String str = node.getText().trim();
if (str.endsWith(";")) {
- str+=";";
+ str += ";";
}
compiler.appendBodyCode(str);
//compiler.bodyCode.append(";\n");
- } else
- if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) {
+ } else if (nodeType == JavaParserTreeConstants.JJTCONSTRUCTORDECLARATION) {
processConstructor(node.getChild(0).getChild(0).getText(), node.getChild(0).getChild(1));
- } else
- if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) {
+ } else if (nodeType == JavaParserTreeConstants.JJTLOCALVARIABLEDECLARATION || nodeType == JavaParserTreeConstants.JJTFIELDDECLARATION) {
// the "local" variable declarations in this expression aren't actually local -- they are flagged local
// just because there isn't an enclosing class scope visible to the parser. "Real" local variable
// declarations won't show up here, because they will be buried inside of methods.
String text = node.getText().trim();
if (!text.endsWith(";")) {
- text+=";";
+ text += ";";
}
String declaration = text;
int equals = text.indexOf("=");
@@ -301,6 +283,8 @@
}
final String finalInitializer = name + " = " + initializer;
compiler.registerInitializer(new Runnable() {
+
+ @Override
public void run() {
compiler.registerCompiledObject(new ScriptInitializer(finalInitializer, compiler));
}
@@ -322,7 +306,6 @@
}
}
-
public void registerScript(String script) throws CompilerException {
JavaParser p = new JavaParser(new StringReader(script));
//JavaParser p = new JavaParser(new StringReader(script + ";"));
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/StylesheetHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,559 @@
+package jaxx.compiler;
+
+import jaxx.runtime.css.Selector;
+import jaxx.runtime.css.Rule;
+import jaxx.runtime.css.Stylesheet;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.types.TypeManager;
+
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A helper class to compute {@link Stylesheet}, {@link Rule} and {@link Selector}
+ * and extract all the compiler logic from this class.
+ * <p/>
+ * In that way we can make the compiler as a single module and a runtime as another module.
+ *
+ * @author chemit
+ */
+public class StylesheetHelper {
+
+ public static void applyTo(CompiledObject object, JAXXCompiler compiler, Stylesheet stylesheet, Stylesheet overrides) throws CompilerException {
+ Map<String, String> overriddenProperties;
+ if (overrides != null) {
+ overriddenProperties = getApplicableProperties(overrides, object);
+ //overriddenProperties = overrides.getApplicableProperties(s,object);
+ } else {
+ overriddenProperties = null;
+ }
+
+ Map<String, String> properties = getApplicableProperties(stylesheet, object);
+ if (properties != null) {
+ if (overriddenProperties != null) {
+ properties.keySet().removeAll(overriddenProperties.keySet());
+ }
+ DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass());
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ String value = e.getValue();
+ if (value.equals(Rule.INLINE_ATTRIBUTE) || value.equals(Rule.DATA_BINDING)) {
+ continue;
+ }
+ handler.setAttribute(object, e.getKey(), e.getValue(), false, compiler);
+ }
+ }
+
+ Rule[] pseudoClasses = getApplicablePseudoClasses(stylesheet, object);
+ if (pseudoClasses != null) {
+ Map<String, Map<String, String>> combinedPseudoClasses = new LinkedHashMap<String, Map<String, String>>();
+ for (Rule pseudoClass1 : pseudoClasses) {
+ Selector[] selectors = pseudoClass1.getSelectors();
+ for (Selector selector : selectors) {
+ if (appliesTo(selector, object) == Selector.PSEUDOCLASS_APPLIES) {
+ properties = pseudoClass1.getProperties();
+ String pseudoClass = selector.getPseudoClass();
+ // TODO: overrides by downstream pseudoclasses are not handled
+ Map<String, String> combinedProperties = combinedPseudoClasses.get(pseudoClass);
+ if (combinedProperties == null) {
+ combinedProperties = new HashMap<String, String>();
+ combinedPseudoClasses.put(pseudoClass, combinedProperties);
+ }
+ combinedProperties.putAll(properties);
+ }
+ }
+ }
+
+ int count = 0;
+ for (Map.Entry<String, Map<String, String>> e : combinedPseudoClasses.entrySet()) {
+ applyPseudoClass(e.getKey(), e.getValue(), object, compiler, count++);
+ }
+ }
+ }
+
+ /**
+ * Replaces all references to the variable "object" with the actual object ID.
+ *
+ * @param code ?
+ * @param id ?
+ * @return ?
+ * @throws CompilerException ?
+ */
+ public static String replaceObjectReferences(String code, String id) throws CompilerException {
+ JavaParser p = new JavaParser(new StringReader(code + ";"));
+ p.Expression();
+ jaxx.compiler.parser.java.SimpleNode node = p.popNode();
+ scanNode(node, id);
+ return node.getText();
+ }
+
+ public static void scanNode(SimpleNode node, String id) {
+ if (node.getId() == JavaParserTreeConstants.JJTNAME) {
+ String name = node.getText();
+ if (name.equals("object") || (name.indexOf(".") != -1 && name.substring(0, name.indexOf(".")).trim().equals("object"))) {
+ node.firstToken.image = id;
+ }
+ } else {
+ int count = node.jjtGetNumChildren();
+ for (int i = 0; i < count; i++) {
+ scanNode(node.getChild(i), id);
+ }
+ }
+ }
+
+ public static void compilePseudoClassAdd(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException {
+
+ if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".add";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { " + propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");");
+ return;
+ }
+
+ MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass);
+
+ String property = null;
+ switch (constant) {
+ case mousedown:
+ property = "mousePressed";
+ break;
+ case mouseout:
+ property = "mouseExited";
+ break;
+ case mouseover:
+ property = "mouseEntered";
+ break;
+ case mouseup:
+ property = "mouseReleased";
+ break;
+ }
+
+ ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class);
+ ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class);
+
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor);
+ MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor);
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener, methodDescriptor, propertyCode, compiler);
+
+ } catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+
+ /*if (pseudoClass.equals("mouseover")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseEntered",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseout")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseExited",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ compiler.appendInitDataBindings("{" + propertyCode + "}");
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseout pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mousedown")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mousePressed",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mousedown pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseup")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".add", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseReleased",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ compiler.appendInitDataBindings("{" + propertyCode + "}");
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseup pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".add";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + pseudoClass + ") { "+ propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding("+ destCode + ");");
+ } else
+ throw new IllegalArgumentException("unrecognized pseudoclass: " + pseudoClass);*/
+ }
+
+ public static void compilePseudoClassRemove(String pseudoClass, CompiledObject object, String propertyCode, JAXXCompiler compiler) throws CompilerException {
+ if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".remove";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");");
+ return;
+ }
+
+ MouseEventEnum constant = MouseEventEnum.valueOf(pseudoClass);
+
+ String property = null;
+ switch (constant) {
+ case mousedown:
+ property = "mousePressed";
+ break;
+ case mouseout:
+ property = "mouseReleased";
+ break;
+ case mouseover:
+ property = "mouseExited";
+ break;
+ case mouseup:
+ property = "mousePressed";
+ break;
+ }
+
+ ClassDescriptor mouseListenerDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseListener.class);
+ ClassDescriptor mouseEventDescriptor = ClassDescriptorLoader.getClassDescriptor(MouseEvent.class);
+
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener", mouseListenerDescriptor);
+ MethodDescriptor methodDescriptor = mouseListenerDescriptor.getMethodDescriptor(property, mouseEventDescriptor);
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener, methodDescriptor, propertyCode, compiler);
+
+ } catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+
+ /*if (pseudoClass.equals("mouseover")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseExited",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseover pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseout")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseEntered",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseout pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mousedown")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mouseReleased",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mousedown pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.equals("mouseup")) {
+ try {
+ MethodDescriptor addMouseListener = object.getObjectClass().getMethodDescriptor("addMouseListener",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseListener.class)});
+ object.addEventHandler("style." + pseudoClass + ".remove", addMouseListener,
+ ClassDescriptorLoader.getClassDescriptor(MouseListener.class).getMethodDescriptor("mousePressed",
+ new ClassDescriptor[]{ClassDescriptorLoader.getClassDescriptor(MouseEvent.class)}),
+ propertyCode, compiler);
+ }
+ catch (NoSuchMethodException e) {
+ compiler.reportError("mouseup pseudoclass cannot be applied to object " + object.getObjectClass().getName() + " (no addMouseListener method)");
+ }
+ } else if (pseudoClass.startsWith("{")) {
+ pseudoClass = pseudoClass.substring(1, pseudoClass.length() - 1).trim();
+ pseudoClass = replaceObjectReferences(pseudoClass, object.getJavaCode());
+ String dest = object.getId() + ".style." + pseudoClass + ".remove";
+ String destCode = TypeManager.getJavaCode(dest);
+ if (compiler.haveProcessDataBinding()) {
+ compiler.appendProcessDataBinding("else ");
+ }
+ compiler.appendProcessDataBinding("if ($dest.equals(" + destCode + ")) { if (" + invert(pseudoClass) + ") { " + propertyCode + "} }");
+ new DataSource(dest, pseudoClass, compiler).compile("new jaxx.runtime.DataBindingListener(" + compiler.getRootObject().getJavaCode() + ", " + destCode + ")");
+ compiler.appendInitDataBindings("applyDataBinding(" + destCode + ");");
+ } else {
+ throw new IllegalArgumentException("unrecognized pseudoclass: " + pseudoClass);
+ }*/
+ }
+
+ public static String invert(String javaCode) {
+ javaCode = javaCode.trim();
+ return javaCode.startsWith("!") ? javaCode.substring(1) : "!(" + javaCode + ")";
+ }
+
+ public static String unwrap(ClassDescriptor type, String valueCode) {
+ if (type == ClassDescriptorLoader.getClassDescriptor(boolean.class)) {
+ return "((java.lang.Boolean) " + valueCode + ").booleanValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(byte.class)) {
+ return "((java.lang.Byte) " + valueCode + ").byteValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(short.class)) {
+ return "((java.lang.Short) " + valueCode + ").shortValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(int.class)) {
+ return "((java.lang.Integer) " + valueCode + ").intValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(long.class)) {
+ return "((java.lang.Long) " + valueCode + ").longValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(float.class)) {
+ return "((java.lang.Float) " + valueCode + ").floatValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(double.class)) {
+ return "((java.lang.Double) " + valueCode + ").doubleValue()";
+ } else if (type == ClassDescriptorLoader.getClassDescriptor(char.class)) {
+ return "((java.lang.Character) " + valueCode + ").charValue()";
+ } else {
+ return valueCode;
+ }
+ }
+
+ public static void applyPseudoClass(String pseudoClass, Map<String, String> properties,
+ CompiledObject object, JAXXCompiler compiler, int priority) throws CompilerException {
+ if (pseudoClass.indexOf("[") != -1) {
+ pseudoClass = pseudoClass.substring(0, pseudoClass.indexOf("["));
+ }
+ final StringBuffer buffer = new StringBuffer();
+ /*CompiledObject bufferObject = new CompiledObject(object.getId(), object.getJavaCode(), object.getObjectClass(), compiler, true) {
+ public void appendInitializationCode(String code) {
+ buffer.append(code);
+ }
+ public void registerDataBinding(String src, String property, String assignment, JAXXCompiler compiler) throws CompilerException {
+ buffer.append(assignment);
+ }
+ };*/
+
+ DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass());
+ boolean valueDeclared = false;
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ String property = e.getKey();
+ ClassDescriptor type = handler.getPropertyType(object, property, compiler);
+ String dataBinding = compiler.processDataBindings(e.getValue(), type);
+ String valueCode;
+ if (dataBinding != null) {
+ valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")";
+ new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(),
+ property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler), compiler).compile(false);
+ } else {
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass));
+ } catch (ClassNotFoundException ex) {
+ compiler.reportError("could not find class " + type.getName());
+ return;
+ }
+ }
+ if (!valueDeclared) {
+ buffer.append("java.lang.Object ");
+ valueDeclared = true;
+ }
+ buffer.append("value = jaxx.runtime.css.Pseudoclasses.applyProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(JAXXCompiler.getLineSeparator());
+ buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(JAXXCompiler.getLineSeparator());
+ String unwrappedValue = unwrap(type, "value");
+ buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) +
+ ") " + unwrappedValue, compiler)).append(JAXXCompiler.getLineSeparator());
+ buffer.append("}").append(JAXXCompiler.getLineSeparator());
+ }
+
+ if (pseudoClass.equals("focused")) {
+ pseudoClass = "{ object.hasFocus() }";
+ } else if (pseudoClass.equals("unfocused")) {
+ pseudoClass = "{ !object.hasFocus() }";
+ } else if (pseudoClass.equals("enabled")) {
+ pseudoClass = "{ object.isEnabled() }";
+ } else if (pseudoClass.equals("disabled")) {
+ pseudoClass = "{ !object.isEnabled() }";
+ } else if (pseudoClass.equals("selected")) {
+ pseudoClass = "{ object.isSelected() }";
+ } else if (pseudoClass.equals("deselected")) {
+ pseudoClass = "{ !object.isSelected() }";
+ }
+
+ compilePseudoClassAdd(pseudoClass, object, buffer.toString(), compiler);
+
+ buffer.setLength(0);
+ valueDeclared = false;
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ String property = e.getKey();
+ ClassDescriptor type = handler.getPropertyType(object, property, compiler);
+ String dataBinding = compiler.processDataBindings(e.getValue(), type);
+ String valueCode;
+ if (dataBinding != null) {
+ valueCode = "new jaxx.runtime.css.DataBinding(" + TypeManager.getJavaCode(object.getId() + "." + property + "." + priority) + ")";
+ new DataBinding(dataBinding, object.getId() + "." + property + "." + priority, handler.getSetPropertyCode(object.getJavaCode(),
+ property, "(" + JAXXCompiler.getCanonicalName(type) + ") " + dataBinding, compiler), compiler).compile(false);
+ } else {
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ valueCode = TypeManager.getJavaCode(TypeManager.convertFromString(e.getValue(), typeClass));
+ } catch (ClassNotFoundException ex) {
+ compiler.reportError("could not find class " + type.getName());
+ return;
+ }
+ }
+ if (!valueDeclared) {
+ buffer.append("java.lang.Object ");
+ valueDeclared = true;
+ }
+ buffer.append("value = jaxx.runtime.css.Pseudoclasses.removeProperty(").append(compiler.getOutputClassName()).append(".this, ").append(object.getJavaCode()).append(", ").append(TypeManager.getJavaCode(property)).append(", ").append(valueCode).append(", jaxx.runtime.css.Pseudoclasses.wrap(").append(handler.getGetPropertyCode(object.getJavaCode(), property, compiler)).append("), ").append(priority).append(");").append(JAXXCompiler.getLineSeparator());
+ buffer.append("if (!(value instanceof jaxx.runtime.css.DataBinding)) {").append(JAXXCompiler.getLineSeparator());
+ String unwrappedValue = unwrap(type, "value");
+ buffer.append(" ").append(handler.getSetPropertyCode(object.getJavaCode(), property, "(" + JAXXCompiler.getCanonicalName(type) +
+ ") " + unwrappedValue, compiler)).append(JAXXCompiler.getLineSeparator());
+ buffer.append("}").append(JAXXCompiler.getLineSeparator());
+ }
+ compilePseudoClassRemove(pseudoClass, object, buffer.toString(), compiler);
+ }
+
+ public static Map<String, String> getApplicableProperties(Stylesheet s, CompiledObject object) throws CompilerException {
+ DefaultObjectHandler handler = TagManager.getTagHandler(object.getObjectClass());
+ Map<String, String> result = null;
+ for (Rule rule : s.getRules()) {
+ int apply = appliesTo(rule, object);
+ if (apply == Selector.ALWAYS_APPLIES || apply == Selector.ALWAYS_APPLIES_INHERIT_ONLY) {
+ if (result == null) {
+ result = new HashMap<String, String>();
+ }
+ for (Map.Entry<String, String> entry : rule.getProperties().entrySet()) {
+ String property = entry.getKey();
+ if (apply == Selector.ALWAYS_APPLIES || handler.isPropertyInherited(property)) {
+ result.put(property, entry.getValue());
+ }
+ }
+ }
+ }
+ return result;
+ }
+
+ public static Rule[] getApplicablePseudoClasses(Stylesheet s, CompiledObject object) throws CompilerException {
+ List<Rule> result = null;
+ for (Rule rule : s.getRules()) {
+ if (appliesTo(rule, object) == Selector.PSEUDOCLASS_APPLIES) {
+ if (result == null) {
+ result = new ArrayList<Rule>();
+ }
+ result.add(rule);
+ }
+ }
+ return result != null ? result.toArray(new Rule[result.size()]) : null;
+ }
+
+ public static Rule inlineAttribute(CompiledObject object, String propertyName, boolean dataBinding) {
+ Map<String, String> properties = new HashMap<String, String>();
+ properties.put(propertyName, dataBinding ? Rule.DATA_BINDING : Rule.INLINE_ATTRIBUTE);
+ return new Rule(new Selector[]{new Selector(null, null, null, object.getId(), true)}, properties);
+ }
+
+ public static int appliesTo(Rule rule, CompiledObject object) throws CompilerException {
+ int appliesTo = Selector.NEVER_APPLIES;
+ for (Selector selector : rule.getSelectors()) {
+ appliesTo = Math.max(appliesTo(selector, object), appliesTo);
+ if (appliesTo == Selector.ALWAYS_APPLIES || appliesTo == Selector.ALWAYS_APPLIES_INHERIT_ONLY) {
+ break;
+ }
+ }
+ return appliesTo;
+ }
+
+ public static int appliesTo(Selector selector, CompiledObject object) {
+ boolean inheritOnly = false;
+ CompiledObject parent = object;
+ String javaClassName = selector.getJavaClassName();
+ String styleClass = selector.getStyleClass();
+ String pseudoClass = selector.getPseudoClass();
+ String id = selector.getId();
+
+ while (parent != null) {
+ boolean classMatch = (javaClassName == null);
+ if (!classMatch) {
+ ClassDescriptor javaClass = parent.getObjectClass();
+ do {
+ String name = javaClass.getName();
+ if (name.equals(javaClassName) || name.substring(name.lastIndexOf(".") + 1).equals(javaClassName)) {
+ classMatch = true;
+ break;
+ }
+ javaClass = javaClass.getSuperclass();
+ } while (javaClass != null);
+ }
+
+ boolean styleClassMatch = (styleClass == null || styleClass.equals(parent.getStyleClass()));
+
+ String objectId = parent.getId();
+ objectId = objectId.substring(objectId.lastIndexOf(".") + 1);
+ boolean idMatch = (id == null || (' ' + objectId + ' ').indexOf(' ' + id + ' ') > -1);
+
+ if (classMatch && styleClassMatch && idMatch) {
+ if (pseudoClass != null) {
+ return inheritOnly ? Selector.PSEUDOCLASS_APPLIES_INHERIT_ONLY : Selector.PSEUDOCLASS_APPLIES;
+ } else {
+ return inheritOnly ? Selector.ALWAYS_APPLIES_INHERIT_ONLY : Selector.ALWAYS_APPLIES;
+ }
+ }
+
+ parent = parent.getParent();
+ inheritOnly = true;
+ }
+ return Selector.NEVER_APPLIES;
+ }
+
+ public enum MouseEventEnum {
+
+ mouseover,
+ mouseout,
+ mousedown,
+ mouseup
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/StylesheetHelper.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingCompiler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,73 +0,0 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
-package jaxx.compiler;
-
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.DefaultObjectHandler;
-
-import java.io.File;
-
-/**
- * Swing JAXX compiler.
- * <p/>
- * todo finish javadoc
- */
-public class SwingCompiler extends JAXXCompiler {
-
- /*---------------------------------------------------------------------------------*/
- /*-- Constructor methods ----------------------------------------------------------*/
- /*---------------------------------------------------------------------------------*/
-
- public SwingCompiler(ClassLoader classLoader) {
- super(classLoader,
- new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)),
- "java.awt.*",
- "java.awt.event.*",
- "java.beans.*",
- "java.io.*",
- "java.lang.*",
- "java.util.*",
- "javax.swing.*",
- "javax.swing.border.*",
- "javax.swing.event.*",
- "jaxx.runtime.swing.JAXXButtonGroup",
- "jaxx.runtime.swing.HBox",
- "jaxx.runtime.swing.VBox",
- "jaxx.runtime.swing.Table",
- "static org.nuiton.i18n.I18n._",
- "static jaxx.runtime.Util.createImageIcon");
-
-
- }
-
- /**
- * Creates a new SwingCompiler.
- *
- * @param baseDir classpath location
- * @param options options to pass to javac
- * @param src location of file to compile
- * @param outputClassName the out file name
- */
- public SwingCompiler(File baseDir, File src, String outputClassName, CompilerOptions options) {
- super(baseDir, src, outputClassName, options,
- new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(Object.class)),
- "java.awt.*",
- "java.awt.event.*",
- "java.beans.*",
- "java.io.*",
- "java.lang.*",
- "java.util.*",
- "javax.swing.*",
- "javax.swing.border.*",
- "javax.swing.event.*",
- "jaxx.runtime.swing.JAXXButtonGroup",
- "jaxx.runtime.swing.HBox",
- "jaxx.runtime.swing.VBox",
- "jaxx.runtime.swing.Table",
- "static org.nuiton.i18n.I18n._",
- "static jaxx.runtime.Util.createImageIcon");
- }
-
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SwingGenerator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,26 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.reflect.ClassDescriptorLoader;
-
-import java.lang.reflect.Modifier;
-
-/** @author chemit */
-public class SwingGenerator implements Generator {
- @Override
- public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
-
- }
-
- @Override
- public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
-
- //TODO : move this to jaxx-compiler-swing generator
- if (ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Application").isAssignableFrom(root.getObjectClass()) && !compiler.isMainDeclared()) {
- // TODO: check for existing main method first
- javaFile.addMethod(JavaMethod.newMethod(Modifier.PUBLIC | Modifier.STATIC, "void", "main",
- "SwingUtilities.invokeLater(new Runnable() { public void run() { new " + className + "().setVisible(true); } });",
- new JavaArgument("String[]", "arg"))
- );
- }
- }
-}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/SymbolTable.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,7 +1,7 @@
package jaxx.compiler;
-import jaxx.reflect.FieldDescriptor;
-import jaxx.reflect.MethodDescriptor;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
import java.util.ArrayList;
import java.util.HashMap;
@@ -12,27 +12,21 @@
public class SymbolTable {
private String superclass;
-
// maps ID strings to class names -- we can't map directly to CompiledObjects, because we
// can't create those until after the first pass
private Map<String, String> ids = new HashMap<String, String>();
-
private List<FieldDescriptor> scriptFields = new ArrayList<FieldDescriptor>();
-
private List<MethodDescriptor> scriptMethods = new ArrayList<MethodDescriptor>();
-
/** @return the fully-qualified name of the superclass of the class described by this symbol table. */
public String getSuperclassName() {
return superclass;
}
-
public void setSuperclassName(String superclass) {
this.superclass = superclass;
}
-
/**
* @return a map of IDs to class names. Each entry in the map corresponds to a class tag with an
* <code>id</code> attribute. The <code>id</code> is the key, and the fully-qualified class name
@@ -42,15 +36,13 @@
return ids;
}
-
/** @return a list of <code>FieldDescriptors</code> for fields defined in <script> tags. */
public List<FieldDescriptor> getScriptFields() {
return scriptFields;
}
-
/** @return a list of <code>MethodDescriptors</code> for methods defined in <script> tags. */
public List<MethodDescriptor> getScriptMethods() {
return scriptMethods;
}
-}
\ No newline at end of file
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedAttributeException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,47 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+/**
+ * Thrown by <code>TagHandler</code> when an unsupported attribute is encountered.
+ *
+ * @see jaxx.tags.TagHandler
+ */
+public class UnsupportedAttributeException extends CompilerException {
+
+ private static final long serialVersionUID = -6919583037172920343L;
+
+ /** Creates a new <code>UnsupportedAttributeException</code>. */
+ public UnsupportedAttributeException() {
+ }
+
+ /**
+ * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message.
+ *
+ * @param msg the exception's detail message
+ */
+ public UnsupportedAttributeException(String msg) {
+ super(msg);
+ }
+
+ /**
+ * Creates a new <code>UnsupportedAttributeException</code> with the specified cause.
+ *
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedAttributeException(Throwable initCause) {
+ super(initCause);
+ }
+
+ /**
+ * Creates a new <code>UnsupportedAttributeException</code> with the specified detail message and cause.
+ *
+ * @param msg the exception's detail message
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedAttributeException(String msg, Throwable initCause) {
+ super(msg, initCause);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedAttributeException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/UnsupportedTagException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler;
+
+/** Thrown by the compiler when an unregistered tag is encountered. */
+public class UnsupportedTagException extends CompilerException {
+ private static final long serialVersionUID = 3199732135804426699L;
+
+ /** Creates a new <code>UnsupportedTagException</code>. */
+ public UnsupportedTagException() {
+ }
+
+
+ /**
+ * Creates a new <code>UnsupportedTagException</code> with the specified detail message.
+ *
+ * @param msg the exception's detail message
+ */
+ public UnsupportedTagException(String msg) {
+ super(msg);
+ }
+
+
+ /**
+ * Creates a new <code>UnsupportedTagException</code> with the specified cause.
+ *
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedTagException(Throwable initCause) {
+ super(initCause);
+ }
+
+
+ /**
+ * Creates a new <code>UnsupportedTagException</code> with the specified detail message and cause.
+ *
+ * @param msg the exception's detail message
+ * @param initCause the exception's initCause
+ */
+ public UnsupportedTagException(String msg, Throwable initCause) {
+ super(msg, initCause);
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/UnsupportedTagException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/ValidatorGenerator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,89 +0,0 @@
-package jaxx.compiler;
-
-import jaxx.compiler.CompiledObject.ChildRef;
-import jaxx.reflect.ClassDescriptor;
-import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.tags.validator.BeanValidatorHandler;
-import jaxx.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
-import jaxx.types.TypeManager;
-
-import java.util.List;
-
-/** @author chemit */
-public class ValidatorGenerator implements Generator {
-
- protected static final JavaField VALIDATOR_IDS_FIELD = JavaField.newField(java.lang.reflect.Modifier.PROTECTED,
- "java.util.List<String>", "validatorIds", "new ArrayList<String>()"
- );
-
- @Override
- public void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) {
-
- if (!BeanValidatorHandler.hasValidator(compiler)) {
- return;
- }
-
- for (CompiledObject object : compiler.getObjects().values()) {
- List<ChildRef> childs = object.getChilds();
- if (childs == null || childs.isEmpty()) {
- continue;
- }
- for (ChildRef child : childs) {
- String javaCode = child.getChildJavaCode();
- // some validators are defined on this object
- boolean found = BeanValidatorHandler.isComponentUsedByValidator(compiler, child.getChild().getId());
- if (found) {
- // box the child component in a JxLayer
- child.setChildJavaCode(jaxx.runtime.SwingUtil.class.getName()+".boxComponentWithJxLayer(" + javaCode + ")");
- }
- }
- }
- // register validator
- for (CompiledBeanValidator validator : BeanValidatorHandler.getValidators(compiler)) {
- String id = TypeManager.getJavaCode(validator.getId());
- compiler.appendLateInitializer("validatorIds.add(" + id + ");");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- compiler.appendLateInitializer("getValidator(" + id + ").installUIs();");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- compiler.appendLateInitializer("getValidator(" + id + ").reloadBean();");
- //compiler.appendLateInitializer("getValidator(" + id + ").validate();");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- }
- compiler.appendLateInitializer("validatorIds = java.util.Collections.unmodifiableList(validatorIds);");
- compiler.appendLateInitializer(JAXXCompiler.getLineSeparator());
- }
-
- @Override
- public void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException {
- if (!BeanValidatorHandler.hasValidator(compiler)) {
- return;
- }
- Class<?> validatorClass = compiler.getOptions().getValidatorClass();
- String validatorFQN = validatorClass.getName();
- javaFile.addImport(validatorFQN);
-
- //TODO use the specific JAXXValidator interface (swing, gwt,...)
- Class<?> validatorInterface = jaxx.runtime.JAXXValidator.class;
-
- if (javaFile.isSuperclassIsJAXXObject()) {
- ClassDescriptor superClass = ClassDescriptorLoader.getClassDescriptor(javaFile.getSuperClass());
- boolean parentIsValidator = ClassDescriptorLoader.getClassDescriptor(validatorInterface).isAssignableFrom(superClass);
-
- if (parentIsValidator) {
- // nothing to generate (use the parent directly)
- return;
- }
- }
-
- // add JAXXValidator interface
- javaFile.addInterface(JAXXCompiler.getCanonicalName(validatorInterface));
-
- // implements JAXXValidator
- javaFile.addField(VALIDATOR_IDS_FIELD);
- javaFile.addMethod(JavaMethod.newMethod(java.lang.reflect.Modifier.PUBLIC, validatorFQN + "<?>", "getValidator",
- "return (" + validatorFQN + ") (validatorIds.contains(validatorId) ? getObjectById(validatorId) : null);",
- new JavaArgument("String", "validatorId")
- ));
- }
-
-}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/beaninfos/BeanInfoUtil.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,36 @@
+package jaxx.compiler.beans;
+
+import java.beans.Introspector;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+/** @author chemit */
+public class BeanInfoUtil {
+
+ public static String[] originalBeanInfoSearchPath;
+
+ public static void addJaxxBeanInfoPath(String... packageNames) {
+
+ String[] searchPath = Introspector.getBeanInfoSearchPath();
+ if (originalBeanInfoSearchPath == null) {
+ originalBeanInfoSearchPath = searchPath;
+ }
+ List<String> listSearchPath = new ArrayList<String>(Arrays.asList(searchPath));
+ for (String packageName : packageNames) {
+ if (!listSearchPath.contains(packageName)) {
+ listSearchPath.add(packageName);
+ }
+ }
+
+ Introspector.setBeanInfoSearchPath(listSearchPath.toArray(new String[listSearchPath.size()]));
+ }
+
+ public static void reset() {
+ if (originalBeanInfoSearchPath != null) {
+ Introspector.setBeanInfoSearchPath(originalBeanInfoSearchPath);
+ originalBeanInfoSearchPath = null;
+ }
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/BeanInfoUtil.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXBeanDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,15 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+/**
+ * Mirrors the class <code>java.beans.BeanDescriptor</code>. JAXX uses its own introspector rather than the built-in
+ * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXBeanDescriptor extends JAXXFeatureDescriptor {
+
+ public JAXXBeanDescriptor(ClassDescriptor beanClass) {
+ super(beanClass, beanClass.getName());
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,33 @@
+package jaxx.compiler.beans;
+
+/**
+ * Mirrors the class <code>java.beans.BeanInfo</code>. JAXX uses its own introspector rather than the built-in
+ * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXBeanInfo {
+
+ private JAXXBeanDescriptor beanDescriptor;
+ private JAXXPropertyDescriptor[] propertyDescriptors;
+ private JAXXEventSetDescriptor[] eventSetDescriptors;
+
+ public JAXXBeanInfo(JAXXBeanDescriptor beanDescriptor,
+ JAXXPropertyDescriptor[] propertyDescriptors,
+ JAXXEventSetDescriptor[] eventSetDescriptors) {
+ this.beanDescriptor = beanDescriptor;
+ this.propertyDescriptors = propertyDescriptors;
+ this.eventSetDescriptors = eventSetDescriptors;
+ }
+
+ public JAXXBeanDescriptor getJAXXBeanDescriptor() {
+ return beanDescriptor;
+ }
+
+ public JAXXPropertyDescriptor[] getJAXXPropertyDescriptors() {
+ return propertyDescriptors;
+ }
+
+ public JAXXEventSetDescriptor[] getJAXXEventSetDescriptors() {
+ return eventSetDescriptors;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXBeanInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXEventSetDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,36 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+/**
+ * Mirrors the class <code>java.beans.EventSetDescriptor</code>. JAXX uses its own introspector rather than the built-in
+ * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXEventSetDescriptor extends JAXXFeatureDescriptor {
+
+ private MethodDescriptor addListenerMethod;
+ private MethodDescriptor removeListenerMethod;
+ private MethodDescriptor[] listenerMethods;
+
+ public JAXXEventSetDescriptor(ClassDescriptor classDescriptor, String name, MethodDescriptor addListenerMethod,
+ MethodDescriptor removeListenerMethod, MethodDescriptor[] listenerMethods) {
+ super(classDescriptor, name);
+ this.addListenerMethod = addListenerMethod;
+ this.removeListenerMethod = removeListenerMethod;
+ this.listenerMethods = listenerMethods;
+ }
+
+ public MethodDescriptor getAddListenerMethod() {
+ return addListenerMethod;
+ }
+
+ public MethodDescriptor getRemoveListenerMethod() {
+ return removeListenerMethod;
+ }
+
+ public MethodDescriptor[] getListenerMethods() {
+ return listenerMethods;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXEventSetDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXFeatureDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,52 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Mirrors the class <code>java.beans.FeatureDescriptor</code>. JAXX uses its own introspector rather than the built-in
+ * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXFeatureDescriptor {
+
+ private String name;
+ private Map<String, Object> values;
+ private ClassDescriptor classDescriptor;
+
+ JAXXFeatureDescriptor(ClassDescriptor classDescriptor, String name) {
+ if (name == null || classDescriptor == null) {
+ throw new NullPointerException();
+ }
+ this.name = name;
+ this.classDescriptor = classDescriptor;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public ClassDescriptor getClassDescriptor() {
+ return classDescriptor;
+ }
+
+ public Object getValue(String key) {
+ return values != null ? values.get(key) : null;
+ }
+
+ public void setValue(String key, Object value) {
+ if (values == null) {
+ values = new HashMap<String, Object>();
+ }
+ values.put(key, value);
+ }
+
+ public static String capitalize(String name) {
+ if (name.length() == 0) {
+ return name;
+ }
+ return Character.toUpperCase(name.charAt(0)) + name.substring(1);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXFeatureDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXIntrospector.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,167 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+import java.beans.BeanDescriptor;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyDescriptor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.Enumeration;
+import java.util.EventListener;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Performs introspection on a <code>ClassDescriptor</code>. Ideally, I could just have copied Sun's Introspector
+ * and changed a few things, but the licensing terms are incompatible. This implementation is incomplete -- it only
+ * bothers to report info that JAXX actually checks. It also relaxes some of Introspector's rules a bit, but I
+ * don't believe it results in any meaningful incompatibilities.
+ * <p/>
+ * JAXX uses its own introspector rather than the built-in
+ * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXIntrospector {
+
+ private ClassDescriptor classDescriptor;
+ private Map<String, JAXXPropertyDescriptor> propertyDescriptors = new HashMap<String, JAXXPropertyDescriptor>();
+ private Map<String, JAXXEventSetDescriptor> eventSetDescriptors = new HashMap<String, JAXXEventSetDescriptor>();
+
+ private JAXXIntrospector(ClassDescriptor classDescriptor) {
+ this.classDescriptor = classDescriptor;
+ }
+
+ /**
+ * Returns the <code>JAXXBeanInfo</code> for a given class.
+ *
+ * @param classDescriptor the class to introspect
+ * @return the <code>JAXXBeanInfo</code> for the bean class
+ * @throws IntrospectionException if an error occurs
+ */
+ public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor classDescriptor) throws IntrospectionException {
+ JAXXIntrospector introspector = new JAXXIntrospector(classDescriptor);
+ return introspector.createBeanInfo();
+ }
+
+ private JAXXBeanInfo createBeanInfo() {
+ ClassDescriptor explicitInfoClass = classDescriptor;
+ BeanInfo explicitBeanInfo = null;
+ while (explicitInfoClass != null) {
+ explicitBeanInfo = getExplicitBeanInfo(explicitInfoClass);
+ if (explicitBeanInfo != null) {
+ break;
+ }
+ explicitInfoClass = explicitInfoClass.getSuperclass();
+ }
+
+ if (explicitBeanInfo != null) {
+ PropertyDescriptor[] explicitProperties = explicitBeanInfo.getPropertyDescriptors();
+ for (PropertyDescriptor explicitProperty : explicitProperties) {
+ Class type = explicitProperty.getPropertyType();
+ Method readMethod = explicitProperty.getReadMethod();
+ Method writeMethod = explicitProperty.getWriteMethod();
+ try {
+ ClassDescriptor typeDescriptor = ClassDescriptorLoader.getClassDescriptor(type.getName(), type.getClassLoader());
+ JAXXPropertyDescriptor propertyDescriptor = new JAXXPropertyDescriptor(classDescriptor, explicitProperty.getName(),
+ readMethod != null ? classDescriptor.getMethodDescriptor(readMethod.getName()) : null,
+ writeMethod != null ? classDescriptor.getMethodDescriptor(writeMethod.getName(), typeDescriptor) : null);
+ propertyDescriptor.setBound(explicitProperty.isBound());
+ Enumeration<String> attributeNames = explicitProperty.attributeNames();
+ while (attributeNames.hasMoreElements()) {
+ String name = attributeNames.nextElement();
+ propertyDescriptor.setValue(name, explicitProperty.getValue(name));
+ }
+ propertyDescriptors.put(propertyDescriptor.getName(), propertyDescriptor);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("Internal error: Could not find ClassDescriptor corresponding to Java " + type, e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Internal error: Could not find expected MethodDescriptor in " + classDescriptor, e);
+ }
+ }
+ }
+
+ // if the class broadcasts PropertyChangeEvent, assume all properties are bound (java.beans.Introspector
+ // does the same)
+ boolean propertyChangeSource;
+ try {
+ classDescriptor.getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class));
+ propertyChangeSource = true;
+ } catch (NoSuchMethodException e) {
+ propertyChangeSource = false;
+ }
+
+ MethodDescriptor[] methods = classDescriptor.getMethodDescriptors();
+ for (MethodDescriptor method : methods) {
+ String name = method.getName();
+ if (name.startsWith("get") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 0) {
+ String propertyName = Introspector.decapitalize(name.substring(3));
+ if (!propertyDescriptors.containsKey(propertyName)) {
+ propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource));
+ }
+ } else if (name.startsWith("is") && name.length() > 2 && Character.isUpperCase(name.charAt(2)) && method.getParameterTypes().length == 0) {
+ String propertyName = Introspector.decapitalize(name.substring(2));
+ if (!propertyDescriptors.containsKey(propertyName)) {
+ propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, method, null, propertyChangeSource));
+ }
+ } else if (name.startsWith("set") && name.length() > 3 && Character.isUpperCase(name.charAt(3)) && method.getParameterTypes().length == 1) {
+ String propertyName = Introspector.decapitalize(name.substring(3));
+ if (!propertyDescriptors.containsKey(propertyName)) {
+ propertyDescriptors.put(propertyName, new JAXXPropertyDescriptor(classDescriptor, propertyName, null, method, propertyChangeSource));
+ }
+ } else if (name.startsWith("add") && name.length() > 3 && Character.isUpperCase(name.charAt(3))) {
+ ClassDescriptor[] parameters = method.getParameterTypes();
+ if (parameters.length != 1 || !ClassDescriptorLoader.getClassDescriptor(EventListener.class).isAssignableFrom(parameters[0])) {
+ continue; // not an event listener method
+ }
+ try {
+ String eventSetName = method.getName().substring(3);
+ MethodDescriptor remove = classDescriptor.getMethodDescriptor("remove" + eventSetName, parameters);
+ eventSetDescriptors.put(eventSetName, new JAXXEventSetDescriptor(classDescriptor, eventSetName, method, remove, parameters[0].getMethodDescriptors()));
+ } catch (NoSuchMethodException e) {
+ // no matching remove method, not a valid event
+ }
+ }
+ }
+
+ JAXXBeanDescriptor beanDescriptor = new JAXXBeanDescriptor(classDescriptor);
+ if (explicitBeanInfo != null) {
+ BeanDescriptor explicitBeanDescriptor = explicitBeanInfo.getBeanDescriptor();
+ if (explicitBeanDescriptor != null) {
+ Enumeration/*<String>*/ attributeNames = explicitBeanDescriptor.attributeNames();
+ while (attributeNames.hasMoreElements()) {
+ String name = (String) attributeNames.nextElement();
+ beanDescriptor.setValue(name, explicitBeanDescriptor.getValue(name));
+ }
+ }
+ }
+
+ return new JAXXBeanInfo(beanDescriptor,
+ propertyDescriptors.values().toArray(new JAXXPropertyDescriptor[propertyDescriptors.size()]),
+ eventSetDescriptors.values().toArray(new JAXXEventSetDescriptor[eventSetDescriptors.size()]));
+ }
+
+ private static BeanInfo getExplicitBeanInfo(ClassDescriptor classDescriptor) {
+ try {
+ Class beanClass = Class.forName(classDescriptor.getName(), true, classDescriptor.getClassLoader()); // see if there is a class by that name in this package
+ Method findExplicitBeanInfo = Introspector.class.getDeclaredMethod("findExplicitBeanInfo", new Class[]{Class.class});
+ findExplicitBeanInfo.setAccessible(true);
+ return (BeanInfo) findExplicitBeanInfo.invoke(null, beanClass);
+ } catch (ClassNotFoundException e) {
+ return null; // happens for uncompiled classes
+ } catch (NoClassDefFoundError e) {
+ return null; // wrong case, etc.
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException("Error: could not find method 'findExplicitBeanInfo' in java.beans.Introspector. You are most likely running a version of Java against which JAXX has not been tested.");
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXIntrospector.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/introspection/JAXXPropertyDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,87 @@
+package jaxx.compiler.beans;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+/**
+ * Mirrors the class <code>java.beans.PropertyDescriptor</code>. JAXX uses its own introspector rather than the built-in
+ * <code>java.beans.Introspector</code> so that it can introspect {@link jaxx.reflect.ClassDescriptor},
+ * not just <code>java.lang.Class</code>.
+ */
+public class JAXXPropertyDescriptor extends JAXXFeatureDescriptor {
+
+ private ClassDescriptor propertyType;
+ private MethodDescriptor readMethod;
+ private MethodDescriptor writeMethod;
+ private boolean bound;
+
+ public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName) {
+ this(classDescriptor, propertyName, null, null);
+ }
+
+ public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName,
+ MethodDescriptor readMethod, MethodDescriptor writeMethod) {
+ this(classDescriptor, propertyName, readMethod, writeMethod, false);
+ }
+
+ public JAXXPropertyDescriptor(ClassDescriptor classDescriptor, String propertyName,
+ MethodDescriptor readMethod, MethodDescriptor writeMethod,
+ boolean bound) {
+ super(classDescriptor, propertyName);
+ this.readMethod = readMethod;
+ this.writeMethod = writeMethod;
+ this.bound = bound;
+ }
+
+ public MethodDescriptor getReadMethodDescriptor() {
+ if (readMethod == null) {
+ try {
+ readMethod = getClassDescriptor().getMethodDescriptor("get" + capitalize(getName()));
+ } catch (NoSuchMethodException e) {
+ try {
+ readMethod = getClassDescriptor().getMethodDescriptor("is" + capitalize(getName()));
+ } catch (NoSuchMethodException e2) {
+ }
+ }
+ }
+ return readMethod;
+ }
+
+ public MethodDescriptor getWriteMethodDescriptor() {
+ if (writeMethod == null) {
+ try {
+ String methodName = "set" + capitalize(getName());
+ MethodDescriptor read = getReadMethodDescriptor();
+ if (read != null) {
+ writeMethod = getClassDescriptor().getMethodDescriptor(methodName, read.getReturnType());
+ } else {
+ throw new CompilerException("Internal error: requesting 'set' method for property of unknown type: '" + getName() + "' (in " + getClassDescriptor() + ")");
+ }
+ } catch (NoSuchMethodException e) {
+ }
+ }
+ return writeMethod;
+ }
+
+ public ClassDescriptor getPropertyType() {
+ if (propertyType == null) {
+ MethodDescriptor read = getReadMethodDescriptor();
+ if (read != null) {
+ propertyType = read.getReturnType();
+ } else {
+ MethodDescriptor write = getWriteMethodDescriptor();
+ propertyType = write.getParameterTypes()[0];
+ }
+ }
+ return propertyType;
+ }
+
+ public boolean isBound() {
+ return bound;
+ }
+
+ public void setBound(boolean bound) {
+ this.bound = bound;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/beans/JAXXPropertyDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/Generator.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,17 @@
+package jaxx.compiler.generators;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaFile;
+
+/**
+ * TODO javadoc!
+ *
+ * @author chemit
+ */
+public interface Generator {
+
+ void finalizeCompiler(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className);
+
+ void prepareJavaFile(CompiledObject root, JAXXCompiler compiler, JavaFile javaFile, String packageName, String className) throws ClassNotFoundException;
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/generators/Generator.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSS.jj)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,587 @@
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. .\CSS.jj */
+/*@egen*//*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+// I would love to have used an existing CSS parser, but all of the ones I could
+// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big
+// fan of the LGPL, unfortunately that won't work.
+options {
+ STATIC = false;
+ JDK_VERSION = "1.4";
+}
+
+PARSER_BEGIN(CSSParser)
+package jaxx.css;
+
+public class CSSParser/*@bgen(jjtree)*/implements CSSParserTreeConstants/*@egen*/ {/*@bgen(jjtree)*/
+ protected JJTCSSParserState jjtree = new JJTCSSParserState();
+
+/*@egen*/
+ public SimpleNode popNode() {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public static void main(String args[]) {
+ System.out.println("Reading from standard input...");
+ CSSParser css = new CSSParser(System.in);
+ try {
+ SimpleNode n = css.Stylesheet();
+ n.dump("");
+ System.out.println("Thank you.");
+ } catch (Exception e) {
+ System.out.println("Oops.");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+
+PARSER_END(CSSParser)
+
+
+<DEFAULT, IN_RULE> SKIP :
+{
+ " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+<*> TOKEN : /* LITERALS */
+{
+ <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?>
+|
+ <#INTEGER_LITERAL: (["0"-"9"])+>
+}
+
+<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */
+{
+ <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*>
+|
+ <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]>
+|
+ <#DIGIT: ["0"-"9"]>
+}
+
+<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */
+{
+ <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT
+}
+
+<DEFAULT> TOKEN: /* COLON */
+{
+ <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS
+}
+
+<IN_RULE> TOKEN: /* COLON_IN_RULE */
+{
+ <COLON: ":">
+}
+
+<*> TOKEN: /* SEMICOLON */
+{
+ <SEMICOLON: ";">
+}
+
+TOKEN : /* LEFT BRACE */
+{
+ <LEFT_BRACE: "{"> : IN_RULE
+}
+
+<IN_RULE> TOKEN : /* RIGHT BRACE */
+{
+ <RIGHT_BRACE: "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */
+{
+ <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */
+{
+ <JAVA_CODE: (~["}"])+ >
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */
+{
+ <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE
+}
+
+
+<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */
+{
+ <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* STRINGS */
+{
+ <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\"">
+}
+
+<IN_RULE> TOKEN : /* COLORS */
+{
+ <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?>
+|
+ <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]>
+}
+
+
+<IN_RULE> TOKEN : /* EMS */
+{
+ <EMS: <DECIMAL_LITERAL> "em">
+}
+
+
+<IN_RULE> TOKEN : /* EXS */
+{
+ <EXS: <DECIMAL_LITERAL> "ex">
+}
+
+
+<IN_RULE> TOKEN : /* LENGTH */
+{
+ <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")>
+}
+
+
+SimpleNode Stylesheet() : {/*@bgen(jjtree) Stylesheet */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Stylesheet */
+ try {
+/*@egen*/
+ (Rule())*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ { return jjtn000; }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Rule() : {/*@bgen(jjtree) Rule */
+ SimpleNode jjtn000 = new SimpleNode(JJTRULE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Rule */
+ try {
+/*@egen*/
+ Selectors()
+ <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Selectors() : {/*@bgen(jjtree) Selectors */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Selectors */
+ try {
+/*@egen*/
+ Selector() ("," Selector())*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Selector() : {/*@bgen(jjtree) Selector */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Selector */
+ try {
+/*@egen*/
+ JavaClass() (Id())? (Class())? (PseudoClass())?
+|
+ Id() (Class())? (PseudoClass())?
+|
+ Class() (PseudoClass())?
+|
+ PseudoClass()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void JavaClass() : {/*@bgen(jjtree) JavaClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) JavaClass */
+ try {
+/*@egen*/
+ <IDENTIFIER> | "*"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Id() : {/*@bgen(jjtree) Id */
+ SimpleNode jjtn000 = new SimpleNode(JJTID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Id */
+ try {
+/*@egen*/
+ "#" <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Class() : {/*@bgen(jjtree) Class */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Class */
+ try {
+/*@egen*/
+ "." <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void PseudoClass() : {/*@bgen(jjtree) PseudoClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PseudoClass */
+ try {
+/*@egen*/
+ <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())?/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void AnimationProperties() : {/*@bgen(jjtree) AnimationProperties */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnimationProperties */
+ try {
+/*@egen*/
+ "[" AnimationProperty() ("," AnimationProperty())* "]"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void AnimationProperty() : {/*@bgen(jjtree) AnimationProperty */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnimationProperty */
+ try {
+/*@egen*/
+ <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)?/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Declaration() : {/*@bgen(jjtree) Declaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Declaration */
+ try {
+/*@egen*/
+ Property() <COLON> Expression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Property() : {/*@bgen(jjtree) Property */
+ SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Property */
+ try {
+/*@egen*/
+ <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Expression() : {/*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Expression */
+ try {
+/*@egen*/
+ (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> |
+ JavaCode())/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void JavaCode() : {/*@bgen(jjtree) JavaCode */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) JavaCode */
+ try {
+/*@egen*/
+ <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void Identifier() : {/*@bgen(jjtree) Identifier */
+ SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Identifier */
+ try {
+/*@egen*/
+ <IDENTIFIER>/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jj
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSS.jjt)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+
+// I would love to have used an existing CSS parser, but all of the ones I could
+// find are licensed under the LGPL. As JAXX is BSD licensed and I'm not a big
+// fan of the LGPL, unfortunately that won't work.
+options {
+ STATIC = false;
+ JDK_VERSION = "1.4";
+ NODE_SCOPE_HOOK = true;
+}
+
+PARSER_BEGIN(CSSParser)
+package jaxx.css;
+
+public class CSSParser {
+ public SimpleNode popNode() {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public static void main(String args[]) {
+ System.out.println("Reading from standard input...");
+ CSSParser css = new CSSParser(System.in);
+ try {
+ SimpleNode n = css.Stylesheet();
+ n.dump("");
+ System.out.println("Thank you.");
+ } catch (Exception e) {
+ System.out.println("Oops.");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+}
+
+PARSER_END(CSSParser)
+
+
+<DEFAULT, IN_RULE> SKIP :
+{
+ " "
+| "\t"
+| "\n"
+| "\r"
+| <"//" (~["\n","\r"])* ("\n"|"\r"|"\r\n")>
+| <"/*" (~["*"])* "*" (~["/"] (~["*"])* "*")* "/">
+}
+
+<*> TOKEN : /* LITERALS */
+{
+ <DECIMAL_LITERAL: <INTEGER_LITERAL> ("." <INTEGER_LITERAL>)?>
+|
+ <#INTEGER_LITERAL: (["0"-"9"])+>
+}
+
+<DEFAULT, IN_RULE> TOKEN : /* IDENTIFIER */
+{
+ <IDENTIFIER: <LETTER> (<LETTER>|<DIGIT>)*>
+|
+ <#LETTER: ["_", "-", "a"-"z", "A"-"Z"]>
+|
+ <#DIGIT: ["0"-"9"]>
+}
+
+<IN_PSEUDOCLASS> TOKEN : /* PSEUDOCLASS_IDENTIFIER */
+{
+ <PSEUDOCLASS_IDENTIFIER: <IDENTIFIER>> : DEFAULT
+}
+
+<DEFAULT> TOKEN: /* COLON */
+{
+ <PSEUDOCLASS_COLON: ":"> : IN_PSEUDOCLASS
+}
+
+<IN_RULE> TOKEN: /* COLON_IN_RULE */
+{
+ <COLON: ":">
+}
+
+<*> TOKEN: /* SEMICOLON */
+{
+ <SEMICOLON: ";">
+}
+
+TOKEN : /* LEFT BRACE */
+{
+ <LEFT_BRACE: "{"> : IN_RULE
+}
+
+<IN_RULE> TOKEN : /* RIGHT BRACE */
+{
+ <RIGHT_BRACE: "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* JAVA_CODE_RULE START */
+{
+ <JAVA_CODE_START: <LEFT_BRACE>> : JAVA_CODE_RULE
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE */
+{
+ <JAVA_CODE: (~["}"])+ >
+}
+
+<JAVA_CODE_RULE> TOKEN : /* JAVA_CODE_RULE END */
+{
+ <JAVA_CODE_END: <RIGHT_BRACE>> : IN_RULE
+}
+
+
+<IN_PSEUDOCLASS> TOKEN : /* PROGRAMMATIC_PSEUDOCLASS */
+{
+ <PROGRAMMATIC_PSEUDOCLASS: "{" (~["}"])+ "}"> : DEFAULT
+}
+
+<IN_RULE> TOKEN : /* STRINGS */
+{
+ <STRING: "\"" (~["\"", "\\", "\n", "\r"])* "\"">
+}
+
+<IN_RULE> TOKEN : /* COLORS */
+{
+ <HEXCOLOR: "#" <HEXDIGIT> <HEXDIGIT> <HEXDIGIT> (<HEXDIGIT> <HEXDIGIT> <HEXDIGIT>)?>
+|
+ <#HEXDIGIT: ["0"-"9", "a"-"f", "A"-"F"]>
+}
+
+
+<IN_RULE> TOKEN : /* EMS */
+{
+ <EMS: <DECIMAL_LITERAL> "em">
+}
+
+
+<IN_RULE> TOKEN : /* EXS */
+{
+ <EXS: <DECIMAL_LITERAL> "ex">
+}
+
+
+<IN_RULE> TOKEN : /* LENGTH */
+{
+ <LENGTH: <DECIMAL_LITERAL> ("pt" | "mm" | "cm" | "pc" | "in")>
+}
+
+
+SimpleNode Stylesheet() : {}
+{
+ (Rule())*
+ { return jjtThis; }
+}
+
+
+void Rule() : {}
+{
+ Selectors()
+ <LEFT_BRACE> Declaration() (";" (Declaration())?)* <RIGHT_BRACE>
+}
+
+
+void Selectors() : {}
+{
+ Selector() ("," Selector())*
+}
+
+
+void Selector() : {}
+{
+ JavaClass() (Id())? (Class())? (PseudoClass())?
+|
+ Id() (Class())? (PseudoClass())?
+|
+ Class() (PseudoClass())?
+|
+ PseudoClass()
+}
+
+
+void JavaClass() : {}
+{
+ <IDENTIFIER> | "*"
+}
+
+
+void Id() : {}
+{
+ "#" <IDENTIFIER>
+}
+
+
+void Class() : {}
+{
+ "." <IDENTIFIER>
+}
+
+
+void PseudoClass() : {}
+{
+ <PSEUDOCLASS_COLON> (<PSEUDOCLASS_IDENTIFIER> | <PROGRAMMATIC_PSEUDOCLASS>) (AnimationProperties())?
+}
+
+
+void AnimationProperties() : {}
+{
+ "[" AnimationProperty() ("," AnimationProperty())* "]"
+}
+
+
+void AnimationProperty() : {}
+{
+ <IDENTIFIER> "=" <DECIMAL_LITERAL> (<IDENTIFIER>)?
+}
+
+
+void Declaration() : {}
+{
+ Property() <COLON> Expression()
+}
+
+
+void Property() : {}
+{
+ <IDENTIFIER>
+}
+
+
+void Expression() : {}
+{
+ (<DECIMAL_LITERAL> | <STRING> | <IDENTIFIER> | <HEXCOLOR> | <EMS> | <EXS> | <LENGTH> |
+ JavaCode())
+}
+
+
+void JavaCode() : {}
+{
+ <JAVA_CODE_START> <JAVA_CODE> <JAVA_CODE_END>
+}
+
+
+void Identifier() : {}
+{
+ <IDENTIFIER>
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSS.jjt
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParser.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,799 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParser.java */
+package jaxx.compiler.parser.css;
+
+public class CSSParser/*@bgen(jjtree)*/ implements CSSParserTreeConstants, CSSParserConstants {/*@bgen(jjtree)*/
+ protected JJTCSSParserState jjtree = new JJTCSSParserState();
+
+ public SimpleNode popNode() {
+ if (jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode) jjtree.popNode();
+ else
+ return null;
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public static void main(String args[]) {
+ System.out.println("Reading from standard input...");
+ CSSParser css = new CSSParser(System.in);
+ try {
+ SimpleNode n = css.Stylesheet();
+ n.dump("");
+ System.out.println("Thank you.");
+ } catch (Exception e) {
+ System.out.println("Oops.");
+ System.out.println(e.getMessage());
+ e.printStackTrace();
+ }
+ }
+
+ final public SimpleNode Stylesheet() throws ParseException {
+ /*@bgen(jjtree) Stylesheet */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTYLESHEET);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ label_1:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ case PSEUDOCLASS_COLON:
+ case 29:
+ case 30:
+ case 31:
+ ;
+ break;
+ default:
+ jj_la1[0] = jj_gen;
+ break label_1;
+ }
+ Rule();
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return jjtn000;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ final public void Rule() throws ParseException {
+ /*@bgen(jjtree) Rule */
+ SimpleNode jjtn000 = new SimpleNode(JJTRULE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Selectors();
+ jj_consume_token(LEFT_BRACE);
+ Declaration();
+ label_2:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SEMICOLON:
+ ;
+ break;
+ default:
+ jj_la1[1] = jj_gen;
+ break label_2;
+ }
+ jj_consume_token(SEMICOLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ Declaration();
+ break;
+ default:
+ jj_la1[2] = jj_gen;
+ ;
+ }
+ }
+ jj_consume_token(RIGHT_BRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Selectors() throws ParseException {
+ /*@bgen(jjtree) Selectors */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTORS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Selector();
+ label_3:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 28:
+ ;
+ break;
+ default:
+ jj_la1[3] = jj_gen;
+ break label_3;
+ }
+ jj_consume_token(28);
+ Selector();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Selector() throws ParseException {
+ /*@bgen(jjtree) Selector */
+ SimpleNode jjtn000 = new SimpleNode(JJTSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ case 29:
+ JavaClass();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 30:
+ Id();
+ break;
+ default:
+ jj_la1[4] = jj_gen;
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 31:
+ Class();
+ break;
+ default:
+ jj_la1[5] = jj_gen;
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[6] = jj_gen;
+ ;
+ }
+ break;
+ case 30:
+ Id();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 31:
+ Class();
+ break;
+ default:
+ jj_la1[7] = jj_gen;
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[8] = jj_gen;
+ ;
+ }
+ break;
+ case 31:
+ Class();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[9] = jj_gen;
+ ;
+ }
+ break;
+ case PSEUDOCLASS_COLON:
+ PseudoClass();
+ break;
+ default:
+ jj_la1[10] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void JavaClass() throws ParseException {
+ /*@bgen(jjtree) JavaClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ case 29:
+ jj_consume_token(29);
+ break;
+ default:
+ jj_la1[11] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Id() throws ParseException {
+ /*@bgen(jjtree) Id */
+ SimpleNode jjtn000 = new SimpleNode(JJTID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(30);
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Class() throws ParseException {
+ /*@bgen(jjtree) Class */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(31);
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PseudoClass() throws ParseException {
+ /*@bgen(jjtree) PseudoClass */
+ SimpleNode jjtn000 = new SimpleNode(JJTPSEUDOCLASS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(PSEUDOCLASS_COLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PSEUDOCLASS_IDENTIFIER:
+ jj_consume_token(PSEUDOCLASS_IDENTIFIER);
+ break;
+ case PROGRAMMATIC_PSEUDOCLASS:
+ jj_consume_token(PROGRAMMATIC_PSEUDOCLASS);
+ break;
+ default:
+ jj_la1[12] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 32:
+ AnimationProperties();
+ break;
+ default:
+ jj_la1[13] = jj_gen;
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnimationProperties() throws ParseException {
+ /*@bgen(jjtree) AnimationProperties */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTIES);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(32);
+ AnimationProperty();
+ label_4:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 28:
+ ;
+ break;
+ default:
+ jj_la1[14] = jj_gen;
+ break label_4;
+ }
+ jj_consume_token(28);
+ AnimationProperty();
+ }
+ jj_consume_token(33);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnimationProperty() throws ParseException {
+ /*@bgen(jjtree) AnimationProperty */
+ SimpleNode jjtn000 = new SimpleNode(JJTANIMATIONPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(34);
+ jj_consume_token(DECIMAL_LITERAL);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ jj_la1[15] = jj_gen;
+ ;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Declaration() throws ParseException {
+ /*@bgen(jjtree) Declaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Property();
+ jj_consume_token(COLON);
+ Expression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Property() throws ParseException {
+ /*@bgen(jjtree) Property */
+ SimpleNode jjtn000 = new SimpleNode(JJTPROPERTY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Expression() throws ParseException {
+ /*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case DECIMAL_LITERAL:
+ jj_consume_token(DECIMAL_LITERAL);
+ break;
+ case STRING:
+ jj_consume_token(STRING);
+ break;
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ case HEXCOLOR:
+ jj_consume_token(HEXCOLOR);
+ break;
+ case EMS:
+ jj_consume_token(EMS);
+ break;
+ case EXS:
+ jj_consume_token(EXS);
+ break;
+ case LENGTH:
+ jj_consume_token(LENGTH);
+ break;
+ case JAVA_CODE_START:
+ JavaCode();
+ break;
+ default:
+ jj_la1[16] = jj_gen;
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void JavaCode() throws ParseException {
+ /*@bgen(jjtree) JavaCode */
+ SimpleNode jjtn000 = new SimpleNode(JJTJAVACODE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(JAVA_CODE_START);
+ jj_consume_token(JAVA_CODE);
+ jj_consume_token(JAVA_CODE_END);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Identifier() throws ParseException {
+ /*@bgen(jjtree) Identifier */
+ SimpleNode jjtn000 = new SimpleNode(JJTIDENTIFIER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ public CSSParserTokenManager token_source;
+ SimpleCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private int jj_gen;
+ final private int[] jj_la1 = new int[17];
+ static private int[] jj_la1_0;
+ static private int[] jj_la1_1;
+
+ static {
+ jj_la1_0();
+ jj_la1_1();
+ }
+
+ private static void jj_la1_0() {
+ jj_la1_0 = new int[]{0xe0002200, 0x8000, 0x200, 0x10000000, 0x40000000, 0x80000000, 0x2000, 0x80000000, 0x2000, 0x2000, 0xe0002200, 0x20000200, 0x201000, 0x0, 0x10000000, 0x200, 0xec40280,};
+ }
+
+ private static void jj_la1_1() {
+ jj_la1_1 = new int[]{0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0,};
+ }
+
+ public CSSParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+
+ public CSSParser(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream = new SimpleCharStream(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source = new CSSParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+
+ public void ReInit(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream.ReInit(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public CSSParser(java.io.Reader stream) {
+ jj_input_stream = new SimpleCharStream(stream, 1, 1);
+ token_source = new CSSParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public CSSParser(CSSParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ public void ReInit(CSSParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ jj_gen = 0;
+ for (int i = 0; i < 17; i++) jj_la1[i] = -1;
+ }
+
+ final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ jj_gen++;
+ return token;
+ }
+ token = oldToken;
+ jj_kind = kind;
+ throw generateParseException();
+ }
+
+ final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ jj_gen++;
+ return token;
+ }
+
+ final public Token getToken(int index) {
+ Token t = token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ final private int jj_ntk() {
+ if ((jj_nt = token.next) == null)
+ return (jj_ntk = (token.next = token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ private java.util.Vector jj_expentries = new java.util.Vector();
+ private int[] jj_expentry;
+ private int jj_kind = -1;
+
+ public ParseException generateParseException() {
+ Token errortok = token.next;
+ int line = errortok.beginLine, column = errortok.beginColumn;
+ String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
+ return new ParseException("Parse error. Encountered: " + mess, line, column);
+ }
+
+ final public void enable_tracing() {
+ }
+
+ final public void disable_tracing() {
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParser.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParserConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,72 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserConstants.java */
+package jaxx.compiler.parser.css;
+
+public interface CSSParserConstants {
+
+ int EOF = 0;
+ int DECIMAL_LITERAL = 7;
+ int INTEGER_LITERAL = 8;
+ int IDENTIFIER = 9;
+ int LETTER = 10;
+ int DIGIT = 11;
+ int PSEUDOCLASS_IDENTIFIER = 12;
+ int PSEUDOCLASS_COLON = 13;
+ int COLON = 14;
+ int SEMICOLON = 15;
+ int LEFT_BRACE = 16;
+ int RIGHT_BRACE = 17;
+ int JAVA_CODE_START = 18;
+ int JAVA_CODE = 19;
+ int JAVA_CODE_END = 20;
+ int PROGRAMMATIC_PSEUDOCLASS = 21;
+ int STRING = 22;
+ int HEXCOLOR = 23;
+ int HEXDIGIT = 24;
+ int EMS = 25;
+ int EXS = 26;
+ int LENGTH = 27;
+
+ int DEFAULT = 0;
+ int IN_RULE = 1;
+ int JAVA_CODE_RULE = 2;
+ int IN_PSEUDOCLASS = 3;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "\" \"",
+ "\"\\t\"",
+ "\"\\n\"",
+ "\"\\r\"",
+ "<token of kind 5>",
+ "<token of kind 6>",
+ "<DECIMAL_LITERAL>",
+ "<INTEGER_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<DIGIT>",
+ "<PSEUDOCLASS_IDENTIFIER>",
+ "\":\"",
+ "\":\"",
+ "\";\"",
+ "\"{\"",
+ "\"}\"",
+ "<JAVA_CODE_START>",
+ "<JAVA_CODE>",
+ "<JAVA_CODE_END>",
+ "<PROGRAMMATIC_PSEUDOCLASS>",
+ "<STRING>",
+ "<HEXCOLOR>",
+ "<HEXDIGIT>",
+ "<EMS>",
+ "<EXS>",
+ "<LENGTH>",
+ "\",\"",
+ "\"*\"",
+ "\"#\"",
+ "\".\"",
+ "\"[\"",
+ "\"]\"",
+ "\"=\"",
+ };
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParserTokenManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,1152 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. CSSParserTokenManager.java */
+package jaxx.compiler.parser.css;
+
+public class CSSParserTokenManager implements CSSParserConstants {
+ public java.io.PrintStream debugStream = System.out;
+
+ public void setDebugStream(java.io.PrintStream ds) {
+ debugStream = ds;
+ }
+
+ private int jjStopStringLiteralDfa_0(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_0(int pos, long active0) {
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0), pos + 1);
+ }
+
+ private int jjStopAtPos(int pos, int kind) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+ }
+
+ private int jjStartNfaWithStates_0(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_0(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_0() {
+ switch (curChar) {
+ case 35:
+ return jjStopAtPos(0, 30);
+ case 42:
+ return jjStopAtPos(0, 29);
+ case 44:
+ return jjStopAtPos(0, 28);
+ case 46:
+ return jjStopAtPos(0, 31);
+ case 58:
+ return jjStopAtPos(0, 13);
+ case 59:
+ return jjStopAtPos(0, 15);
+ case 61:
+ return jjStopAtPos(0, 34);
+ case 91:
+ return jjStopAtPos(0, 32);
+ case 93:
+ return jjStopAtPos(0, 33);
+ case 123:
+ return jjStopAtPos(0, 16);
+ default:
+ return jjMoveNfa_0(3, 0);
+ }
+ }
+
+ private void jjCheckNAdd(int state) {
+ if (jjrounds[state] != jjround) {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+ }
+
+ private void jjAddStates(int start, int end) {
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddTwoStates(int state1, int state2) {
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+ }
+
+ private void jjCheckNAddStates(int start, int end) {
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddStates(int start) {
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+ }
+
+ static final long[] jjbitVec0 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+ };
+
+ private int jjMoveNfa_0(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 17;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ } else if (curChar == 47)
+ jjAddStates(0, 1);
+ else if (curChar == 45) {
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(4);
+ }
+ break;
+ case 0:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ break;
+ case 1:
+ if (curChar == 46)
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(2);
+ break;
+ case 4:
+ if ((0x3ff200000000000L & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 47)
+ jjAddStates(0, 1);
+ break;
+ case 6:
+ if (curChar == 47)
+ jjCheckNAddStates(2, 4);
+ break;
+ case 7:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(2, 4);
+ break;
+ case 8:
+ if ((0x2400L & l) != 0L && kind > 5)
+ kind = 5;
+ break;
+ case 9:
+ if (curChar == 10 && kind > 5)
+ kind = 5;
+ break;
+ case 10:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 11:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 12:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 13:
+ if (curChar == 42)
+ jjAddStates(5, 6);
+ break;
+ case 14:
+ if ((0xffff7fffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 15:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ case 16:
+ if (curChar == 47 && kind > 6)
+ kind = 6;
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(4);
+ break;
+ case 7:
+ jjAddStates(2, 4);
+ break;
+ case 12:
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 7:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(2, 4);
+ break;
+ case 12:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(12, 13);
+ break;
+ case 14:
+ case 15:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(15, 13);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 17 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjStopStringLiteralDfa_3(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_3(int pos, long active0) {
+ return jjMoveNfa_3(jjStopStringLiteralDfa_3(pos, active0), pos + 1);
+ }
+
+ private int jjStartNfaWithStates_3(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_3(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_3() {
+ switch (curChar) {
+ case 59:
+ return jjStopAtPos(0, 15);
+ default:
+ return jjMoveNfa_3(3, 0);
+ }
+ }
+
+ private int jjMoveNfa_3(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 8;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ } else if (curChar == 45) {
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ }
+ break;
+ case 0:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ break;
+ case 1:
+ if (curChar == 46)
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(2);
+ break;
+ case 4:
+ if ((0x3ff200000000000L & l) == 0L)
+ break;
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ break;
+ case 6:
+ jjAddStates(7, 8);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 3:
+ if ((0x7fffffe87fffffeL & l) != 0L) {
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ } else if (curChar == 123)
+ jjCheckNAdd(6);
+ break;
+ case 4:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 12)
+ kind = 12;
+ jjCheckNAdd(4);
+ break;
+ case 5:
+ if (curChar == 123)
+ jjCheckNAdd(6);
+ break;
+ case 6:
+ if ((0xdfffffffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(6, 7);
+ break;
+ case 7:
+ if (curChar == 125)
+ kind = 21;
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 6:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(7, 8);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 8 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjStopStringLiteralDfa_1(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_1(int pos, long active0) {
+ return jjMoveNfa_1(jjStopStringLiteralDfa_1(pos, active0), pos + 1);
+ }
+
+ private int jjStartNfaWithStates_1(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_1(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_1() {
+ switch (curChar) {
+ case 58:
+ return jjStopAtPos(0, 14);
+ case 59:
+ return jjStopAtPos(0, 15);
+ case 125:
+ return jjStopAtPos(0, 17);
+ default:
+ return jjMoveNfa_1(0, 0);
+ }
+ }
+
+ private int jjMoveNfa_1(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 50;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 0:
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddStates(9, 22);
+ } else if (curChar == 47)
+ jjAddStates(23, 24);
+ else if (curChar == 35)
+ jjstateSet[jjnewStateCnt++] = 7;
+ else if (curChar == 34)
+ jjCheckNAddTwoStates(4, 5);
+ else if (curChar == 45) {
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ }
+ break;
+ case 1:
+ if ((0x3ff200000000000L & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ break;
+ case 3:
+ if (curChar == 34)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 4:
+ if ((0xfffffffbffffdbffL & l) != 0L)
+ jjCheckNAddTwoStates(4, 5);
+ break;
+ case 5:
+ if (curChar == 34 && kind > 22)
+ kind = 22;
+ break;
+ case 6:
+ if (curChar == 35)
+ jjstateSet[jjnewStateCnt++] = 7;
+ break;
+ case 7:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 8;
+ break;
+ case 8:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 9:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 23)
+ kind = 23;
+ jjstateSet[jjnewStateCnt++] = 10;
+ break;
+ case 10:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 11:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 12;
+ break;
+ case 12:
+ if ((0x3ff000000000000L & l) != 0L && kind > 23)
+ kind = 23;
+ break;
+ case 13:
+ if (curChar == 47)
+ jjAddStates(23, 24);
+ break;
+ case 14:
+ if (curChar == 47)
+ jjCheckNAddStates(25, 27);
+ break;
+ case 15:
+ if ((0xffffffffffffdbffL & l) != 0L)
+ jjCheckNAddStates(25, 27);
+ break;
+ case 16:
+ if ((0x2400L & l) != 0L && kind > 5)
+ kind = 5;
+ break;
+ case 17:
+ if (curChar == 10 && kind > 5)
+ kind = 5;
+ break;
+ case 18:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 17;
+ break;
+ case 19:
+ if (curChar == 42)
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 20:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 21:
+ if (curChar == 42)
+ jjAddStates(28, 29);
+ break;
+ case 22:
+ if ((0xffff7fffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ case 23:
+ if ((0xfffffbffffffffffL & l) != 0L)
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ case 24:
+ if (curChar == 47 && kind > 6)
+ kind = 6;
+ break;
+ case 25:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddStates(9, 22);
+ break;
+ case 26:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(26, 27);
+ break;
+ case 27:
+ if (curChar == 46)
+ jjCheckNAdd(28);
+ break;
+ case 28:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(28);
+ break;
+ case 29:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(30, 32);
+ break;
+ case 30:
+ if (curChar == 46)
+ jjCheckNAdd(31);
+ break;
+ case 31:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(31, 33);
+ break;
+ case 34:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(33, 35);
+ break;
+ case 35:
+ if (curChar == 46)
+ jjCheckNAdd(36);
+ break;
+ case 36:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(36, 38);
+ break;
+ case 39:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(36, 41);
+ break;
+ case 40:
+ if (curChar == 46)
+ jjCheckNAdd(41);
+ break;
+ case 41:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(42, 46);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 0:
+ if ((0x7fffffe87fffffeL & l) != 0L) {
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ } else if (curChar == 123) {
+ if (kind > 18)
+ kind = 18;
+ }
+ break;
+ case 1:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 9)
+ kind = 9;
+ jjCheckNAdd(1);
+ break;
+ case 2:
+ if (curChar == 123 && kind > 18)
+ kind = 18;
+ break;
+ case 4:
+ if ((0xffffffffefffffffL & l) != 0L)
+ jjAddStates(47, 48);
+ break;
+ case 7:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 8;
+ break;
+ case 8:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 9;
+ break;
+ case 9:
+ if ((0x7e0000007eL & l) == 0L)
+ break;
+ if (kind > 23)
+ kind = 23;
+ jjstateSet[jjnewStateCnt++] = 10;
+ break;
+ case 10:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 11;
+ break;
+ case 11:
+ if ((0x7e0000007eL & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 12;
+ break;
+ case 12:
+ if ((0x7e0000007eL & l) != 0L && kind > 23)
+ kind = 23;
+ break;
+ case 15:
+ jjAddStates(25, 27);
+ break;
+ case 20:
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 22:
+ case 23:
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ case 32:
+ if (curChar == 109 && kind > 25)
+ kind = 25;
+ break;
+ case 33:
+ if (curChar == 101)
+ jjstateSet[jjnewStateCnt++] = 32;
+ break;
+ case 37:
+ if (curChar == 120 && kind > 26)
+ kind = 26;
+ break;
+ case 38:
+ if (curChar == 101)
+ jjstateSet[jjnewStateCnt++] = 37;
+ break;
+ case 42:
+ if (curChar == 109 && kind > 27)
+ kind = 27;
+ break;
+ case 43:
+ if (curChar == 109)
+ jjCheckNAdd(42);
+ break;
+ case 44:
+ if (curChar == 99)
+ jjCheckNAdd(42);
+ break;
+ case 45:
+ if (curChar == 110 && kind > 27)
+ kind = 27;
+ break;
+ case 46:
+ if (curChar == 105)
+ jjstateSet[jjnewStateCnt++] = 45;
+ break;
+ case 47:
+ if (curChar == 112)
+ jjAddStates(49, 50);
+ break;
+ case 48:
+ if (curChar == 116 && kind > 27)
+ kind = 27;
+ break;
+ case 49:
+ if (curChar == 99 && kind > 27)
+ kind = 27;
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(47, 48);
+ break;
+ case 15:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjAddStates(25, 27);
+ break;
+ case 20:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(20, 21);
+ break;
+ case 22:
+ case 23:
+ if ((jjbitVec0[i2] & l2) != 0L)
+ jjCheckNAddTwoStates(23, 21);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 50 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjStopStringLiteralDfa_2(int pos, long active0) {
+ switch (pos) {
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_2(int pos, long active0) {
+ return jjMoveNfa_2(jjStopStringLiteralDfa_2(pos, active0), pos + 1);
+ }
+
+ private int jjStartNfaWithStates_2(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_2(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_2() {
+ switch (curChar) {
+ case 59:
+ return jjStartNfaWithStates_2(0, 15, 3);
+ default:
+ return jjMoveNfa_2(4, 0);
+ }
+ }
+
+ private int jjMoveNfa_2(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 5;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ if ((0x3ff000000000000L & l) != 0L) {
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ }
+ break;
+ case 0:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAddTwoStates(0, 1);
+ break;
+ case 1:
+ if (curChar == 46)
+ jjCheckNAdd(2);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 7)
+ kind = 7;
+ jjCheckNAdd(2);
+ break;
+ case 3:
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ if ((0xdfffffffffffffffL & l) != 0L) {
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ } else if (curChar == 125) {
+ if (kind > 20)
+ kind = 20;
+ }
+ break;
+ case 3:
+ if ((0xdfffffffffffffffL & l) == 0L)
+ break;
+ kind = 19;
+ jjCheckNAdd(3);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 4:
+ case 3:
+ if ((jjbitVec0[i2] & l2) == 0L)
+ break;
+ if (kind > 19)
+ kind = 19;
+ jjCheckNAdd(3);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 5 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ static final int[] jjnextStates = {
+ 6, 11, 7, 8, 10, 14, 16, 6, 7, 26, 27, 29, 30, 33, 34, 35,
+ 38, 39, 40, 43, 44, 46, 47, 14, 19, 15, 16, 18, 22, 24, 29, 30,
+ 33, 34, 35, 38, 39, 40, 43, 44, 46, 47, 41, 43, 44, 46, 47, 4,
+ 5, 48, 49,
+ };
+ public static final String[] jjstrLiteralImages = {
+ "", null, null, null, null, null, null, null, null, null, null, null, null,
+ "\72", "\72", "\73", "\173", "\175", null, null, null, null, null, null, null, null,
+ null, null, "\54", "\52", "\43", "\56", "\133", "\135", "\75",};
+ public static final String[] lexStateNames = {
+ "DEFAULT",
+ "IN_RULE",
+ "JAVA_CODE_RULE",
+ "IN_PSEUDOCLASS",
+ };
+ public static final int[] jjnewLexState = {
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, 3, -1, -1, 1, 0, 2, -1, 1, 0, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ };
+ static final long[] jjtoToken = {
+ 0x7fefff281L,
+ };
+ static final long[] jjtoSkip = {
+ 0x7eL,
+ };
+ protected SimpleCharStream input_stream;
+ private final int[] jjrounds = new int[50];
+ private final int[] jjstateSet = new int[100];
+ protected char curChar;
+
+ public CSSParserTokenManager(SimpleCharStream stream) {
+ if (SimpleCharStream.staticFlag)
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+ input_stream = stream;
+ }
+
+ public CSSParserTokenManager(SimpleCharStream stream, int lexState) {
+ this(stream);
+ SwitchTo(lexState);
+ }
+
+ public void ReInit(SimpleCharStream stream) {
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+ }
+
+ private void ReInitRounds() {
+ int i;
+ jjround = 0x80000001;
+ for (i = 50; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+ }
+
+ public void ReInit(SimpleCharStream stream, int lexState) {
+ ReInit(stream);
+ SwitchTo(lexState);
+ }
+
+ public void SwitchTo(int lexState) {
+ if (lexState >= 4 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+ }
+
+ protected Token jjFillToken() {
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+ }
+
+ int curLexState = 0;
+ int defaultLexState = 0;
+ int jjnewStateCnt;
+ int jjround;
+ int jjmatchedPos;
+ int jjmatchedKind;
+
+ public Token getNextToken() {
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop:
+ for (; ;) {
+ try {
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e) {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ return matchedToken;
+ }
+
+ switch (curLexState) {
+ case 0:
+ try {
+ input_stream.backup(0);
+ while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) {
+ continue EOFLoop;
+ }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ break;
+ case 1:
+ try {
+ input_stream.backup(0);
+ while (curChar <= 32 && (0x100002600L & (1L << curChar)) != 0L)
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e1) {
+ continue EOFLoop;
+ }
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_1();
+ break;
+ case 2:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_2();
+ break;
+ case 3:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_3();
+ break;
+ }
+ if (jjmatchedKind != 0x7fffffff) {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ matchedToken = jjFillToken();
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ return matchedToken;
+ } else {
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ continue EOFLoop;
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try {
+ input_stream.readChar();
+ input_stream.backup(1);
+ }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ } else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTokenManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/CSSParserTreeConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,40 @@
+/* Generated By:JJTree: Do not edit this line. .\CSSParserTreeConstants.java */
+
+package jaxx.compiler.parser.css;
+
+public interface CSSParserTreeConstants {
+ public int JJTSTYLESHEET = 0;
+ public int JJTRULE = 1;
+ public int JJTSELECTORS = 2;
+ public int JJTSELECTOR = 3;
+ public int JJTJAVACLASS = 4;
+ public int JJTID = 5;
+ public int JJTCLASS = 6;
+ public int JJTPSEUDOCLASS = 7;
+ public int JJTANIMATIONPROPERTIES = 8;
+ public int JJTANIMATIONPROPERTY = 9;
+ public int JJTDECLARATION = 10;
+ public int JJTPROPERTY = 11;
+ public int JJTEXPRESSION = 12;
+ public int JJTJAVACODE = 13;
+ public int JJTIDENTIFIER = 14;
+
+
+ public String[] jjtNodeName = {
+ "Stylesheet",
+ "Rule",
+ "Selectors",
+ "Selector",
+ "JavaClass",
+ "Id",
+ "Class",
+ "PseudoClass",
+ "AnimationProperties",
+ "AnimationProperty",
+ "Declaration",
+ "Property",
+ "Expression",
+ "JavaCode",
+ "Identifier",
+ };
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/CSSParserTreeConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/JJTCSSParserState.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,123 @@
+/* Generated By:JJTree: Do not edit this line. .\JJTCSSParserState.java */
+
+package jaxx.compiler.parser.css;
+
+class JJTCSSParserState {
+ private java.util.Stack<Node> nodes;
+ private java.util.Stack<Integer> marks;
+
+ private int sp; // number of nodes on stack
+ private int mk; // current mark
+ private boolean node_created;
+
+ JJTCSSParserState() {
+ nodes = new java.util.Stack<Node>();
+ marks = new java.util.Stack<Integer>();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Determines whether the current node was actually closed and
+ pushed. This should only be called in the final user action of a
+ node scope. */
+ boolean nodeCreated() {
+ return node_created;
+ }
+
+ /* Call this to reinitialize the node stack. It is called
+automatically by the parser's ReInit() method. */
+ void reset() {
+ nodes.removeAllElements();
+ marks.removeAllElements();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Returns the root node of the AST. It only makes sense to call
+this after a successful parse. */
+ Node rootNode() {
+ return nodes.elementAt(0);
+ }
+
+ /* Pushes a node on to the stack. */
+ void pushNode(Node n) {
+ nodes.push(n);
+ ++sp;
+ }
+
+ /* Returns the node on the top of the stack, and remove it from the
+ stack. */
+ Node popNode() {
+ if (--sp < mk) {
+ mk = marks.pop();
+ }
+ return nodes.pop();
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ Node peekNode() {
+ return nodes.peek();
+ }
+
+ /* Returns the number of children on the stack in the current node
+ scope. */
+ int nodeArity() {
+ return sp - mk;
+ }
+
+
+ void clearNodeScope(Node n) {
+ while (sp > mk) {
+ popNode();
+ }
+ mk = marks.pop();
+ }
+
+
+ void openNodeScope(Node n) {
+ marks.push(mk);
+ mk = sp;
+ n.jjtOpen();
+ }
+
+
+ /* A definite node is constructed from a specified number of
+children. That number of nodes are popped from the stack and
+made the children of the definite node. Then the definite node
+is pushed on to the stack. */
+ void closeNodeScope(Node n, int num) {
+ mk = marks.pop();
+ while (num-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, num);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ }
+
+
+ /* A conditional node is constructed if its condition is true. All
+the nodes that have been pushed since the node was opened are
+made children of the the conditional node, which is then pushed
+on to the stack. If the condition is false the node is not
+constructed and they are left on the stack. */
+ void closeNodeScope(Node n, boolean condition) {
+ if (condition) {
+ int a = nodeArity();
+ mk = marks.pop();
+ while (a-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, a);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ } else {
+ mk = marks.pop();
+ node_created = false;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/JJTCSSParserState.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/Node.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,51 @@
+/* Generated By:JJTree: Do not edit this line. Node.java */
+
+package jaxx.compiler.parser.css;
+
+/* All AST nodes must implement this interface. It provides basic
+ machinery for constructing the parent and child relationships
+ between nodes. */
+
+public interface Node {
+
+ /**
+ * This method is called after the node has been made the current
+ * node. It indicates that child nodes can now be added to it.
+ */
+ public void jjtOpen();
+
+ /**
+ * This method is called after all the child nodes have been
+ * added.
+ */
+ public void jjtClose();
+
+ /**
+ * This pair of methods are used to inform the node of its
+ * parent.
+ *
+ * @param n node
+ */
+ public void jjtSetParent(Node n);
+
+ public Node jjtGetParent();
+
+ /**
+ * This method tells the node to add its argument to the node's
+ * list of children.
+ *
+ * @param n node
+ * @param i pos
+ */
+ public void jjtAddChild(Node n, int i);
+
+ /**
+ * @param i pos
+ * @return a child node. The children are numbered
+ * from zero, left to right.
+ */
+ public Node jjtGetChild(int i);
+
+ /** @return the number of children the node has. */
+ public int jjtGetNumChildren();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Node.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/ParseException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,20 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+package jaxx.compiler.parser.css;
+
+public class ParseException extends jaxx.compiler.parser.java.ParseException {
+ private static final long serialVersionUID = 229575674880359031L;
+
+ public ParseException() {
+ super();
+ }
+
+
+ public ParseException(String message) {
+ super(message);
+ }
+
+
+ public ParseException(String message, int line, int column) {
+ super(message, line, column);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/ParseException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/SimpleCharStream.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,398 @@
+/* Generated By:JavaCC: Do not edit this line. SimpleCharStream.java Version 4.0 */
+package jaxx.compiler.parser.css;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (without unicode processing).
+ */
+
+public class SimpleCharStream {
+ public static final boolean staticFlag = false;
+ int bufsize;
+ int available;
+ int tokenBegin;
+ public int bufpos = -1;
+ protected int bufline[];
+ protected int bufcolumn[];
+
+ protected int column = 0;
+ protected int line = 1;
+
+ protected boolean prevCharIsCR = false;
+ protected boolean prevCharIsLF = false;
+
+ protected java.io.Reader inputStream;
+
+ protected char[] buffer;
+ protected int maxNextCharInd = 0;
+ protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) {
+ tabSize = i;
+ }
+
+ protected int getTabSize(int i) {
+ return tabSize;
+ }
+
+
+ protected void ExpandBuff(boolean wrapAround) {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try {
+ if (wrapAround) {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos += (bufsize - tokenBegin));
+ } else {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ maxNextCharInd = (bufpos -= tokenBegin);
+ }
+ }
+ catch (Throwable t) {
+ throw new Error(t.getMessage());
+ }
+
+
+ bufsize += 2048;
+ available = bufsize;
+ tokenBegin = 0;
+ }
+
+ protected void FillBuff() throws java.io.IOException {
+ if (maxNextCharInd == available) {
+ if (available == bufsize) {
+ if (tokenBegin > 2048) {
+ bufpos = maxNextCharInd = 0;
+ available = tokenBegin;
+ } else if (tokenBegin < 0)
+ bufpos = maxNextCharInd = 0;
+ else
+ ExpandBuff(false);
+ } else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ int i;
+ try {
+ if ((i = inputStream.read(buffer, maxNextCharInd,
+ available - maxNextCharInd)) == -1) {
+ inputStream.close();
+ throw new java.io.IOException();
+ } else
+ maxNextCharInd += i;
+ }
+ catch (java.io.IOException e) {
+ --bufpos;
+ backup(0);
+ if (tokenBegin == -1)
+ tokenBegin = bufpos;
+ throw e;
+ }
+ }
+
+ public char BeginToken() throws java.io.IOException {
+ tokenBegin = -1;
+ char c = readChar();
+ tokenBegin = bufpos;
+
+ return c;
+ }
+
+ protected void UpdateLineColumn(char c) {
+ column++;
+
+ if (prevCharIsLF) {
+ prevCharIsLF = false;
+ line += (column = 1);
+ } else if (prevCharIsCR) {
+ prevCharIsCR = false;
+ if (c == '\n') {
+ prevCharIsLF = true;
+ } else
+ line += (column = 1);
+ }
+
+ switch (c) {
+ case '\r':
+ prevCharIsCR = true;
+ break;
+ case '\n':
+ prevCharIsLF = true;
+ break;
+ case '\t':
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default:
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ public char readChar() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ if (++bufpos >= maxNextCharInd)
+ FillBuff();
+
+ char c = buffer[bufpos];
+
+ UpdateLineColumn(c);
+ return (c);
+ }
+
+ /**
+ * @return ???
+ * @see #getEndColumn
+ * @deprecated
+ */
+
+ public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @return ???
+ * @see #getEndLine
+ * @deprecated
+ */
+
+ public int getLine() {
+ return bufline[bufpos];
+ }
+
+ public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+
+ public SimpleCharStream(java.io.Reader dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.Reader dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length) {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public SimpleCharStream(java.io.InputStream dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public String GetImage() {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ public char[] GetSuffix(int len) {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ public void Done() {
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ *
+ * @param newLine ?
+ * @param newCol ?
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol) {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin) {
+ len = bufpos - tokenBegin + inBuf + 1;
+ } else {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k;
+ int nextColDiff, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len) {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len) {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleCharStream.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/SimpleNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,122 @@
+/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
+
+package jaxx.compiler.parser.css;
+
+public class SimpleNode implements Node {
+ protected Node parent;
+ protected Node[] children;
+ protected int id;
+ protected CSSParser parser;
+ public Token firstToken;
+ public Token lastToken;
+
+
+ public SimpleNode(int i) {
+ id = i;
+ }
+
+ public SimpleNode(CSSParser p, int i) {
+ this(i);
+ parser = p;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void jjtOpen() {
+ }
+
+ public void jjtClose() {
+ }
+
+ public void jjtSetParent(Node n) {
+ parent = n;
+ }
+
+ public Node jjtGetParent() {
+ return parent;
+ }
+
+ public SimpleNode getParent() {
+ return (SimpleNode) parent;
+ }
+
+ public void jjtAddChild(Node n, int i) {
+ if (children == null) {
+ children = new Node[i + 1];
+ } else if (i >= children.length) {
+ Node c[] = new Node[i + 1];
+ System.arraycopy(children, 0, c, 0, children.length);
+ children = c;
+ }
+ children[i] = n;
+ }
+
+ public Node jjtGetChild(int i) {
+ return children[i];
+ }
+
+ public SimpleNode getChild(int i) {
+ return (SimpleNode) children[i];
+ }
+
+ public int jjtGetNumChildren() {
+ return (children == null) ? 0 : children.length;
+ }
+
+ /* You can override these two methods in subclasses of SimpleNode to
+customize the way the node appears when the tree is dumped. If
+your output uses more than one line you should override
+toString(String), otherwise overriding toString() is probably all
+you need to do. */
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getText() + "]";
+ }
+
+ public String toString(String prefix) {
+ return prefix + toString();
+ }
+
+ /* Override this method if you want to customize how the node dumps
+ out its children. */
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+ if (children != null) {
+ for (Node aChildren : children) {
+ SimpleNode n = (SimpleNode) aChildren;
+ if (n != null) {
+ n.dump(prefix + " ");
+ }
+ }
+ }
+ }
+
+ private void appendSpecialTokens(StringBuffer s, Token st) {
+ if (st != null) {
+ appendSpecialTokens(s, st.specialToken);
+ s.append(st.image);
+ }
+ }
+
+
+ /** @return the text of the tokens comprising this node. */
+ public String getText() {
+ StringBuffer text = new StringBuffer();
+ Token t = firstToken;
+ while (t != null) {
+ appendSpecialTokens(text, t.specialToken);
+ text.append(t.image);
+ if (t == lastToken)
+ break;
+ t = t.next;
+ }
+
+ return text.toString();
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/SimpleNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/Token.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,76 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+package jaxx.compiler.parser.css;
+
+/** Describes the input token stream. */
+
+public class Token {
+
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /** The string image of the token. */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /** Returns the image. */
+ public String toString() {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ * <p/>
+ * case MyParserConstants.ID : return new IDToken();
+ * <p/>
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ *
+ * @param ofKind kind of token
+ * @return the new token
+ */
+ public static Token newToken(int ofKind) {
+ switch (ofKind) {
+ default:
+ return new Token();
+ }
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/Token.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/css/TokenMgrError.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,126 @@
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+package jaxx.compiler.parser.css;
+
+public class TokenMgrError extends Error {
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /** Lexical error occured. */
+ static final int LEXICAL_ERROR = 0;
+
+ /** An attempt wass made to create a second instance of a static token manager. */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /** Tried to change to an invalid lexical state. */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /** Detected (and bailed out of) an infinite loop in the token manager. */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+ private static final long serialVersionUID = -4308847190164230336L;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ *
+ * @param str text to espace
+ * @return the espaced text
+ */
+ protected static String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i)) {
+ case 0:
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * @param EOFSeen : indicates if EOF caused the lexicl error
+ * @param lexState : lexical state in which this error occured
+ * @param errorLine : line number when the error occured
+ * @param errorColumn : column number when the error occured
+ * @param errorAfter : prefix that was seen before this error occured
+ * @param curChar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ * @return a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return ("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ * <p/>
+ * "Internal Error : Please file a bug report .... "
+ * <p/>
+ * from this method for such cases in the release version of your parser.
+ */
+ @Override
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/css/TokenMgrError.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JJTJavaParserState.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,123 @@
+/* Generated By:JJTree: Do not edit this line. .\JJTJavaParserState.java */
+
+package jaxx.compiler.parser.java;
+
+class JJTJavaParserState {
+ private java.util.Stack<Node> nodes;
+ private java.util.Stack<Integer> marks;
+
+ private int sp; // number of nodes on stack
+ private int mk; // current mark
+ private boolean node_created;
+
+ JJTJavaParserState() {
+ nodes = new java.util.Stack<Node>();
+ marks = new java.util.Stack<Integer>();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Determines whether the current node was actually closed and
+ pushed. This should only be called in the final user action of a
+ node scope. */
+ boolean nodeCreated() {
+ return node_created;
+ }
+
+ /* Call this to reinitialize the node stack. It is called
+automatically by the parser's ReInit() method. */
+ void reset() {
+ nodes.removeAllElements();
+ marks.removeAllElements();
+ sp = 0;
+ mk = 0;
+ }
+
+ /* Returns the root node of the AST. It only makes sense to call
+this after a successful parse. */
+ Node rootNode() {
+ return nodes.elementAt(0);
+ }
+
+ /* Pushes a node on to the stack. */
+ void pushNode(Node n) {
+ nodes.push(n);
+ ++sp;
+ }
+
+ /* Returns the node on the top of the stack, and remove it from the
+ stack. */
+ Node popNode() {
+ if (--sp < mk) {
+ mk = marks.pop();
+ }
+ return nodes.pop();
+ }
+
+ /* Returns the node currently on the top of the stack. */
+ Node peekNode() {
+ return nodes.peek();
+ }
+
+ /* Returns the number of children on the stack in the current node
+ scope. */
+ int nodeArity() {
+ return sp - mk;
+ }
+
+
+ void clearNodeScope(Node n) {
+ while (sp > mk) {
+ popNode();
+ }
+ mk = marks.pop();
+ }
+
+
+ void openNodeScope(Node n) {
+ marks.push(mk);
+ mk = sp;
+ n.jjtOpen();
+ }
+
+
+ /* A definite node is constructed from a specified number of
+children. That number of nodes are popped from the stack and
+made the children of the definite node. Then the definite node
+is pushed on to the stack. */
+ void closeNodeScope(Node n, int num) {
+ mk = marks.pop();
+ while (num-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, num);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ }
+
+
+ /* A conditional node is constructed if its condition is true. All
+the nodes that have been pushed since the node was opened are
+made children of the the conditional node, which is then pushed
+on to the stack. If the condition is false the node is not
+constructed and they are left on the stack. */
+ void closeNodeScope(Node n, boolean condition) {
+ if (condition) {
+ int a = nodeArity();
+ mk = marks.pop();
+ while (a-- > 0) {
+ Node c = popNode();
+ c.jjtSetParent(n);
+ n.jjtAddChild(c, a);
+ }
+ n.jjtClose();
+ pushNode(n);
+ node_created = true;
+ } else {
+ mk = marks.pop();
+ node_created = false;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JJTJavaParserState.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Java1.5.jj)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,5125 @@
+/*@bgen(jjtree) Generated By:JJTree: Do not edit this line. ./Java1.5.jj */
+/*@egen*/
+/*
+ * Copyright \u00a9 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements. Use is subject to license terms.
+ * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries. Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited. Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+// Slightly modified version of javacc's reference 1.5 grammar, tweaked for
+// usage with JAXX. There are two main areas of changes: several new
+// nonterminals were added to make identifying certain constructs easier,
+// and the Line nonterminal was added to support JAXX's script tags.
+// Several of the new changes are inefficient and require excess lookahead,
+// but at this point I'd rather have inefficiency than risk breaking it during
+// attempted optimizations.
+
+options {
+ JAVA_UNICODE_ESCAPE = true;
+ ERROR_REPORTING = false;
+ STATIC = false;
+ JDK_VERSION = "1.4";
+}
+
+PARSER_BEGIN(JavaParser)
+package jaxx.parser;
+
+import java.io.*;
+
+/**
+ * Grammar to parse Java version 1.5
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser/*@bgen(jjtree)*/implements JavaParserTreeConstants/*@egen*/
+{/*@bgen(jjtree)*/
+ protected JJTJavaParserState jjtree = new JJTJavaParserState();
+
+/*@egen*/
+ /**
+ * Class to hold modifiers.
+ */
+ static public final class ModifierSet
+ {
+ /* Definitions of the bits in the modifiers field. */
+ public static final int PUBLIC = 0x0001;
+ public static final int PROTECTED = 0x0002;
+ public static final int PRIVATE = 0x0004;
+ public static final int ABSTRACT = 0x0008;
+ public static final int STATIC = 0x0010;
+ public static final int FINAL = 0x0020;
+ public static final int SYNCHRONIZED = 0x0040;
+ public static final int NATIVE = 0x0080;
+ public static final int TRANSIENT = 0x0100;
+ public static final int VOLATILE = 0x0200;
+ public static final int STRICTFP = 0x1000;
+
+ /** A set of accessors that indicate whether the specified modifier
+ is in the set. */
+
+ public boolean isPublic(int modifiers)
+ {
+ return (modifiers & PUBLIC) != 0;
+ }
+
+ public boolean isProtected(int modifiers)
+ {
+ return (modifiers & PROTECTED) != 0;
+ }
+
+ public boolean isPrivate(int modifiers)
+ {
+ return (modifiers & PRIVATE) != 0;
+ }
+
+ public boolean isStatic(int modifiers)
+ {
+ return (modifiers & STATIC) != 0;
+ }
+
+ public boolean isAbstract(int modifiers)
+ {
+ return (modifiers & ABSTRACT) != 0;
+ }
+
+ public boolean isFinal(int modifiers)
+ {
+ return (modifiers & FINAL) != 0;
+ }
+
+ public boolean isNative(int modifiers)
+ {
+ return (modifiers & NATIVE) != 0;
+ }
+
+ public boolean isStrictfp(int modifiers)
+ {
+ return (modifiers & STRICTFP) != 0;
+ }
+
+ public boolean isSynchronized(int modifiers)
+ {
+ return (modifiers & SYNCHRONIZED) != 0;
+ }
+
+ public boolean isTransient(int modifiers)
+ {
+ return (modifiers & TRANSIENT) != 0;
+ }
+
+ public boolean isVolatile(int modifiers)
+ {
+ return (modifiers & VOLATILE) != 0;
+ }
+
+ /**
+ * Removes the given modifier.
+ */
+ static int removeModifier(int modifiers, int mod)
+ {
+ return modifiers & ~mod;
+ }
+ }
+
+ public JavaParser(String fileName)
+ {
+ this(System.in);
+ try { ReInit(new FileInputStream(new File(fileName))); }
+ catch(Exception e) { e.printStackTrace(); }
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public SimpleNode popNode()
+ {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+ public static void main(String args[]) {
+ JavaParser parser;
+ if (args.length == 0) {
+ System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
+ parser = new JavaParser(System.in);
+ } else if (args.length == 1) {
+ System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
+ try {
+ parser = new JavaParser(new java.io.FileInputStream(args[0]));
+ } catch (java.io.FileNotFoundException e) {
+ System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
+ return;
+ }
+ } else {
+ System.out.println("Java Parser Version 1.1: Usage is one of:");
+ System.out.println(" java JavaParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java JavaParser inputfile");
+ return;
+ }
+ try {
+ parser.CompilationUnit();
+ System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
+ }
+ }
+
+}
+
+PARSER_END(JavaParser)
+
+/* COMMENTS */
+
+MORE :
+{
+ <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
+|
+ "/*" : IN_MULTI_LINE_COMMENT
+}
+
+SPECIAL_TOKEN:
+{
+ <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+>
+}
+
+SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?>
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+ <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+ <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+MORE :
+{
+ < ~[] >
+}
+
+/* RESERVED WORDS AND LITERALS */
+
+TOKEN :
+{
+ < ABSTRACT: "abstract" >
+| < ASSERT: "assert" >
+| < BOOLEAN: "boolean" >
+| < BREAK: "break" >
+| < BYTE: "byte" >
+| < CASE: "case" >
+| < CATCH: "catch" >
+| < CHAR: "char" >
+| < CLASS: "class" >
+| < CONST: "const" >
+| < CONTINUE: "continue" >
+| < _DEFAULT: "default" >
+| < DO: "do" >
+| < DOUBLE: "double" >
+| < ELSE: "else" >
+| < ENUM: "enum" >
+| < EXTENDS: "extends" >
+| < FALSE: "false" >
+| < FINAL: "final" >
+| < FINALLY: "finally" >
+| < FLOAT: "float" >
+| < FOR: "for" >
+| < GOTO: "goto" >
+| < IF: "if" >
+| < IMPLEMENTS: "implements" >
+| < IMPORT: "import" >
+| < INSTANCEOF: "instanceof" >
+| < INT: "int" >
+| < INTERFACE: "interface" >
+| < LONG: "long" >
+| < NATIVE: "native" >
+| < NEW: "new" >
+| < NULL: "null" >
+| < PACKAGE: "package">
+| < PRIVATE: "private" >
+| < PROTECTED: "protected" >
+| < PUBLIC: "public" >
+| < RETURN: "return" >
+| < SHORT: "short" >
+| < STATIC: "static" >
+| < STRICTFP: "strictfp" >
+| < SUPER: "super" >
+| < SWITCH: "switch" >
+| < SYNCHRONIZED: "synchronized" >
+| < THIS: "this" >
+| < THROW: "throw" >
+| < THROWS: "throws" >
+| < TRANSIENT: "transient" >
+| < TRUE: "true" >
+| < TRY: "try" >
+| < VOID: "void" >
+| < VOLATILE: "volatile" >
+| < WHILE: "while" >
+}
+
+/* LITERALS */
+
+TOKEN :
+{
+ < INTEGER_LITERAL:
+ <DECIMAL_LITERAL> (["l","L"])?
+ | <HEX_LITERAL> (["l","L"])?
+ | <OCTAL_LITERAL> (["l","L"])?
+ >
+|
+ < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
+|
+ < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
+|
+ < #OCTAL_LITERAL: "0" (["0"-"7"])* >
+|
+ < FLOATING_POINT_LITERAL:
+ <DECIMAL_FLOATING_POINT_LITERAL>
+ | <HEXADECIMAL_FLOATING_POINT_LITERAL>
+ >
+|
+ < #DECIMAL_FLOATING_POINT_LITERAL:
+ (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])?
+ | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"]
+ >
+|
+ < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|
+ < #HEXADECIMAL_FLOATING_POINT_LITERAL:
+ "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ >
+|
+ < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
+|
+ < CHARACTER_LITERAL:
+ "'"
+ ( (~["'","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )
+ "'"
+ >
+|
+ < STRING_LITERAL:
+ "\""
+ ( (~["\"","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )*
+ "\""
+ >
+}
+
+/* IDENTIFIERS */
+
+TOKEN :
+{
+ < IDENTIFIER: <LETTER> (<PART_LETTER>)* >
+|
+ < #LETTER:
+ [ // all chars for which Character.isIdentifierStart is true
+ "$",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u064a",
+ "\u0671"-"\u06d3",
+ "\u06d5",
+ "\u06e5"-"\u06e6",
+ "\u06fa"-"\u06fc",
+ "\u0710",
+ "\u0712"-"\u072c",
+ "\u0780"-"\u07a5",
+ "\u0905"-"\u0939",
+ "\u093d",
+ "\u0950",
+ "\u0958"-"\u0961",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e1",
+ "\u09f0"-"\u09f3",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a72"-"\u0a74",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3d",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c60"-"\u0c61",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d60"-"\u0d61",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0e01"-"\u0e30",
+ "\u0e32"-"\u0e33",
+ "\u0e3f"-"\u0e46",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb0",
+ "\u0eb2"-"\u0eb3",
+ "\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f40"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f88"-"\u0f8b",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u1050"-"\u1055",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17b3",
+ "\u17db",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a8",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u203f"-"\u2040",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u3029",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d",
+ "\ufb1f"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\uff04",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6"
+ ]
+ >
+|
+ < #PART_LETTER:
+ [ // all chars for which Character.isIdentifierPart is true
+ "\u0000"-"\u0008",
+ "\u000e"-"\u001b",
+ "$",
+ "0"-"9",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u007f"-"\u009f",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u0300"-"\u034e",
+ "\u0360"-"\u0362",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u0483"-"\u0486",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u0591"-"\u05a1",
+ "\u05a3"-"\u05b9",
+ "\u05bb"-"\u05bd",
+ "\u05bf",
+ "\u05c1"-"\u05c2",
+ "\u05c4",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u0655",
+ "\u0660"-"\u0669",
+ "\u0670"-"\u06d3",
+ "\u06d5"-"\u06dc",
+ "\u06df"-"\u06e8",
+ "\u06ea"-"\u06ed",
+ "\u06f0"-"\u06fc",
+ "\u070f"-"\u072c",
+ "\u0730"-"\u074a",
+ "\u0780"-"\u07b0",
+ "\u0901"-"\u0903",
+ "\u0905"-"\u0939",
+ "\u093c"-"\u094d",
+ "\u0950"-"\u0954",
+ "\u0958"-"\u0963",
+ "\u0966"-"\u096f",
+ "\u0981"-"\u0983",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09bc",
+ "\u09be"-"\u09c4",
+ "\u09c7"-"\u09c8",
+ "\u09cb"-"\u09cd",
+ "\u09d7",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e3",
+ "\u09e6"-"\u09f3",
+ "\u0a02",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a3c",
+ "\u0a3e"-"\u0a42",
+ "\u0a47"-"\u0a48",
+ "\u0a4b"-"\u0a4d",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a66"-"\u0a74",
+ "\u0a81"-"\u0a83",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abc"-"\u0ac5",
+ "\u0ac7"-"\u0ac9",
+ "\u0acb"-"\u0acd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0ae6"-"\u0aef",
+ "\u0b01"-"\u0b03",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3c"-"\u0b43",
+ "\u0b47"-"\u0b48",
+ "\u0b4b"-"\u0b4d",
+ "\u0b56"-"\u0b57",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b66"-"\u0b6f",
+ "\u0b82"-"\u0b83",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0bbe"-"\u0bc2",
+ "\u0bc6"-"\u0bc8",
+ "\u0bca"-"\u0bcd",
+ "\u0bd7",
+ "\u0be7"-"\u0bef",
+ "\u0c01"-"\u0c03",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c3e"-"\u0c44",
+ "\u0c46"-"\u0c48",
+ "\u0c4a"-"\u0c4d",
+ "\u0c55"-"\u0c56",
+ "\u0c60"-"\u0c61",
+ "\u0c66"-"\u0c6f",
+ "\u0c82"-"\u0c83",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cbe"-"\u0cc4",
+ "\u0cc6"-"\u0cc8",
+ "\u0cca"-"\u0ccd",
+ "\u0cd5"-"\u0cd6",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0ce6"-"\u0cef",
+ "\u0d02"-"\u0d03",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d3e"-"\u0d43",
+ "\u0d46"-"\u0d48",
+ "\u0d4a"-"\u0d4d",
+ "\u0d57",
+ "\u0d60"-"\u0d61",
+ "\u0d66"-"\u0d6f",
+ "\u0d82"-"\u0d83",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0dca",
+ "\u0dcf"-"\u0dd4",
+ "\u0dd6",
+ "\u0dd8"-"\u0ddf",
+ "\u0df2"-"\u0df3",
+ "\u0e01"-"\u0e3a",
+ "\u0e3f"-"\u0e4e",
+ "\u0e50"-"\u0e59",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb9",
+ "\u0ebb"-"\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0ec8"-"\u0ecd",
+ "\u0ed0"-"\u0ed9",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f18"-"\u0f19",
+ "\u0f20"-"\u0f29",
+ "\u0f35",
+ "\u0f37",
+ "\u0f39",
+ "\u0f3e"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f71"-"\u0f84",
+ "\u0f86"-"\u0f8b",
+ "\u0f90"-"\u0f97",
+ "\u0f99"-"\u0fbc",
+ "\u0fc6",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u102c"-"\u1032",
+ "\u1036"-"\u1039",
+ "\u1040"-"\u1049",
+ "\u1050"-"\u1059",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u1369"-"\u1371",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17d3",
+ "\u17db",
+ "\u17e0"-"\u17e9",
+ "\u180b"-"\u180e",
+ "\u1810"-"\u1819",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a9",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u200c"-"\u200f",
+ "\u202a"-"\u202e",
+ "\u203f"-"\u2040",
+ "\u206a"-"\u206f",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u20d0"-"\u20dc",
+ "\u20e1",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u302f",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u3099"-"\u309a",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe20"-"\ufe23",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\ufeff",
+ "\uff04",
+ "\uff10"-"\uff19",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6",
+ "\ufff9"-"\ufffb"
+ ]
+ >
+}
+
+/* SEPARATORS */
+
+TOKEN :
+{
+ < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+| < AT: "@" >
+}
+
+/* OPERATORS */
+
+TOKEN :
+{
+ < ASSIGN: "=" >
+| < LT: "<" >
+| < BANG: "!" >
+| < TILDE: "~" >
+| < HOOK: "?" >
+| < COLON: ":" >
+| < EQ: "==" >
+| < LE: "<=" >
+| < GE: ">=" >
+| < NE: "!=" >
+| < SC_OR: "||" >
+| < SC_AND: "&&" >
+| < INCR: "++" >
+| < DECR: "--" >
+| < PLUS: "+" >
+| < MINUS: "-" >
+| < STAR: "*" >
+| < SLASH: "/" >
+| < BIT_AND: "&" >
+| < BIT_OR: "|" >
+| < XOR: "^" >
+| < REM: "%" >
+| < LSHIFT: "<<" >
+| < PLUSASSIGN: "+=" >
+| < MINUSASSIGN: "-=" >
+| < STARASSIGN: "*=" >
+| < SLASHASSIGN: "/=" >
+| < ANDASSIGN: "&=" >
+| < ORASSIGN: "|=" >
+| < XORASSIGN: "^=" >
+| < REMASSIGN: "%=" >
+| < LSHIFTASSIGN: "<<=" >
+| < RSIGNEDSHIFTASSIGN: ">>=" >
+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
+| < ELLIPSIS: "..." >
+}
+
+/* >'s need special attention due to generics syntax. */
+TOKEN :
+{
+ < RUNSIGNEDSHIFT: ">>>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT;
+ input_stream.backup(2);
+ matchedToken.image = ">";
+ }
+| < RSIGNEDSHIFT: ">>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT;
+ input_stream.backup(1);
+ matchedToken.image = ">";
+ }
+| < GT: ">" >
+}
+
+boolean Line() :
+{/*@bgen(jjtree) Line */
+ SimpleNode jjtn000 = new SimpleNode(JJTLINE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers;
+}
+{/*@bgen(jjtree) Line */
+ try {
+/*@egen*/
+ <EOF>/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return true;
+ }
+|
+ LOOKAHEAD(BlockStatement())
+ BlockStatement()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{")
+ ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false))
+ ClassOrInterfaceBodyDeclaration(false)/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ LOOKAHEAD(Expression())
+ Expression()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }
+|
+ ImportDeclaration()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/ {
+ return false;
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*****************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ *****************************************/
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit():
+{/*@bgen(jjtree) CompilationUnit */
+ SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) CompilationUnit */
+ try {
+/*@egen*/
+ [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ]
+ ( ImportDeclaration() )*
+ ( TypeDeclaration() )*
+ ( < "\u001a" > )?
+ ( <STUFF_TO_IGNORE: ~[]> )?
+ <EOF>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PackageDeclaration():
+{/*@bgen(jjtree) PackageDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PackageDeclaration */
+ try {
+/*@egen*/
+ Modifiers() "package" Name() ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ImportDeclaration():
+{/*@bgen(jjtree) ImportDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ImportDeclaration */
+ try {
+/*@egen*/
+ "import" [ "static" ] Name() [ "." "*" ] ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+
+int Modifiers():
+{/*@bgen(jjtree) Modifiers */
+ SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers = 0;
+}
+{/*@bgen(jjtree) Modifiers */
+ try {
+/*@egen*/
+ (
+ LOOKAHEAD(2)
+ (
+ "public" { modifiers |= ModifierSet.PUBLIC; }
+ |
+ "static" { modifiers |= ModifierSet.STATIC; }
+ |
+ "protected" { modifiers |= ModifierSet.PROTECTED; }
+ |
+ "private" { modifiers |= ModifierSet.PRIVATE; }
+ |
+ "final" { modifiers |= ModifierSet.FINAL; }
+ |
+ "abstract" { modifiers |= ModifierSet.ABSTRACT; }
+ |
+ "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; }
+ |
+ "native" { modifiers |= ModifierSet.NATIVE; }
+ |
+ "transient" { modifiers |= ModifierSet.TRANSIENT; }
+ |
+ "volatile" { modifiers |= ModifierSet.VOLATILE; }
+ |
+ "strictfp" { modifiers |= ModifierSet.STRICTFP; }
+ |
+ Annotation()
+ )
+ )*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+
+ {
+ return modifiers;
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * Declaration syntax follows.
+ */
+void TypeDeclaration():
+{/*@bgen(jjtree) TypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers;
+}
+{/*@bgen(jjtree) TypeDeclaration */
+ try {
+/*@egen*/
+ ";"
+|
+ modifiers = Modifiers()
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void ClassOrInterfaceDeclaration(int modifiers):
+{/*@bgen(jjtree) ClassOrInterfaceDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ boolean isInterface = false;
+}
+{/*@bgen(jjtree) ClassOrInterfaceDeclaration */
+ try {
+/*@egen*/
+ ( "class" | "interface" { isInterface = true; } )
+ <IDENTIFIER>
+ [ TypeParameters() ]
+ [ ExtendsList(isInterface) ]
+ [ ImplementsList(isInterface) ]
+ ClassOrInterfaceBody(isInterface)/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ExtendsList(boolean isInterface):
+{/*@bgen(jjtree) ExtendsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ boolean extendsMoreThanOne = false;
+}
+{/*@bgen(jjtree) ExtendsList */
+ try {
+/*@egen*/
+ "extends" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ if (extendsMoreThanOne && !isInterface)
+ throw new ParseException("A class cannot extend more than one other class");
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ImplementsList(boolean isInterface):
+{/*@bgen(jjtree) ImplementsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ImplementsList */
+ try {
+/*@egen*/
+ "implements" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() )*/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot implement other interfaces");
+ }/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EnumDeclaration(int modifiers):
+{/*@bgen(jjtree) EnumDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EnumDeclaration */
+ try {
+/*@egen*/
+ "enum" <IDENTIFIER>
+ [ ImplementsList(false) ]
+ EnumBody()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EnumBody():
+{/*@bgen(jjtree) EnumBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EnumBody */
+ try {
+/*@egen*/
+ "{"
+ [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
+ [ "," ]
+ [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
+ "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EnumConstant():
+{/*@bgen(jjtree) EnumConstant */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EnumConstant */
+ try {
+/*@egen*/
+ Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeParameters():
+{/*@bgen(jjtree) TypeParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeParameters */
+ try {
+/*@egen*/
+ "<" TypeParameter() ( "," TypeParameter() )* ">"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeParameter():
+{/*@bgen(jjtree) TypeParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeParameter */
+ try {
+/*@egen*/
+ <IDENTIFIER> [ TypeBound() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeBound():
+{/*@bgen(jjtree) TypeBound */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeBound */
+ try {
+/*@egen*/
+ "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ClassOrInterfaceBody(boolean isInterface):
+{/*@bgen(jjtree) ClassOrInterfaceBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ClassOrInterfaceBody */
+ try {
+/*@egen*/
+ "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ClassOrInterfaceBodyDeclaration(boolean isInterface):
+{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ boolean isNestedInterface = false;
+ int modifiers;
+}
+{/*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ Initializer()/*@bgen(jjtree)*/
+ {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ }
+/*@egen*/
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot have initializers");
+ }
+|
+ modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do
+ // more checks, pass the modifiers down to the member
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" )
+ ConstructorDeclaration()
+ |
+ LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) )
+ FieldDeclaration(modifiers)
+ |
+ MethodDeclaration(modifiers)
+ )
+|
+ ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void FieldDeclaration(int modifiers):
+{/*@bgen(jjtree) FieldDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) FieldDeclaration */
+ try {
+/*@egen*/
+ // Modifiers are already matched in the caller
+ Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void VariableDeclarator():
+{/*@bgen(jjtree) VariableDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) VariableDeclarator */
+ try {
+/*@egen*/
+ VariableDeclaratorId() [ "=" VariableInitializer() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void VariableDeclaratorId():
+{/*@bgen(jjtree) VariableDeclaratorId */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) VariableDeclaratorId */
+ try {
+/*@egen*/
+ <IDENTIFIER> ( "[" "]" )*/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void VariableInitializer():
+{/*@bgen(jjtree) VariableInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) VariableInitializer */
+ try {
+/*@egen*/
+ ArrayInitializer()
+|
+ Expression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ArrayInitializer():
+{/*@bgen(jjtree) ArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ArrayInitializer */
+ try {
+/*@egen*/
+ "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MethodDeclaration(int modifiers):
+{/*@bgen(jjtree) MethodDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MethodDeclaration */
+ try {
+/*@egen*/
+ // Modifiers already matched in the caller!
+ [ TypeParameters() ]
+ ResultType()
+ MethodDeclarator() [ "throws" NameList() ]
+ ( Block() | ";" )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MethodDeclarator():
+{/*@bgen(jjtree) MethodDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MethodDeclarator */
+ try {
+/*@egen*/
+ <IDENTIFIER> FormalParameters() ( "[" "]" )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void FormalParameters():
+{/*@bgen(jjtree) FormalParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) FormalParameters */
+ try {
+/*@egen*/
+ "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void FormalParameter():
+{/*@bgen(jjtree) FormalParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) FormalParameter */
+ try {
+/*@egen*/
+ Modifiers() Type() [ "..." ] VariableDeclaratorId()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConstructorDeclaration():
+{/*@bgen(jjtree) ConstructorDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConstructorDeclaration */
+ try {
+/*@egen*/
+ [ TypeParameters() ]
+ // Modifiers matched in the caller
+ <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+ "{"
+ [ LOOKAHEAD(ExplicitConstructorInvocation())
+ ExplicitConstructorInvocation()
+ ]
+ ( BlockStatement() )*
+ "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ExplicitConstructorInvocation():
+{/*@bgen(jjtree) ExplicitConstructorInvocation */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ExplicitConstructorInvocation */
+ try {
+/*@egen*/
+ ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ]
+ [ TypeArguments() ] ("this"|"super") Arguments() ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Initializer():
+{/*@bgen(jjtree) Initializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Initializer */
+ try {
+/*@egen*/
+ [ "static" ] Block()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type():
+{/*@bgen(jjtree) Type */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Type */
+ try {
+/*@egen*/
+ LOOKAHEAD(2) ReferenceType()
+ |
+ PrimitiveType()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ReferenceType():
+{/*@bgen(jjtree) ReferenceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ReferenceType */
+ try {
+/*@egen*/
+ PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+
+ |
+ ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ClassOrInterfaceType():
+{/*@bgen(jjtree) ClassOrInterfaceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ClassOrInterfaceType */
+ try {
+/*@egen*/
+ <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ]
+ ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeArguments():
+{/*@bgen(jjtree) TypeArguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeArguments */
+ try {
+/*@egen*/
+ "<" TypeArgument() ( "," TypeArgument() )* ">"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TypeArgument():
+{/*@bgen(jjtree) TypeArgument */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TypeArgument */
+ try {
+/*@egen*/
+ ReferenceType()
+ |
+ "?" [ WildcardBounds() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void WildcardBounds():
+{/*@bgen(jjtree) WildcardBounds */
+ SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) WildcardBounds */
+ try {
+/*@egen*/
+ "extends" ReferenceType()
+ |
+ "super" ReferenceType()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+void PrimitiveType():
+{/*@bgen(jjtree) PrimitiveType */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimitiveType */
+ try {
+/*@egen*/
+ "boolean"
+|
+ "char"
+|
+ "byte"
+|
+ "short"
+|
+ "int"
+|
+ "long"
+|
+ "float"
+|
+ "double"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ResultType():
+{/*@bgen(jjtree) ResultType */
+ SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ResultType */
+ try {
+/*@egen*/
+ "void"
+|
+ Type()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Name():
+/*
+ * A lookahead of 2 is required below since "Name" can be followed
+ * by a ".*" when used in the context of an "ImportDeclaration".
+ */
+{/*@bgen(jjtree) Name */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAME);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Name */
+ try {
+/*@egen*/
+ <IDENTIFIER>
+ ( LOOKAHEAD(2) "." <IDENTIFIER>
+ )*/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void NameList():
+{/*@bgen(jjtree) NameList */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) NameList */
+ try {
+/*@egen*/
+ Name() ( "," Name() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/*
+ * Expression syntax follows.
+ */
+
+void Expression():
+/*
+ * This expansion has been written this way instead of:
+ * Assignment() | ConditionalExpression()
+ * for performance reasons.
+ * However, it is a weakening of the grammar for it allows the LHS of
+ * assignments to be any conditional expression whereas it can only be
+ * a primary expression. Consider adding a semantic predicate to work
+ * around this.
+ */
+{/*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Expression */
+ try {
+/*@egen*/
+ ConditionalExpression()
+ [
+ LOOKAHEAD(2)
+ AssignmentOperator() Expression()
+ ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AssignmentOperator():
+{/*@bgen(jjtree) AssignmentOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AssignmentOperator */
+ try {
+/*@egen*/
+ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AssignmentExpression():
+{/*@bgen(jjtree) AssignmentExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AssignmentExpression */
+ try {
+/*@egen*/
+ PrimaryExpression() AssignmentOperator() Expression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConditionalExpression():
+{/*@bgen(jjtree) ConditionalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConditionalExpression */
+ try {
+/*@egen*/
+ ConditionalOrExpression() [ "?" Expression() ":" Expression() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConditionalOrExpression():
+{/*@bgen(jjtree) ConditionalOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConditionalOrExpression */
+ try {
+/*@egen*/
+ ConditionalAndExpression() ( "||" ConditionalAndExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ConditionalAndExpression():
+{/*@bgen(jjtree) ConditionalAndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ConditionalAndExpression */
+ try {
+/*@egen*/
+ InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void InclusiveOrExpression():
+{/*@bgen(jjtree) InclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) InclusiveOrExpression */
+ try {
+/*@egen*/
+ ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ExclusiveOrExpression():
+{/*@bgen(jjtree) ExclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ExclusiveOrExpression */
+ try {
+/*@egen*/
+ AndExpression() ( "^" AndExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AndExpression():
+{/*@bgen(jjtree) AndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AndExpression */
+ try {
+/*@egen*/
+ EqualityExpression() ( "&" EqualityExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EqualityExpression():
+{/*@bgen(jjtree) EqualityExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EqualityExpression */
+ try {
+/*@egen*/
+ InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void InstanceOfExpression():
+{/*@bgen(jjtree) InstanceOfExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) InstanceOfExpression */
+ try {
+/*@egen*/
+ RelationalExpression() [ "instanceof" Type() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void RelationalExpression():
+{/*@bgen(jjtree) RelationalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) RelationalExpression */
+ try {
+/*@egen*/
+ ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ShiftExpression():
+{/*@bgen(jjtree) ShiftExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ShiftExpression */
+ try {
+/*@egen*/
+ AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AdditiveExpression():
+{/*@bgen(jjtree) AdditiveExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AdditiveExpression */
+ try {
+/*@egen*/
+ MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MultiplicativeExpression():
+{/*@bgen(jjtree) MultiplicativeExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MultiplicativeExpression */
+ try {
+/*@egen*/
+ UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void UnaryExpression():
+{/*@bgen(jjtree) UnaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) UnaryExpression */
+ try {
+/*@egen*/
+ ( "+" | "-" ) UnaryExpression()
+|
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PreIncrementExpression():
+{/*@bgen(jjtree) PreIncrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PreIncrementExpression */
+ try {
+/*@egen*/
+ "++" PrimaryExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PreDecrementExpression():
+{/*@bgen(jjtree) PreDecrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PreDecrementExpression */
+ try {
+/*@egen*/
+ "--" PrimaryExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void UnaryExpressionNotPlusMinus():
+{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) UnaryExpressionNotPlusMinus */
+ try {
+/*@egen*/
+ ( "~" | "!" ) UnaryExpression()
+|
+ LOOKAHEAD( CastLookahead() )
+ CastExpression()
+|
+ PostfixExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+// This production is to determine lookahead only. The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+// this.
+void CastLookahead():
+{/*@bgen(jjtree) CastLookahead */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) CastLookahead */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ "(" PrimitiveType()
+|
+ LOOKAHEAD("(" Type() "[")
+ "(" Type() "[" "]"
+|
+ "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PostfixExpression():
+{/*@bgen(jjtree) PostfixExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PostfixExpression */
+ try {
+/*@egen*/
+ PrimaryExpression() [ PostfixOperator() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PostfixOperator():
+{/*@bgen(jjtree) PostfixOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PostfixOperator */
+ try {
+/*@egen*/
+ "++" | "--"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void CastExpression():
+{/*@bgen(jjtree) CastExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) CastExpression */
+ try {
+/*@egen*/
+ LOOKAHEAD("(" PrimitiveType())
+ "(" Type() ")" UnaryExpression()
+|
+ "(" Type() ")" UnaryExpressionNotPlusMinus()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PrimaryExpression():
+{/*@bgen(jjtree) PrimaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimaryExpression */
+ try {
+/*@egen*/
+ PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberSelector():
+{/*@bgen(jjtree) MemberSelector */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberSelector */
+ try {
+/*@egen*/
+ "." TypeArguments() <IDENTIFIER>/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PrimaryPrefix():
+{/*@bgen(jjtree) PrimaryPrefix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimaryPrefix */
+ try {
+/*@egen*/
+ Literal()
+|
+ LOOKAHEAD( ( <IDENTIFIER> "." )* "this" )
+ ( <IDENTIFIER> "." )*
+ "this"
+|
+ "super" "." <IDENTIFIER>
+|
+ "(" Expression() ")"
+|
+ AllocationExpression()
+|
+ LOOKAHEAD( ResultType() "." "class" )
+ ResultType() "." "class"
+|
+ Name()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void PrimarySuffix():
+{/*@bgen(jjtree) PrimarySuffix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) PrimarySuffix */
+ try {
+/*@egen*/
+ LOOKAHEAD("." "super" ".")
+ "." "super"
+|
+ LOOKAHEAD("." "this")
+ "." "this"
+|
+ LOOKAHEAD(2)
+ "." AllocationExpression()
+|
+ LOOKAHEAD(3)
+ MemberSelector()
+|
+ "[" Expression() "]"
+|
+ "." <IDENTIFIER>
+|
+ Arguments()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Literal():
+{/*@bgen(jjtree) Literal */
+ SimpleNode jjtn000 = new SimpleNode(JJTLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Literal */
+ try {
+/*@egen*/
+ <INTEGER_LITERAL>
+|
+ <FLOATING_POINT_LITERAL>
+|
+ <CHARACTER_LITERAL>
+|
+ <STRING_LITERAL>
+|
+ BooleanLiteral()
+|
+ NullLiteral()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void BooleanLiteral():
+{/*@bgen(jjtree) BooleanLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) BooleanLiteral */
+ try {
+/*@egen*/
+ "true"
+|
+ "false"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void NullLiteral():
+{/*@bgen(jjtree) NullLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) NullLiteral */
+ try {
+/*@egen*/
+ "null"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Arguments():
+{/*@bgen(jjtree) Arguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Arguments */
+ try {
+/*@egen*/
+ "(" [ ArgumentList() ] ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ArgumentList():
+{/*@bgen(jjtree) ArgumentList */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ArgumentList */
+ try {
+/*@egen*/
+ Expression() ( "," Expression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AllocationExpression():
+{/*@bgen(jjtree) AllocationExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AllocationExpression */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ "new" PrimitiveType() ArrayDimsAndInits()
+|
+ "new" ClassOrInterfaceType() [ TypeArguments() ]
+ (
+ ArrayDimsAndInits()
+ |
+ Arguments() [ ClassOrInterfaceBody(false) ]
+ )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimsAndInits():
+{/*@bgen(jjtree) ArrayDimsAndInits */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ArrayDimsAndInits */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+|
+ ( "[" "]" )+ ArrayInitializer()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement():
+{/*@bgen(jjtree) Statement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Statement */
+ try {
+/*@egen*/
+ LOOKAHEAD(2)
+ LabeledStatement()
+|
+ AssertStatement()
+|
+ Block()
+|
+ EmptyStatement()
+|
+ StatementExpression() ";"
+|
+ SwitchStatement()
+|
+ IfStatement()
+|
+ WhileStatement()
+|
+ DoStatement()
+|
+ ForStatement()
+|
+ BreakStatement()
+|
+ ContinueStatement()
+|
+ ReturnStatement()
+|
+ ThrowStatement()
+|
+ SynchronizedStatement()
+|
+ TryStatement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AssertStatement():
+{/*@bgen(jjtree) AssertStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AssertStatement */
+ try {
+/*@egen*/
+ "assert" Expression() [ ":" Expression() ] ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void LabeledStatement():
+{/*@bgen(jjtree) LabeledStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) LabeledStatement */
+ try {
+/*@egen*/
+ <IDENTIFIER> ":" Statement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void Block():
+{/*@bgen(jjtree) Block */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCK);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Block */
+ try {
+/*@egen*/
+ "{" ( BlockStatement() )* "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void BlockStatement():
+{/*@bgen(jjtree) BlockStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) BlockStatement */
+ try {
+/*@egen*/
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration() ";"
+|
+ Statement()
+|
+ ClassOrInterfaceDeclaration(0)/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void LocalVariableDeclaration():
+{/*@bgen(jjtree) LocalVariableDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) LocalVariableDeclaration */
+ try {
+/*@egen*/
+ Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void EmptyStatement():
+{/*@bgen(jjtree) EmptyStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) EmptyStatement */
+ try {
+/*@egen*/
+ ";"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void StatementExpression():
+{/*@bgen(jjtree) StatementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) StatementExpression */
+ try {
+/*@egen*/
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ LOOKAHEAD(PrimaryExpression() AssignmentOperator())
+ AssignmentExpression()
+|
+ PostfixExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SwitchStatement():
+{/*@bgen(jjtree) SwitchStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SwitchStatement */
+ try {
+/*@egen*/
+ "switch" "(" Expression() ")" "{"
+ ( SwitchLabel() ( BlockStatement() )* )*
+ "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SwitchLabel():
+{/*@bgen(jjtree) SwitchLabel */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SwitchLabel */
+ try {
+/*@egen*/
+ "case" Expression() ":"
+|
+ "default" ":"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void IfStatement():
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+{/*@bgen(jjtree) IfStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) IfStatement */
+ try {
+/*@egen*/
+ "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void WhileStatement():
+{/*@bgen(jjtree) WhileStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) WhileStatement */
+ try {
+/*@egen*/
+ "while" "(" Expression() ")" Statement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void DoStatement():
+{/*@bgen(jjtree) DoStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) DoStatement */
+ try {
+/*@egen*/
+ "do" Statement() "while" "(" Expression() ")" ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ForStatement():
+{/*@bgen(jjtree) ForStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ForStatement */
+ try {
+/*@egen*/
+ "for" "("
+
+ (
+ LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
+ Modifiers() Type() <IDENTIFIER> ":" Expression()
+ |
+ [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ]
+ )
+
+ ")" Statement()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ForInit():
+{/*@bgen(jjtree) ForInit */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORINIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ForInit */
+ try {
+/*@egen*/
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration()
+|
+ StatementExpressionList()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void StatementExpressionList():
+{/*@bgen(jjtree) StatementExpressionList */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) StatementExpressionList */
+ try {
+/*@egen*/
+ StatementExpression() ( "," StatementExpression() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ForUpdate():
+{/*@bgen(jjtree) ForUpdate */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ForUpdate */
+ try {
+/*@egen*/
+ StatementExpressionList()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void BreakStatement():
+{/*@bgen(jjtree) BreakStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) BreakStatement */
+ try {
+/*@egen*/
+ "break" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ContinueStatement():
+{/*@bgen(jjtree) ContinueStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ContinueStatement */
+ try {
+/*@egen*/
+ "continue" [ <IDENTIFIER> ] ";"/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ReturnStatement():
+{/*@bgen(jjtree) ReturnStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ReturnStatement */
+ try {
+/*@egen*/
+ "return" [ Expression() ] ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void ThrowStatement():
+{/*@bgen(jjtree) ThrowStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) ThrowStatement */
+ try {
+/*@egen*/
+ "throw" Expression() ";"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SynchronizedStatement():
+{/*@bgen(jjtree) SynchronizedStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SynchronizedStatement */
+ try {
+/*@egen*/
+ "synchronized" "(" Expression() ")" Block()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void TryStatement():
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{/*@bgen(jjtree) TryStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) TryStatement */
+ try {
+/*@egen*/
+ "try" Block()
+ ( "catch" "(" FormalParameter() ")" Block() )*
+ [ "finally" Block() ]/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+
+void RUNSIGNEDSHIFT():
+{/*@bgen(jjtree) RUNSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) RUNSIGNEDSHIFT */
+ try {
+/*@egen*/
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} )
+ ">" ">" ">"
+ )/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void RSIGNEDSHIFT():
+{/*@bgen(jjtree) RSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) RSIGNEDSHIFT */
+ try {
+/*@egen*/
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} )
+ ">" ">"
+ )/*@bgen(jjtree)*/
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+/* Annotation syntax follows. */
+
+void Annotation():
+{/*@bgen(jjtree) Annotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) Annotation */
+ try {
+/*@egen*/
+ LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" ))
+ NormalAnnotation()
+ |
+ LOOKAHEAD( "@" Name() "(" )
+ SingleMemberAnnotation()
+ |
+ MarkerAnnotation()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void NormalAnnotation():
+{/*@bgen(jjtree) NormalAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) NormalAnnotation */
+ try {
+/*@egen*/
+ "@" Name() "(" [ MemberValuePairs() ] ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MarkerAnnotation():
+{/*@bgen(jjtree) MarkerAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MarkerAnnotation */
+ try {
+/*@egen*/
+ "@" Name()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void SingleMemberAnnotation():
+{/*@bgen(jjtree) SingleMemberAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) SingleMemberAnnotation */
+ try {
+/*@egen*/
+ "@" Name() "(" MemberValue() ")"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValuePairs():
+{/*@bgen(jjtree) MemberValuePairs */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValuePairs */
+ try {
+/*@egen*/
+ MemberValuePair() ( "," MemberValuePair() )*/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValuePair():
+{/*@bgen(jjtree) MemberValuePair */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValuePair */
+ try {
+/*@egen*/
+ <IDENTIFIER> "=" MemberValue()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValue():
+{/*@bgen(jjtree) MemberValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValue */
+ try {
+/*@egen*/
+ Annotation()
+ |
+ MemberValueArrayInitializer()
+ |
+ ConditionalExpression()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void MemberValueArrayInitializer():
+{/*@bgen(jjtree) MemberValueArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) MemberValueArrayInitializer */
+ try {
+/*@egen*/
+ "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+
+/* Annotation Types. */
+
+void AnnotationTypeDeclaration(int modifiers):
+{/*@bgen(jjtree) AnnotationTypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnnotationTypeDeclaration */
+ try {
+/*@egen*/
+ "@" "interface" <IDENTIFIER> AnnotationTypeBody()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AnnotationTypeBody():
+{/*@bgen(jjtree) AnnotationTypeBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) AnnotationTypeBody */
+ try {
+/*@egen*/
+ "{" ( AnnotationTypeMemberDeclaration() )* "}"/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void AnnotationTypeMemberDeclaration():
+{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/
+ int modifiers;
+}
+{/*@bgen(jjtree) AnnotationTypeMemberDeclaration */
+ try {
+/*@egen*/
+ modifiers = Modifiers()
+ (
+ LOOKAHEAD(Type() <IDENTIFIER> "(")
+ Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";"
+ |
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ |
+ FieldDeclaration(modifiers)
+ )
+ |
+ ( ";" )/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
+
+void DefaultValue():
+{/*@bgen(jjtree) DefaultValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+/*@egen*/}
+{/*@bgen(jjtree) DefaultValue */
+ try {
+/*@egen*/
+ "default" MemberValue()/*@bgen(jjtree)*/
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ throw (RuntimeException)jjte000;
+ }
+ if (jjte000 instanceof ParseException) {
+ throw (ParseException)jjte000;
+ }
+ throw (Error)jjte000;
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+/*@egen*/
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jj
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Java1.5.jjt)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,2150 @@
+
+/*
+ * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
+ * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
+ * intellectual property rights relating to technology embodied in the product
+ * that is described in this document. In particular, and without limitation,
+ * these intellectual property rights may include one or more of the U.S.
+ * patents listed at http://www.sun.com/patents and one or more additional
+ * patents or pending patent applications in the U.S. and in other countries.
+ * U.S. Government Rights - Commercial software. Government users are subject
+ * to the Sun Microsystems, Inc. standard license agreement and applicable
+ * provisions of the FAR and its supplements. Use is subject to license terms.
+ * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
+ * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
+ * product is covered and controlled by U.S. Export Control laws and may be
+ * subject to the export or import laws in other countries. Nuclear, missile,
+ * chemical biological weapons or nuclear maritime end uses or end users,
+ * whether direct or indirect, are strictly prohibited. Export or reexport
+ * to countries subject to U.S. embargo or to entities identified on U.S.
+ * export exclusion lists, including, but not limited to, the denied persons
+ * and specially designated nationals lists is strictly prohibited.
+ */
+
+// Slightly modified version of javacc's reference 1.5 grammar, tweaked for
+// usage with JAXX. There are two main areas of changes: several new
+// nonterminals were added to make identifying certain constructs easier,
+// and the Line nonterminal was added to support JAXX's script tags.
+// Several of the new changes are inefficient and require excess lookahead,
+// but at this point I'd rather have inefficiency than risk breaking it during
+// attempted optimizations.
+
+options {
+ JAVA_UNICODE_ESCAPE = true;
+ ERROR_REPORTING = false;
+ STATIC = false;
+ JDK_VERSION = "1.4";
+ NODE_SCOPE_HOOK=true;
+}
+
+PARSER_BEGIN(JavaParser)
+package jaxx.parser;
+
+import java.io.*;
+
+/**
+ * Grammar to parse Java version 1.5
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser
+{
+ /**
+ * Class to hold modifiers.
+ */
+ static public final class ModifierSet
+ {
+ /* Definitions of the bits in the modifiers field. */
+ public static final int PUBLIC = 0x0001;
+ public static final int PROTECTED = 0x0002;
+ public static final int PRIVATE = 0x0004;
+ public static final int ABSTRACT = 0x0008;
+ public static final int STATIC = 0x0010;
+ public static final int FINAL = 0x0020;
+ public static final int SYNCHRONIZED = 0x0040;
+ public static final int NATIVE = 0x0080;
+ public static final int TRANSIENT = 0x0100;
+ public static final int VOLATILE = 0x0200;
+ public static final int STRICTFP = 0x1000;
+
+ /** A set of accessors that indicate whether the specified modifier
+ is in the set. */
+
+ public boolean isPublic(int modifiers)
+ {
+ return (modifiers & PUBLIC) != 0;
+ }
+
+ public boolean isProtected(int modifiers)
+ {
+ return (modifiers & PROTECTED) != 0;
+ }
+
+ public boolean isPrivate(int modifiers)
+ {
+ return (modifiers & PRIVATE) != 0;
+ }
+
+ public boolean isStatic(int modifiers)
+ {
+ return (modifiers & STATIC) != 0;
+ }
+
+ public boolean isAbstract(int modifiers)
+ {
+ return (modifiers & ABSTRACT) != 0;
+ }
+
+ public boolean isFinal(int modifiers)
+ {
+ return (modifiers & FINAL) != 0;
+ }
+
+ public boolean isNative(int modifiers)
+ {
+ return (modifiers & NATIVE) != 0;
+ }
+
+ public boolean isStrictfp(int modifiers)
+ {
+ return (modifiers & STRICTFP) != 0;
+ }
+
+ public boolean isSynchronized(int modifiers)
+ {
+ return (modifiers & SYNCHRONIZED) != 0;
+ }
+
+ public boolean isTransient(int modifiers)
+ {
+ return (modifiers & TRANSIENT) != 0;
+ }
+
+ public boolean isVolatile(int modifiers)
+ {
+ return (modifiers & VOLATILE) != 0;
+ }
+
+ /**
+ * Removes the given modifier.
+ */
+ static int removeModifier(int modifiers, int mod)
+ {
+ return modifiers & ~mod;
+ }
+ }
+
+ public JavaParser(String fileName)
+ {
+ this(System.in);
+ try { ReInit(new FileInputStream(new File(fileName))); }
+ catch(Exception e) { e.printStackTrace(); }
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public SimpleNode popNode()
+ {
+ if ( jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode)jjtree.popNode();
+ else
+ return null;
+ }
+ public static void main(String args[]) {
+ JavaParser parser;
+ if (args.length == 0) {
+ System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
+ parser = new JavaParser(System.in);
+ } else if (args.length == 1) {
+ System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
+ try {
+ parser = new JavaParser(new java.io.FileInputStream(args[0]));
+ } catch (java.io.FileNotFoundException e) {
+ System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
+ return;
+ }
+ } else {
+ System.out.println("Java Parser Version 1.1: Usage is one of:");
+ System.out.println(" java JavaParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java JavaParser inputfile");
+ return;
+ }
+ try {
+ parser.CompilationUnit();
+ System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
+ }
+ }
+
+}
+
+PARSER_END(JavaParser)
+
+/* COMMENTS */
+
+MORE :
+{
+ <"/**" ~["/"]> { input_stream.backup(1); } : IN_FORMAL_COMMENT
+|
+ "/*" : IN_MULTI_LINE_COMMENT
+}
+
+SPECIAL_TOKEN:
+{
+ <WHITE_SPACE: ([" ", "\n", "\r", "\t", "\f"])+>
+}
+
+SPECIAL_TOKEN :
+{
+ <SINGLE_LINE_COMMENT: "//" (~["\n", "\r"])* ("\n" | "\r" | "\r\n")?>
+}
+
+<IN_FORMAL_COMMENT>
+SPECIAL_TOKEN :
+{
+ <FORMAL_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_MULTI_LINE_COMMENT>
+SPECIAL_TOKEN :
+{
+ <MULTI_LINE_COMMENT: "*/" > : DEFAULT
+}
+
+<IN_FORMAL_COMMENT,IN_MULTI_LINE_COMMENT>
+MORE :
+{
+ < ~[] >
+}
+
+/* RESERVED WORDS AND LITERALS */
+
+TOKEN :
+{
+ < ABSTRACT: "abstract" >
+| < ASSERT: "assert" >
+| < BOOLEAN: "boolean" >
+| < BREAK: "break" >
+| < BYTE: "byte" >
+| < CASE: "case" >
+| < CATCH: "catch" >
+| < CHAR: "char" >
+| < CLASS: "class" >
+| < CONST: "const" >
+| < CONTINUE: "continue" >
+| < _DEFAULT: "default" >
+| < DO: "do" >
+| < DOUBLE: "double" >
+| < ELSE: "else" >
+| < ENUM: "enum" >
+| < EXTENDS: "extends" >
+| < FALSE: "false" >
+| < FINAL: "final" >
+| < FINALLY: "finally" >
+| < FLOAT: "float" >
+| < FOR: "for" >
+| < GOTO: "goto" >
+| < IF: "if" >
+| < IMPLEMENTS: "implements" >
+| < IMPORT: "import" >
+| < INSTANCEOF: "instanceof" >
+| < INT: "int" >
+| < INTERFACE: "interface" >
+| < LONG: "long" >
+| < NATIVE: "native" >
+| < NEW: "new" >
+| < NULL: "null" >
+| < PACKAGE: "package">
+| < PRIVATE: "private" >
+| < PROTECTED: "protected" >
+| < PUBLIC: "public" >
+| < RETURN: "return" >
+| < SHORT: "short" >
+| < STATIC: "static" >
+| < STRICTFP: "strictfp" >
+| < SUPER: "super" >
+| < SWITCH: "switch" >
+| < SYNCHRONIZED: "synchronized" >
+| < THIS: "this" >
+| < THROW: "throw" >
+| < THROWS: "throws" >
+| < TRANSIENT: "transient" >
+| < TRUE: "true" >
+| < TRY: "try" >
+| < VOID: "void" >
+| < VOLATILE: "volatile" >
+| < WHILE: "while" >
+}
+
+/* LITERALS */
+
+TOKEN :
+{
+ < INTEGER_LITERAL:
+ <DECIMAL_LITERAL> (["l","L"])?
+ | <HEX_LITERAL> (["l","L"])?
+ | <OCTAL_LITERAL> (["l","L"])?
+ >
+|
+ < #DECIMAL_LITERAL: ["1"-"9"] (["0"-"9"])* >
+|
+ < #HEX_LITERAL: "0" ["x","X"] (["0"-"9","a"-"f","A"-"F"])+ >
+|
+ < #OCTAL_LITERAL: "0" (["0"-"7"])* >
+|
+ < FLOATING_POINT_LITERAL:
+ <DECIMAL_FLOATING_POINT_LITERAL>
+ | <HEXADECIMAL_FLOATING_POINT_LITERAL>
+ >
+|
+ < #DECIMAL_FLOATING_POINT_LITERAL:
+ (["0"-"9"])+ "." (["0"-"9"])* (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | "." (["0"-"9"])+ (<DECIMAL_EXPONENT>)? (["f","F","d","D"])?
+ | (["0"-"9"])+ <DECIMAL_EXPONENT> (["f","F","d","D"])?
+ | (["0"-"9"])+ (<DECIMAL_EXPONENT>)? ["f","F","d","D"]
+ >
+|
+ < #DECIMAL_EXPONENT: ["e","E"] (["+","-"])? (["0"-"9"])+ >
+|
+ < #HEXADECIMAL_FLOATING_POINT_LITERAL:
+ "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])+ (".")? <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ | "0" ["x", "X"] (["0"-"9","a"-"f","A"-"F"])* "." (["0"-"9","a"-"f","A"-"F"])+ <HEXADECIMAL_EXPONENT> (["f","F","d","D"])?
+ >
+|
+ < #HEXADECIMAL_EXPONENT: ["p","P"] (["+","-"])? (["0"-"9"])+ >
+|
+ < CHARACTER_LITERAL:
+ "'"
+ ( (~["'","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )
+ "'"
+ >
+|
+ < STRING_LITERAL:
+ "\""
+ ( (~["\"","\\","\n","\r"])
+ | ("\\"
+ ( ["n","t","b","r","f","\\","'","\""]
+ | ["0"-"7"] ( ["0"-"7"] )?
+ | ["0"-"3"] ["0"-"7"] ["0"-"7"]
+ )
+ )
+ )*
+ "\""
+ >
+}
+
+/* IDENTIFIERS */
+
+TOKEN :
+{
+ < IDENTIFIER: <LETTER> (<PART_LETTER>)* >
+|
+ < #LETTER:
+ [ // all chars for which Character.isIdentifierStart is true
+ "$",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u064a",
+ "\u0671"-"\u06d3",
+ "\u06d5",
+ "\u06e5"-"\u06e6",
+ "\u06fa"-"\u06fc",
+ "\u0710",
+ "\u0712"-"\u072c",
+ "\u0780"-"\u07a5",
+ "\u0905"-"\u0939",
+ "\u093d",
+ "\u0950",
+ "\u0958"-"\u0961",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e1",
+ "\u09f0"-"\u09f3",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a72"-"\u0a74",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3d",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c60"-"\u0c61",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d60"-"\u0d61",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0e01"-"\u0e30",
+ "\u0e32"-"\u0e33",
+ "\u0e3f"-"\u0e46",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb0",
+ "\u0eb2"-"\u0eb3",
+ "\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f40"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f88"-"\u0f8b",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u1050"-"\u1055",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17b3",
+ "\u17db",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a8",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u203f"-"\u2040",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u3029",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d",
+ "\ufb1f"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\uff04",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6"
+ ]
+ >
+|
+ < #PART_LETTER:
+ [ // all chars for which Character.isIdentifierPart is true
+ "\u0000"-"\u0008",
+ "\u000e"-"\u001b",
+ "$",
+ "0"-"9",
+ "A"-"Z",
+ "_",
+ "a"-"z",
+ "\u007f"-"\u009f",
+ "\u00a2"-"\u00a5",
+ "\u00aa",
+ "\u00b5",
+ "\u00ba",
+ "\u00c0"-"\u00d6",
+ "\u00d8"-"\u00f6",
+ "\u00f8"-"\u021f",
+ "\u0222"-"\u0233",
+ "\u0250"-"\u02ad",
+ "\u02b0"-"\u02b8",
+ "\u02bb"-"\u02c1",
+ "\u02d0"-"\u02d1",
+ "\u02e0"-"\u02e4",
+ "\u02ee",
+ "\u0300"-"\u034e",
+ "\u0360"-"\u0362",
+ "\u037a",
+ "\u0386",
+ "\u0388"-"\u038a",
+ "\u038c",
+ "\u038e"-"\u03a1",
+ "\u03a3"-"\u03ce",
+ "\u03d0"-"\u03d7",
+ "\u03da"-"\u03f3",
+ "\u0400"-"\u0481",
+ "\u0483"-"\u0486",
+ "\u048c"-"\u04c4",
+ "\u04c7"-"\u04c8",
+ "\u04cb"-"\u04cc",
+ "\u04d0"-"\u04f5",
+ "\u04f8"-"\u04f9",
+ "\u0531"-"\u0556",
+ "\u0559",
+ "\u0561"-"\u0587",
+ "\u0591"-"\u05a1",
+ "\u05a3"-"\u05b9",
+ "\u05bb"-"\u05bd",
+ "\u05bf",
+ "\u05c1"-"\u05c2",
+ "\u05c4",
+ "\u05d0"-"\u05ea",
+ "\u05f0"-"\u05f2",
+ "\u0621"-"\u063a",
+ "\u0640"-"\u0655",
+ "\u0660"-"\u0669",
+ "\u0670"-"\u06d3",
+ "\u06d5"-"\u06dc",
+ "\u06df"-"\u06e8",
+ "\u06ea"-"\u06ed",
+ "\u06f0"-"\u06fc",
+ "\u070f"-"\u072c",
+ "\u0730"-"\u074a",
+ "\u0780"-"\u07b0",
+ "\u0901"-"\u0903",
+ "\u0905"-"\u0939",
+ "\u093c"-"\u094d",
+ "\u0950"-"\u0954",
+ "\u0958"-"\u0963",
+ "\u0966"-"\u096f",
+ "\u0981"-"\u0983",
+ "\u0985"-"\u098c",
+ "\u098f"-"\u0990",
+ "\u0993"-"\u09a8",
+ "\u09aa"-"\u09b0",
+ "\u09b2",
+ "\u09b6"-"\u09b9",
+ "\u09bc",
+ "\u09be"-"\u09c4",
+ "\u09c7"-"\u09c8",
+ "\u09cb"-"\u09cd",
+ "\u09d7",
+ "\u09dc"-"\u09dd",
+ "\u09df"-"\u09e3",
+ "\u09e6"-"\u09f3",
+ "\u0a02",
+ "\u0a05"-"\u0a0a",
+ "\u0a0f"-"\u0a10",
+ "\u0a13"-"\u0a28",
+ "\u0a2a"-"\u0a30",
+ "\u0a32"-"\u0a33",
+ "\u0a35"-"\u0a36",
+ "\u0a38"-"\u0a39",
+ "\u0a3c",
+ "\u0a3e"-"\u0a42",
+ "\u0a47"-"\u0a48",
+ "\u0a4b"-"\u0a4d",
+ "\u0a59"-"\u0a5c",
+ "\u0a5e",
+ "\u0a66"-"\u0a74",
+ "\u0a81"-"\u0a83",
+ "\u0a85"-"\u0a8b",
+ "\u0a8d",
+ "\u0a8f"-"\u0a91",
+ "\u0a93"-"\u0aa8",
+ "\u0aaa"-"\u0ab0",
+ "\u0ab2"-"\u0ab3",
+ "\u0ab5"-"\u0ab9",
+ "\u0abc"-"\u0ac5",
+ "\u0ac7"-"\u0ac9",
+ "\u0acb"-"\u0acd",
+ "\u0ad0",
+ "\u0ae0",
+ "\u0ae6"-"\u0aef",
+ "\u0b01"-"\u0b03",
+ "\u0b05"-"\u0b0c",
+ "\u0b0f"-"\u0b10",
+ "\u0b13"-"\u0b28",
+ "\u0b2a"-"\u0b30",
+ "\u0b32"-"\u0b33",
+ "\u0b36"-"\u0b39",
+ "\u0b3c"-"\u0b43",
+ "\u0b47"-"\u0b48",
+ "\u0b4b"-"\u0b4d",
+ "\u0b56"-"\u0b57",
+ "\u0b5c"-"\u0b5d",
+ "\u0b5f"-"\u0b61",
+ "\u0b66"-"\u0b6f",
+ "\u0b82"-"\u0b83",
+ "\u0b85"-"\u0b8a",
+ "\u0b8e"-"\u0b90",
+ "\u0b92"-"\u0b95",
+ "\u0b99"-"\u0b9a",
+ "\u0b9c",
+ "\u0b9e"-"\u0b9f",
+ "\u0ba3"-"\u0ba4",
+ "\u0ba8"-"\u0baa",
+ "\u0bae"-"\u0bb5",
+ "\u0bb7"-"\u0bb9",
+ "\u0bbe"-"\u0bc2",
+ "\u0bc6"-"\u0bc8",
+ "\u0bca"-"\u0bcd",
+ "\u0bd7",
+ "\u0be7"-"\u0bef",
+ "\u0c01"-"\u0c03",
+ "\u0c05"-"\u0c0c",
+ "\u0c0e"-"\u0c10",
+ "\u0c12"-"\u0c28",
+ "\u0c2a"-"\u0c33",
+ "\u0c35"-"\u0c39",
+ "\u0c3e"-"\u0c44",
+ "\u0c46"-"\u0c48",
+ "\u0c4a"-"\u0c4d",
+ "\u0c55"-"\u0c56",
+ "\u0c60"-"\u0c61",
+ "\u0c66"-"\u0c6f",
+ "\u0c82"-"\u0c83",
+ "\u0c85"-"\u0c8c",
+ "\u0c8e"-"\u0c90",
+ "\u0c92"-"\u0ca8",
+ "\u0caa"-"\u0cb3",
+ "\u0cb5"-"\u0cb9",
+ "\u0cbe"-"\u0cc4",
+ "\u0cc6"-"\u0cc8",
+ "\u0cca"-"\u0ccd",
+ "\u0cd5"-"\u0cd6",
+ "\u0cde",
+ "\u0ce0"-"\u0ce1",
+ "\u0ce6"-"\u0cef",
+ "\u0d02"-"\u0d03",
+ "\u0d05"-"\u0d0c",
+ "\u0d0e"-"\u0d10",
+ "\u0d12"-"\u0d28",
+ "\u0d2a"-"\u0d39",
+ "\u0d3e"-"\u0d43",
+ "\u0d46"-"\u0d48",
+ "\u0d4a"-"\u0d4d",
+ "\u0d57",
+ "\u0d60"-"\u0d61",
+ "\u0d66"-"\u0d6f",
+ "\u0d82"-"\u0d83",
+ "\u0d85"-"\u0d96",
+ "\u0d9a"-"\u0db1",
+ "\u0db3"-"\u0dbb",
+ "\u0dbd",
+ "\u0dc0"-"\u0dc6",
+ "\u0dca",
+ "\u0dcf"-"\u0dd4",
+ "\u0dd6",
+ "\u0dd8"-"\u0ddf",
+ "\u0df2"-"\u0df3",
+ "\u0e01"-"\u0e3a",
+ "\u0e3f"-"\u0e4e",
+ "\u0e50"-"\u0e59",
+ "\u0e81"-"\u0e82",
+ "\u0e84",
+ "\u0e87"-"\u0e88",
+ "\u0e8a",
+ "\u0e8d",
+ "\u0e94"-"\u0e97",
+ "\u0e99"-"\u0e9f",
+ "\u0ea1"-"\u0ea3",
+ "\u0ea5",
+ "\u0ea7",
+ "\u0eaa"-"\u0eab",
+ "\u0ead"-"\u0eb9",
+ "\u0ebb"-"\u0ebd",
+ "\u0ec0"-"\u0ec4",
+ "\u0ec6",
+ "\u0ec8"-"\u0ecd",
+ "\u0ed0"-"\u0ed9",
+ "\u0edc"-"\u0edd",
+ "\u0f00",
+ "\u0f18"-"\u0f19",
+ "\u0f20"-"\u0f29",
+ "\u0f35",
+ "\u0f37",
+ "\u0f39",
+ "\u0f3e"-"\u0f47",
+ "\u0f49"-"\u0f6a",
+ "\u0f71"-"\u0f84",
+ "\u0f86"-"\u0f8b",
+ "\u0f90"-"\u0f97",
+ "\u0f99"-"\u0fbc",
+ "\u0fc6",
+ "\u1000"-"\u1021",
+ "\u1023"-"\u1027",
+ "\u1029"-"\u102a",
+ "\u102c"-"\u1032",
+ "\u1036"-"\u1039",
+ "\u1040"-"\u1049",
+ "\u1050"-"\u1059",
+ "\u10a0"-"\u10c5",
+ "\u10d0"-"\u10f6",
+ "\u1100"-"\u1159",
+ "\u115f"-"\u11a2",
+ "\u11a8"-"\u11f9",
+ "\u1200"-"\u1206",
+ "\u1208"-"\u1246",
+ "\u1248",
+ "\u124a"-"\u124d",
+ "\u1250"-"\u1256",
+ "\u1258",
+ "\u125a"-"\u125d",
+ "\u1260"-"\u1286",
+ "\u1288",
+ "\u128a"-"\u128d",
+ "\u1290"-"\u12ae",
+ "\u12b0",
+ "\u12b2"-"\u12b5",
+ "\u12b8"-"\u12be",
+ "\u12c0",
+ "\u12c2"-"\u12c5",
+ "\u12c8"-"\u12ce",
+ "\u12d0"-"\u12d6",
+ "\u12d8"-"\u12ee",
+ "\u12f0"-"\u130e",
+ "\u1310",
+ "\u1312"-"\u1315",
+ "\u1318"-"\u131e",
+ "\u1320"-"\u1346",
+ "\u1348"-"\u135a",
+ "\u1369"-"\u1371",
+ "\u13a0"-"\u13f4",
+ "\u1401"-"\u166c",
+ "\u166f"-"\u1676",
+ "\u1681"-"\u169a",
+ "\u16a0"-"\u16ea",
+ "\u1780"-"\u17d3",
+ "\u17db",
+ "\u17e0"-"\u17e9",
+ "\u180b"-"\u180e",
+ "\u1810"-"\u1819",
+ "\u1820"-"\u1877",
+ "\u1880"-"\u18a9",
+ "\u1e00"-"\u1e9b",
+ "\u1ea0"-"\u1ef9",
+ "\u1f00"-"\u1f15",
+ "\u1f18"-"\u1f1d",
+ "\u1f20"-"\u1f45",
+ "\u1f48"-"\u1f4d",
+ "\u1f50"-"\u1f57",
+ "\u1f59",
+ "\u1f5b",
+ "\u1f5d",
+ "\u1f5f"-"\u1f7d",
+ "\u1f80"-"\u1fb4",
+ "\u1fb6"-"\u1fbc",
+ "\u1fbe",
+ "\u1fc2"-"\u1fc4",
+ "\u1fc6"-"\u1fcc",
+ "\u1fd0"-"\u1fd3",
+ "\u1fd6"-"\u1fdb",
+ "\u1fe0"-"\u1fec",
+ "\u1ff2"-"\u1ff4",
+ "\u1ff6"-"\u1ffc",
+ "\u200c"-"\u200f",
+ "\u202a"-"\u202e",
+ "\u203f"-"\u2040",
+ "\u206a"-"\u206f",
+ "\u207f",
+ "\u20a0"-"\u20af",
+ "\u20d0"-"\u20dc",
+ "\u20e1",
+ "\u2102",
+ "\u2107",
+ "\u210a"-"\u2113",
+ "\u2115",
+ "\u2119"-"\u211d",
+ "\u2124",
+ "\u2126",
+ "\u2128",
+ "\u212a"-"\u212d",
+ "\u212f"-"\u2131",
+ "\u2133"-"\u2139",
+ "\u2160"-"\u2183",
+ "\u3005"-"\u3007",
+ "\u3021"-"\u302f",
+ "\u3031"-"\u3035",
+ "\u3038"-"\u303a",
+ "\u3041"-"\u3094",
+ "\u3099"-"\u309a",
+ "\u309d"-"\u309e",
+ "\u30a1"-"\u30fe",
+ "\u3105"-"\u312c",
+ "\u3131"-"\u318e",
+ "\u31a0"-"\u31b7",
+ "\u3400"-"\u4db5",
+ "\u4e00"-"\u9fa5",
+ "\ua000"-"\ua48c",
+ "\uac00"-"\ud7a3",
+ "\uf900"-"\ufa2d",
+ "\ufb00"-"\ufb06",
+ "\ufb13"-"\ufb17",
+ "\ufb1d"-"\ufb28",
+ "\ufb2a"-"\ufb36",
+ "\ufb38"-"\ufb3c",
+ "\ufb3e",
+ "\ufb40"-"\ufb41",
+ "\ufb43"-"\ufb44",
+ "\ufb46"-"\ufbb1",
+ "\ufbd3"-"\ufd3d",
+ "\ufd50"-"\ufd8f",
+ "\ufd92"-"\ufdc7",
+ "\ufdf0"-"\ufdfb",
+ "\ufe20"-"\ufe23",
+ "\ufe33"-"\ufe34",
+ "\ufe4d"-"\ufe4f",
+ "\ufe69",
+ "\ufe70"-"\ufe72",
+ "\ufe74",
+ "\ufe76"-"\ufefc",
+ "\ufeff",
+ "\uff04",
+ "\uff10"-"\uff19",
+ "\uff21"-"\uff3a",
+ "\uff3f",
+ "\uff41"-"\uff5a",
+ "\uff65"-"\uffbe",
+ "\uffc2"-"\uffc7",
+ "\uffca"-"\uffcf",
+ "\uffd2"-"\uffd7",
+ "\uffda"-"\uffdc",
+ "\uffe0"-"\uffe1",
+ "\uffe5"-"\uffe6",
+ "\ufff9"-"\ufffb"
+ ]
+ >
+}
+
+/* SEPARATORS */
+
+TOKEN :
+{
+ < LPAREN: "(" >
+| < RPAREN: ")" >
+| < LBRACE: "{" >
+| < RBRACE: "}" >
+| < LBRACKET: "[" >
+| < RBRACKET: "]" >
+| < SEMICOLON: ";" >
+| < COMMA: "," >
+| < DOT: "." >
+| < AT: "@" >
+}
+
+/* OPERATORS */
+
+TOKEN :
+{
+ < ASSIGN: "=" >
+| < LT: "<" >
+| < BANG: "!" >
+| < TILDE: "~" >
+| < HOOK: "?" >
+| < COLON: ":" >
+| < EQ: "==" >
+| < LE: "<=" >
+| < GE: ">=" >
+| < NE: "!=" >
+| < SC_OR: "||" >
+| < SC_AND: "&&" >
+| < INCR: "++" >
+| < DECR: "--" >
+| < PLUS: "+" >
+| < MINUS: "-" >
+| < STAR: "*" >
+| < SLASH: "/" >
+| < BIT_AND: "&" >
+| < BIT_OR: "|" >
+| < XOR: "^" >
+| < REM: "%" >
+| < LSHIFT: "<<" >
+| < PLUSASSIGN: "+=" >
+| < MINUSASSIGN: "-=" >
+| < STARASSIGN: "*=" >
+| < SLASHASSIGN: "/=" >
+| < ANDASSIGN: "&=" >
+| < ORASSIGN: "|=" >
+| < XORASSIGN: "^=" >
+| < REMASSIGN: "%=" >
+| < LSHIFTASSIGN: "<<=" >
+| < RSIGNEDSHIFTASSIGN: ">>=" >
+| < RUNSIGNEDSHIFTASSIGN: ">>>=" >
+| < ELLIPSIS: "..." >
+}
+
+/* >'s need special attention due to generics syntax. */
+TOKEN :
+{
+ < RUNSIGNEDSHIFT: ">>>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RUNSIGNEDSHIFT;
+ input_stream.backup(2);
+ matchedToken.image = ">";
+ }
+| < RSIGNEDSHIFT: ">>" >
+ {
+ matchedToken.kind = GT;
+ ((Token.GTToken)matchedToken).realKind = RSIGNEDSHIFT;
+ input_stream.backup(1);
+ matchedToken.image = ">";
+ }
+| < GT: ">" >
+}
+
+boolean Line() :
+{
+ int modifiers;
+}
+{
+ <EOF> {
+ return true;
+ }
+|
+ LOOKAHEAD(BlockStatement())
+ BlockStatement() {
+ return false;
+ }
+|
+ LOOKAHEAD(Modifiers() [ TypeParameters() ] [ ResultType() ] <IDENTIFIER> FormalParameters() [ "throws" NameList() ] "{")
+ ClassOrInterfaceBodyDeclaration(false) {
+ return false;
+ }
+|
+ LOOKAHEAD(ClassOrInterfaceBodyDeclaration(false))
+ ClassOrInterfaceBodyDeclaration(false) {
+ return false;
+ }
+|
+ LOOKAHEAD(Expression())
+ Expression() {
+ return false;
+ }
+|
+ ImportDeclaration() {
+ return false;
+ }
+}
+
+/*****************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ *****************************************/
+
+/*
+ * Program structuring syntax follows.
+ */
+
+void CompilationUnit():
+{}
+{
+ [ LOOKAHEAD( ( Annotation() )* "package" ) PackageDeclaration() ]
+ ( ImportDeclaration() )*
+ ( TypeDeclaration() )*
+ ( < "\u001a" > )?
+ ( <STUFF_TO_IGNORE: ~[]> )?
+ <EOF>
+}
+
+void PackageDeclaration():
+{}
+{
+ Modifiers() "package" Name() ";"
+}
+
+void ImportDeclaration():
+{}
+{
+ "import" [ "static" ] Name() [ "." "*" ] ";"
+}
+
+/*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+
+int Modifiers():
+{
+ int modifiers = 0;
+}
+{
+ (
+ LOOKAHEAD(2)
+ (
+ "public" { modifiers |= ModifierSet.PUBLIC; }
+ |
+ "static" { modifiers |= ModifierSet.STATIC; }
+ |
+ "protected" { modifiers |= ModifierSet.PROTECTED; }
+ |
+ "private" { modifiers |= ModifierSet.PRIVATE; }
+ |
+ "final" { modifiers |= ModifierSet.FINAL; }
+ |
+ "abstract" { modifiers |= ModifierSet.ABSTRACT; }
+ |
+ "synchronized" { modifiers |= ModifierSet.SYNCHRONIZED; }
+ |
+ "native" { modifiers |= ModifierSet.NATIVE; }
+ |
+ "transient" { modifiers |= ModifierSet.TRANSIENT; }
+ |
+ "volatile" { modifiers |= ModifierSet.VOLATILE; }
+ |
+ "strictfp" { modifiers |= ModifierSet.STRICTFP; }
+ |
+ Annotation()
+ )
+ )*
+
+ {
+ return modifiers;
+ }
+}
+
+/*
+ * Declaration syntax follows.
+ */
+void TypeDeclaration():
+{
+ int modifiers;
+}
+{
+ ";"
+|
+ modifiers = Modifiers()
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ )
+}
+
+
+void ClassOrInterfaceDeclaration(int modifiers):
+{
+ boolean isInterface = false;
+}
+{
+ ( "class" | "interface" { isInterface = true; } )
+ <IDENTIFIER>
+ [ TypeParameters() ]
+ [ ExtendsList(isInterface) ]
+ [ ImplementsList(isInterface) ]
+ ClassOrInterfaceBody(isInterface)
+}
+
+void ExtendsList(boolean isInterface):
+{
+ boolean extendsMoreThanOne = false;
+}
+{
+ "extends" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() { extendsMoreThanOne = true; } )*
+ {
+ if (extendsMoreThanOne && !isInterface)
+ throw new ParseException("A class cannot extend more than one other class");
+ }
+}
+
+void ImplementsList(boolean isInterface):
+{}
+{
+ "implements" ClassOrInterfaceType()
+ ( "," ClassOrInterfaceType() )*
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot implement other interfaces");
+ }
+}
+
+void EnumDeclaration(int modifiers):
+{}
+{
+ "enum" <IDENTIFIER>
+ [ ImplementsList(false) ]
+ EnumBody()
+}
+
+void EnumBody():
+{}
+{
+ "{"
+ [ EnumConstant() ( LOOKAHEAD(2) "," EnumConstant() )* ]
+ [ "," ]
+ [ ";" ( ClassOrInterfaceBodyDeclaration(false) )* ]
+ "}"
+}
+
+void EnumConstant():
+{}
+{
+ Modifiers() <IDENTIFIER> [ Arguments() ] [ ClassOrInterfaceBody(false) ]
+}
+
+void TypeParameters():
+{}
+{
+ "<" TypeParameter() ( "," TypeParameter() )* ">"
+}
+
+void TypeParameter():
+{}
+{
+ <IDENTIFIER> [ TypeBound() ]
+}
+
+void TypeBound():
+{}
+{
+ "extends" ClassOrInterfaceType() ( "&" ClassOrInterfaceType() )*
+}
+
+void ClassOrInterfaceBody(boolean isInterface):
+{}
+{
+ "{" ( ClassOrInterfaceBodyDeclaration(isInterface) )* "}"
+}
+
+void ClassOrInterfaceBodyDeclaration(boolean isInterface):
+{
+ boolean isNestedInterface = false;
+ int modifiers;
+}
+{
+ LOOKAHEAD(2)
+ Initializer()
+ {
+ if (isInterface)
+ throw new ParseException("An interface cannot have initializers");
+ }
+|
+ modifiers = Modifiers() // Just get all the modifiers out of the way. If you want to do
+ // more checks, pass the modifiers down to the member
+ (
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ LOOKAHEAD( [ TypeParameters() ] <IDENTIFIER> "(" )
+ ConstructorDeclaration()
+ |
+ LOOKAHEAD( Type() <IDENTIFIER> ( "[" "]" )* ( "," | "=" | ";" ) )
+ FieldDeclaration(modifiers)
+ |
+ MethodDeclaration(modifiers)
+ )
+|
+ ";"
+}
+
+void FieldDeclaration(int modifiers):
+{}
+{
+ // Modifiers are already matched in the caller
+ Type() VariableDeclarator() ( "," VariableDeclarator() )* ";"
+}
+
+void VariableDeclarator():
+{}
+{
+ VariableDeclaratorId() [ "=" VariableInitializer() ]
+}
+
+void VariableDeclaratorId():
+{}
+{
+ <IDENTIFIER> ( "[" "]" )*
+}
+
+void VariableInitializer():
+{}
+{
+ ArrayInitializer()
+|
+ Expression()
+}
+
+void ArrayInitializer():
+{}
+{
+ "{" [ VariableInitializer() ( LOOKAHEAD(2) "," VariableInitializer() )* ] [ "," ] "}"
+}
+
+void MethodDeclaration(int modifiers):
+{}
+{
+ // Modifiers already matched in the caller!
+ [ TypeParameters() ]
+ ResultType()
+ MethodDeclarator() [ "throws" NameList() ]
+ ( Block() | ";" )
+}
+
+void MethodDeclarator():
+{}
+{
+ <IDENTIFIER> FormalParameters() ( "[" "]" )*
+}
+
+void FormalParameters():
+{}
+{
+ "(" [ FormalParameter() ( "," FormalParameter() )* ] ")"
+}
+
+void FormalParameter():
+{}
+{
+ Modifiers() Type() [ "..." ] VariableDeclaratorId()
+}
+
+void ConstructorDeclaration():
+{}
+{
+ [ TypeParameters() ]
+ // Modifiers matched in the caller
+ <IDENTIFIER> FormalParameters() [ "throws" NameList() ]
+ "{"
+ [ LOOKAHEAD(ExplicitConstructorInvocation())
+ ExplicitConstructorInvocation()
+ ]
+ ( BlockStatement() )*
+ "}"
+}
+
+void ExplicitConstructorInvocation():
+{}
+{
+ ( <IDENTIFIER> "." )* [ LOOKAHEAD(2) "this" "." ]
+ [ TypeArguments() ] ("this"|"super") Arguments() ";"
+}
+
+void Initializer():
+{}
+{
+ [ "static" ] Block()
+}
+
+
+/*
+ * Type, name and expression syntax follows.
+ */
+
+void Type():
+{}
+{
+ LOOKAHEAD(2) ReferenceType()
+ |
+ PrimitiveType()
+}
+
+void ReferenceType():
+{}
+{
+ PrimitiveType() ( LOOKAHEAD(2) "[" "]" )+
+ |
+ ( ClassOrInterfaceType() ) ( LOOKAHEAD(2) "[" "]" )*
+}
+
+void ClassOrInterfaceType():
+{}
+{
+ <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ]
+ ( LOOKAHEAD(2) "." <IDENTIFIER> [ LOOKAHEAD(2) TypeArguments() ] )*
+}
+
+void TypeArguments():
+{}
+{
+ "<" TypeArgument() ( "," TypeArgument() )* ">"
+}
+
+void TypeArgument():
+{}
+{
+ ReferenceType()
+ |
+ "?" [ WildcardBounds() ]
+}
+
+void WildcardBounds():
+{}
+{
+ "extends" ReferenceType()
+ |
+ "super" ReferenceType()
+}
+
+
+void PrimitiveType():
+{}
+{
+ "boolean"
+|
+ "char"
+|
+ "byte"
+|
+ "short"
+|
+ "int"
+|
+ "long"
+|
+ "float"
+|
+ "double"
+}
+
+void ResultType():
+{}
+{
+ "void"
+|
+ Type()
+}
+
+void Name():
+/*
+ * A lookahead of 2 is required below since "Name" can be followed
+ * by a ".*" when used in the context of an "ImportDeclaration".
+ */
+{}
+{
+ <IDENTIFIER>
+ ( LOOKAHEAD(2) "." <IDENTIFIER>
+ )*
+}
+
+void NameList():
+{}
+{
+ Name() ( "," Name() )*
+}
+
+
+/*
+ * Expression syntax follows.
+ */
+
+void Expression():
+/*
+ * This expansion has been written this way instead of:
+ * Assignment() | ConditionalExpression()
+ * for performance reasons.
+ * However, it is a weakening of the grammar for it allows the LHS of
+ * assignments to be any conditional expression whereas it can only be
+ * a primary expression. Consider adding a semantic predicate to work
+ * around this.
+ */
+{}
+{
+ ConditionalExpression()
+ [
+ LOOKAHEAD(2)
+ AssignmentOperator() Expression()
+ ]
+}
+
+void AssignmentOperator():
+{}
+{
+ "=" | "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
+}
+
+void AssignmentExpression():
+{}
+{
+ PrimaryExpression() AssignmentOperator() Expression()
+}
+
+void ConditionalExpression():
+{}
+{
+ ConditionalOrExpression() [ "?" Expression() ":" Expression() ]
+}
+
+void ConditionalOrExpression():
+{}
+{
+ ConditionalAndExpression() ( "||" ConditionalAndExpression() )*
+}
+
+void ConditionalAndExpression():
+{}
+{
+ InclusiveOrExpression() ( "&&" InclusiveOrExpression() )*
+}
+
+void InclusiveOrExpression():
+{}
+{
+ ExclusiveOrExpression() ( "|" ExclusiveOrExpression() )*
+}
+
+void ExclusiveOrExpression():
+{}
+{
+ AndExpression() ( "^" AndExpression() )*
+}
+
+void AndExpression():
+{}
+{
+ EqualityExpression() ( "&" EqualityExpression() )*
+}
+
+void EqualityExpression():
+{}
+{
+ InstanceOfExpression() ( ( "==" | "!=" ) InstanceOfExpression() )*
+}
+
+void InstanceOfExpression():
+{}
+{
+ RelationalExpression() [ "instanceof" Type() ]
+}
+
+void RelationalExpression():
+{}
+{
+ ShiftExpression() ( ( "<" | ">" | "<=" | ">=" ) ShiftExpression() )*
+}
+
+void ShiftExpression():
+{}
+{
+ AdditiveExpression() ( ( "<<" | RSIGNEDSHIFT() | RUNSIGNEDSHIFT() ) AdditiveExpression() )*
+}
+
+void AdditiveExpression():
+{}
+{
+ MultiplicativeExpression() ( ( "+" | "-" ) MultiplicativeExpression() )*
+}
+
+void MultiplicativeExpression():
+{}
+{
+ UnaryExpression() ( ( "*" | "/" | "%" ) UnaryExpression() )*
+}
+
+void UnaryExpression():
+{}
+{
+ ( "+" | "-" ) UnaryExpression()
+|
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ UnaryExpressionNotPlusMinus()
+}
+
+void PreIncrementExpression():
+{}
+{
+ "++" PrimaryExpression()
+}
+
+void PreDecrementExpression():
+{}
+{
+ "--" PrimaryExpression()
+}
+
+void UnaryExpressionNotPlusMinus():
+{}
+{
+ ( "~" | "!" ) UnaryExpression()
+|
+ LOOKAHEAD( CastLookahead() )
+ CastExpression()
+|
+ PostfixExpression()
+}
+
+// This production is to determine lookahead only. The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+// this.
+void CastLookahead():
+{}
+{
+ LOOKAHEAD(2)
+ "(" PrimitiveType()
+|
+ LOOKAHEAD("(" Type() "[")
+ "(" Type() "[" "]"
+|
+ "(" Type() ")" ( "~" | "!" | "(" | <IDENTIFIER> | "this" | "super" | "new" | Literal() )
+}
+
+void PostfixExpression():
+{}
+{
+ PrimaryExpression() [ PostfixOperator() ]
+}
+
+void PostfixOperator():
+{}
+{
+ "++" | "--"
+}
+
+void CastExpression():
+{}
+{
+ LOOKAHEAD("(" PrimitiveType())
+ "(" Type() ")" UnaryExpression()
+|
+ "(" Type() ")" UnaryExpressionNotPlusMinus()
+}
+
+void PrimaryExpression():
+{}
+{
+ PrimaryPrefix() ( LOOKAHEAD(2) PrimarySuffix() )*
+}
+
+void MemberSelector():
+{}
+{
+ "." TypeArguments() <IDENTIFIER>
+}
+
+void PrimaryPrefix():
+{}
+{
+ Literal()
+|
+ LOOKAHEAD( ( <IDENTIFIER> "." )* "this" )
+ ( <IDENTIFIER> "." )*
+ "this"
+|
+ "super" "." <IDENTIFIER>
+|
+ "(" Expression() ")"
+|
+ AllocationExpression()
+|
+ LOOKAHEAD( ResultType() "." "class" )
+ ResultType() "." "class"
+|
+ Name()
+}
+
+void PrimarySuffix():
+{}
+{
+ LOOKAHEAD("." "super" ".")
+ "." "super"
+|
+ LOOKAHEAD("." "this")
+ "." "this"
+|
+ LOOKAHEAD(2)
+ "." AllocationExpression()
+|
+ LOOKAHEAD(3)
+ MemberSelector()
+|
+ "[" Expression() "]"
+|
+ "." <IDENTIFIER>
+|
+ Arguments()
+}
+
+void Literal():
+{}
+{
+ <INTEGER_LITERAL>
+|
+ <FLOATING_POINT_LITERAL>
+|
+ <CHARACTER_LITERAL>
+|
+ <STRING_LITERAL>
+|
+ BooleanLiteral()
+|
+ NullLiteral()
+}
+
+void BooleanLiteral():
+{}
+{
+ "true"
+|
+ "false"
+}
+
+void NullLiteral():
+{}
+{
+ "null"
+}
+
+void Arguments():
+{}
+{
+ "(" [ ArgumentList() ] ")"
+}
+
+void ArgumentList():
+{}
+{
+ Expression() ( "," Expression() )*
+}
+
+void AllocationExpression():
+{}
+{
+ LOOKAHEAD(2)
+ "new" PrimitiveType() ArrayDimsAndInits()
+|
+ "new" ClassOrInterfaceType() [ TypeArguments() ]
+ (
+ ArrayDimsAndInits()
+ |
+ Arguments() [ ClassOrInterfaceBody(false) ]
+ )
+}
+
+/*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+void ArrayDimsAndInits():
+{}
+{
+ LOOKAHEAD(2)
+ ( LOOKAHEAD(2) "[" Expression() "]" )+ ( LOOKAHEAD(2) "[" "]" )*
+|
+ ( "[" "]" )+ ArrayInitializer()
+}
+
+
+/*
+ * Statement syntax follows.
+ */
+
+void Statement():
+{}
+{
+ LOOKAHEAD(2)
+ LabeledStatement()
+|
+ AssertStatement()
+|
+ Block()
+|
+ EmptyStatement()
+|
+ StatementExpression() ";"
+|
+ SwitchStatement()
+|
+ IfStatement()
+|
+ WhileStatement()
+|
+ DoStatement()
+|
+ ForStatement()
+|
+ BreakStatement()
+|
+ ContinueStatement()
+|
+ ReturnStatement()
+|
+ ThrowStatement()
+|
+ SynchronizedStatement()
+|
+ TryStatement()
+}
+
+void AssertStatement():
+{}
+{
+ "assert" Expression() [ ":" Expression() ] ";"
+}
+
+void LabeledStatement():
+{}
+{
+ <IDENTIFIER> ":" Statement()
+}
+
+void Block():
+{}
+{
+ "{" ( BlockStatement() )* "}"
+}
+
+void BlockStatement():
+{}
+{
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration() ";"
+|
+ Statement()
+|
+ ClassOrInterfaceDeclaration(0)
+}
+
+void LocalVariableDeclaration():
+{}
+{
+ Modifiers() Type() VariableDeclarator() ( "," VariableDeclarator() )*
+}
+
+void EmptyStatement():
+{}
+{
+ ";"
+}
+
+void StatementExpression():
+{}
+{
+ PreIncrementExpression()
+|
+ PreDecrementExpression()
+|
+ LOOKAHEAD(PrimaryExpression() AssignmentOperator())
+ AssignmentExpression()
+|
+ PostfixExpression()
+}
+
+void SwitchStatement():
+{}
+{
+ "switch" "(" Expression() ")" "{"
+ ( SwitchLabel() ( BlockStatement() )* )*
+ "}"
+}
+
+void SwitchLabel():
+{}
+{
+ "case" Expression() ":"
+|
+ "default" ":"
+}
+
+void IfStatement():
+/*
+ * The disambiguating algorithm of JavaCC automatically binds dangling
+ * else's to the innermost if statement. The LOOKAHEAD specification
+ * is to tell JavaCC that we know what we are doing.
+ */
+{}
+{
+ "if" "(" Expression() ")" Statement() [ LOOKAHEAD(1) "else" Statement() ]
+}
+
+void WhileStatement():
+{}
+{
+ "while" "(" Expression() ")" Statement()
+}
+
+void DoStatement():
+{}
+{
+ "do" Statement() "while" "(" Expression() ")" ";"
+}
+
+void ForStatement():
+{}
+{
+ "for" "("
+
+ (
+ LOOKAHEAD(Modifiers() Type() <IDENTIFIER> ":")
+ Modifiers() Type() <IDENTIFIER> ":" Expression()
+ |
+ [ ForInit() ] ";" [ Expression() ] ";" [ ForUpdate() ]
+ )
+
+ ")" Statement()
+}
+
+void ForInit():
+{}
+{
+ LOOKAHEAD( Modifiers() Type() <IDENTIFIER> )
+ LocalVariableDeclaration()
+|
+ StatementExpressionList()
+}
+
+void StatementExpressionList():
+{}
+{
+ StatementExpression() ( "," StatementExpression() )*
+}
+
+void ForUpdate():
+{}
+{
+ StatementExpressionList()
+}
+
+void BreakStatement():
+{}
+{
+ "break" [ <IDENTIFIER> ] ";"
+}
+
+void ContinueStatement():
+{}
+{
+ "continue" [ <IDENTIFIER> ] ";"
+}
+
+void ReturnStatement():
+{}
+{
+ "return" [ Expression() ] ";"
+}
+
+void ThrowStatement():
+{}
+{
+ "throw" Expression() ";"
+}
+
+void SynchronizedStatement():
+{}
+{
+ "synchronized" "(" Expression() ")" Block()
+}
+
+void TryStatement():
+/*
+ * Semantic check required here to make sure that at least one
+ * finally/catch is present.
+ */
+{}
+{
+ "try" Block()
+ ( "catch" "(" FormalParameter() ")" Block() )*
+ [ "finally" Block() ]
+}
+
+/* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+
+void RUNSIGNEDSHIFT():
+{}
+{
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RUNSIGNEDSHIFT} )
+ ">" ">" ">"
+ )
+}
+
+void RSIGNEDSHIFT():
+{}
+{
+ ( LOOKAHEAD({ getToken(1).kind == GT &&
+ ((Token.GTToken)getToken(1)).realKind == RSIGNEDSHIFT} )
+ ">" ">"
+ )
+}
+
+/* Annotation syntax follows. */
+
+void Annotation():
+{}
+{
+ LOOKAHEAD( "@" Name() "(" ( <IDENTIFIER> "=" | ")" ))
+ NormalAnnotation()
+ |
+ LOOKAHEAD( "@" Name() "(" )
+ SingleMemberAnnotation()
+ |
+ MarkerAnnotation()
+}
+
+void NormalAnnotation():
+{}
+{
+ "@" Name() "(" [ MemberValuePairs() ] ")"
+}
+
+void MarkerAnnotation():
+{}
+{
+ "@" Name()
+}
+
+void SingleMemberAnnotation():
+{}
+{
+ "@" Name() "(" MemberValue() ")"
+}
+
+void MemberValuePairs():
+{}
+{
+ MemberValuePair() ( "," MemberValuePair() )*
+}
+
+void MemberValuePair():
+{}
+{
+ <IDENTIFIER> "=" MemberValue()
+}
+
+void MemberValue():
+{}
+{
+ Annotation()
+ |
+ MemberValueArrayInitializer()
+ |
+ ConditionalExpression()
+}
+
+void MemberValueArrayInitializer():
+{}
+{
+ "{" MemberValue() ( LOOKAHEAD(2) "," MemberValue() )* [ "," ] "}"
+}
+
+
+/* Annotation Types. */
+
+void AnnotationTypeDeclaration(int modifiers):
+{}
+{
+ "@" "interface" <IDENTIFIER> AnnotationTypeBody()
+}
+
+void AnnotationTypeBody():
+{}
+{
+ "{" ( AnnotationTypeMemberDeclaration() )* "}"
+}
+
+void AnnotationTypeMemberDeclaration():
+{
+ int modifiers;
+}
+{
+ modifiers = Modifiers()
+ (
+ LOOKAHEAD(Type() <IDENTIFIER> "(")
+ Type() <IDENTIFIER> "(" ")" [ DefaultValue() ] ";"
+ |
+ ClassOrInterfaceDeclaration(modifiers)
+ |
+ EnumDeclaration(modifiers)
+ |
+ AnnotationTypeDeclaration(modifiers)
+ |
+ FieldDeclaration(modifiers)
+ )
+ |
+ ( ";" )
+}
+
+void DefaultValue():
+{}
+{
+ "default" MemberValue()
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Java1.5.jjt
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaCharStream.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,530 @@
+/* Generated By:JavaCC: Do not edit this line. JavaCharStream.java Version 4.0 */
+package jaxx.compiler.parser.java;
+
+/**
+ * An implementation of interface CharStream, where the stream is assumed to
+ * contain only ASCII characters (with java-like unicode escape processing).
+ */
+
+public class JavaCharStream {
+ public static final boolean staticFlag = false;
+
+ static int hexval(char c) throws java.io.IOException {
+ switch (c) {
+ case '0':
+ return 0;
+ case '1':
+ return 1;
+ case '2':
+ return 2;
+ case '3':
+ return 3;
+ case '4':
+ return 4;
+ case '5':
+ return 5;
+ case '6':
+ return 6;
+ case '7':
+ return 7;
+ case '8':
+ return 8;
+ case '9':
+ return 9;
+
+ case 'a':
+ case 'A':
+ return 10;
+ case 'b':
+ case 'B':
+ return 11;
+ case 'c':
+ case 'C':
+ return 12;
+ case 'd':
+ case 'D':
+ return 13;
+ case 'e':
+ case 'E':
+ return 14;
+ case 'f':
+ case 'F':
+ return 15;
+ }
+
+ throw new java.io.IOException(); // Should never come here
+ }
+
+ public int bufpos = -1;
+ int bufsize;
+ int available;
+ int tokenBegin;
+ protected int bufline[];
+ protected int bufcolumn[];
+
+ protected int column = 0;
+ protected int line = 1;
+
+ protected boolean prevCharIsCR = false;
+ protected boolean prevCharIsLF = false;
+
+ protected java.io.Reader inputStream;
+
+ protected char[] nextCharBuf;
+ protected char[] buffer;
+ protected int maxNextCharInd = 0;
+ protected int nextCharInd = -1;
+ protected int inBuf = 0;
+ protected int tabSize = 8;
+
+ protected void setTabSize(int i) {
+ tabSize = i;
+ }
+
+ protected int getTabSize(int i) {
+ return tabSize;
+ }
+
+ protected void ExpandBuff(boolean wrapAround) {
+ char[] newbuffer = new char[bufsize + 2048];
+ int newbufline[] = new int[bufsize + 2048];
+ int newbufcolumn[] = new int[bufsize + 2048];
+
+ try {
+ if (wrapAround) {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ System.arraycopy(buffer, 0, newbuffer,
+ bufsize - tokenBegin, bufpos);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
+ bufcolumn = newbufcolumn;
+
+ bufpos += (bufsize - tokenBegin);
+ } else {
+ System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
+ buffer = newbuffer;
+
+ System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
+ bufline = newbufline;
+
+ System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
+ bufcolumn = newbufcolumn;
+
+ bufpos -= tokenBegin;
+ }
+ }
+ catch (Throwable t) {
+ throw new Error(t.getMessage());
+ }
+
+ available = (bufsize += 2048);
+ tokenBegin = 0;
+ }
+
+ protected void FillBuff() throws java.io.IOException {
+ int i;
+ if (maxNextCharInd == 4096)
+ maxNextCharInd = nextCharInd = 0;
+
+ try {
+ if ((i = inputStream.read(nextCharBuf, maxNextCharInd,
+ 4096 - maxNextCharInd)) == -1) {
+ inputStream.close();
+ throw new java.io.IOException();
+ } else {
+ maxNextCharInd += i;
+ }
+ }
+ catch (java.io.IOException e) {
+ if (bufpos != 0) {
+ --bufpos;
+ backup(0);
+ } else {
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+ throw e;
+ }
+ }
+
+ protected char ReadByte() throws java.io.IOException {
+ if (++nextCharInd >= maxNextCharInd)
+ FillBuff();
+
+ return nextCharBuf[nextCharInd];
+ }
+
+ public char BeginToken() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize) {
+ bufpos = 0;
+ }
+
+ tokenBegin = bufpos;
+ return buffer[bufpos];
+ }
+
+ tokenBegin = 0;
+ bufpos = -1;
+
+ return readChar();
+ }
+
+ protected void AdjustBuffSize() {
+ if (available == bufsize) {
+ if (tokenBegin > 2048) {
+ bufpos = 0;
+ available = tokenBegin;
+ } else
+ ExpandBuff(false);
+ } else if (available > tokenBegin)
+ available = bufsize;
+ else if ((tokenBegin - available) < 2048)
+ ExpandBuff(true);
+ else
+ available = tokenBegin;
+ }
+
+ protected void UpdateLineColumn(char c) {
+ column++;
+
+ if (prevCharIsLF) {
+ prevCharIsLF = false;
+ line += (column = 1);
+ } else if (prevCharIsCR) {
+ prevCharIsCR = false;
+ if (c == '\n') {
+ prevCharIsLF = true;
+ } else
+ line += (column = 1);
+ }
+
+ switch (c) {
+ case '\r':
+ prevCharIsCR = true;
+ break;
+ case '\n':
+ prevCharIsLF = true;
+ break;
+ case '\t':
+ column--;
+ column += (tabSize - (column % tabSize));
+ break;
+ default:
+ break;
+ }
+
+ bufline[bufpos] = line;
+ bufcolumn[bufpos] = column;
+ }
+
+ public char readChar() throws java.io.IOException {
+ if (inBuf > 0) {
+ --inBuf;
+
+ if (++bufpos == bufsize)
+ bufpos = 0;
+
+ return buffer[bufpos];
+ }
+
+ char c;
+
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ if ((buffer[bufpos] = c = ReadByte()) == '\\') {
+ UpdateLineColumn(c);
+
+ int backSlashCnt = 1;
+
+ for (; ;) // Read all the backslashes
+ {
+ if (++bufpos == available)
+ AdjustBuffSize();
+
+ try {
+ if ((buffer[bufpos] = c = ReadByte()) != '\\') {
+ UpdateLineColumn(c);
+ // found a non-backslash char.
+ if ((c == 'u') && ((backSlashCnt & 1) == 1)) {
+ if (--bufpos < 0)
+ bufpos = bufsize - 1;
+
+ break;
+ }
+
+ backup(backSlashCnt);
+ return '\\';
+ }
+ }
+ catch (java.io.IOException e) {
+ if (backSlashCnt > 1)
+ backup(backSlashCnt);
+
+ return '\\';
+ }
+
+ UpdateLineColumn(c);
+ backSlashCnt++;
+ }
+
+ // Here, we have seen an odd number of backslash's followed by a 'u'
+ try {
+ while ((c = ReadByte()) == 'u')
+ ++column;
+
+ buffer[bufpos] = c = (char) (hexval(c) << 12 |
+ hexval(ReadByte()) << 8 |
+ hexval(ReadByte()) << 4 |
+ hexval(ReadByte()));
+
+ column += 4;
+ }
+ catch (java.io.IOException e) {
+ throw new Error("Invalid escape character at line " + line +
+ " column " + column + ".");
+ }
+
+ if (backSlashCnt == 1)
+ return c;
+ else {
+ backup(backSlashCnt - 1);
+ return '\\';
+ }
+ } else {
+ UpdateLineColumn(c);
+ return (c);
+ }
+ }
+
+ /**
+ * @return column index
+ * @see #getEndColumn
+ * @deprecated
+ */
+
+ public int getColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ /**
+ * @return line type ???
+ * @see #getEndLine
+ * @deprecated
+ */
+
+ public int getLine() {
+ return bufline[bufpos];
+ }
+
+ public int getEndColumn() {
+ return bufcolumn[bufpos];
+ }
+
+ public int getEndLine() {
+ return bufline[bufpos];
+ }
+
+ public int getBeginColumn() {
+ return bufcolumn[tokenBegin];
+ }
+
+ public int getBeginLine() {
+ return bufline[tokenBegin];
+ }
+
+ public void backup(int amount) {
+
+ inBuf += amount;
+ if ((bufpos -= amount) < 0)
+ bufpos += bufsize;
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+
+ public JavaCharStream(java.io.Reader dstream,
+ int startline, int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.Reader dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn, int buffersize) {
+ inputStream = dstream;
+ line = startline;
+ column = startcolumn - 1;
+
+ if (buffer == null || buffersize != buffer.length) {
+ available = bufsize = buffersize;
+ buffer = new char[buffersize];
+ bufline = new int[buffersize];
+ bufcolumn = new int[buffersize];
+ nextCharBuf = new char[4096];
+ }
+ prevCharIsLF = prevCharIsCR = false;
+ tokenBegin = inBuf = maxNextCharInd = 0;
+ nextCharInd = bufpos = -1;
+ }
+
+ public void ReInit(java.io.Reader dstream,
+ int startline, int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.Reader dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ this(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ this(dstream, startline, startcolumn, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ this(dstream, encoding, 1, 1, 4096);
+ }
+
+ public JavaCharStream(java.io.InputStream dstream) {
+ this(dstream, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn, int buffersize) throws java.io.UnsupportedEncodingException {
+ ReInit(encoding == null ? new java.io.InputStreamReader(dstream) : new java.io.InputStreamReader(dstream, encoding), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn, int buffersize) {
+ ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, buffersize);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding, int startline,
+ int startcolumn) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, int startline,
+ int startcolumn) {
+ ReInit(dstream, startline, startcolumn, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream, String encoding) throws java.io.UnsupportedEncodingException {
+ ReInit(dstream, encoding, 1, 1, 4096);
+ }
+
+ public void ReInit(java.io.InputStream dstream) {
+ ReInit(dstream, 1, 1, 4096);
+ }
+
+ public String GetImage() {
+ if (bufpos >= tokenBegin)
+ return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
+ else
+ return new String(buffer, tokenBegin, bufsize - tokenBegin) +
+ new String(buffer, 0, bufpos + 1);
+ }
+
+ public char[] GetSuffix(int len) {
+ char[] ret = new char[len];
+
+ if ((bufpos + 1) >= len)
+ System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
+ else {
+ System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
+ len - bufpos - 1);
+ System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
+ }
+
+ return ret;
+ }
+
+ public void Done() {
+ nextCharBuf = null;
+ buffer = null;
+ bufline = null;
+ bufcolumn = null;
+ }
+
+ /**
+ * Method to adjust line and column numbers for the start of a token.
+ *
+ * @param newLine line number ?
+ * @param newCol column number ?
+ */
+ public void adjustBeginLineColumn(int newLine, int newCol) {
+ int start = tokenBegin;
+ int len;
+
+ if (bufpos >= tokenBegin) {
+ len = bufpos - tokenBegin + inBuf + 1;
+ } else {
+ len = bufsize - tokenBegin + bufpos + 1 + inBuf;
+ }
+
+ int i = 0, j = 0, k;
+ int nextColDiff, columnDiff = 0;
+
+ while (i < len &&
+ bufline[j = start % bufsize] == bufline[k = ++start % bufsize]) {
+ bufline[j] = newLine;
+ nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
+ bufcolumn[j] = newCol + columnDiff;
+ columnDiff = nextColDiff;
+ i++;
+ }
+
+ if (i < len) {
+ bufline[j] = newLine++;
+ bufcolumn[j] = newCol + columnDiff;
+
+ while (i++ < len) {
+ if (bufline[j = start % bufsize] != bufline[++start % bufsize])
+ bufline[j] = newLine++;
+ else
+ bufline[j] = newLine;
+ }
+ }
+
+ line = bufline[j];
+ column = bufcolumn[j];
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaCharStream.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParser.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,10048 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParser.java */
+package jaxx.compiler.parser.java;
+
+import java.io.File;
+import java.io.FileInputStream;
+
+/**
+ * Grammar to parse Java version 1.5
+ *
+ * @author Sreenivasa Viswanadha - Simplified and enhanced for 1.5
+ */
+public class JavaParser/*@bgen(jjtree)*/ implements JavaParserTreeConstants, JavaParserConstants {/*@bgen(jjtree)*/
+ protected JJTJavaParserState jjtree = new JJTJavaParserState();
+
+ /** Class to hold modifiers. */
+ static public final class ModifierSet {
+ /* Definitions of the bits in the modifiers field. */
+ public static final int PUBLIC = 0x0001;
+ public static final int PROTECTED = 0x0002;
+ public static final int PRIVATE = 0x0004;
+ public static final int ABSTRACT = 0x0008;
+ public static final int STATIC = 0x0010;
+ public static final int FINAL = 0x0020;
+ public static final int SYNCHRONIZED = 0x0040;
+ public static final int NATIVE = 0x0080;
+ public static final int TRANSIENT = 0x0100;
+ public static final int VOLATILE = 0x0200;
+ public static final int STRICTFP = 0x1000;
+
+ /**
+ * A set of accessors that indicate whether the specified modifier
+ * is in the set.
+ */
+
+ public boolean isPublic(int modifiers) {
+ return (modifiers & PUBLIC) != 0;
+ }
+
+ public boolean isProtected(int modifiers) {
+ return (modifiers & PROTECTED) != 0;
+ }
+
+ public boolean isPrivate(int modifiers) {
+ return (modifiers & PRIVATE) != 0;
+ }
+
+ public boolean isStatic(int modifiers) {
+ return (modifiers & STATIC) != 0;
+ }
+
+ public boolean isAbstract(int modifiers) {
+ return (modifiers & ABSTRACT) != 0;
+ }
+
+ public boolean isFinal(int modifiers) {
+ return (modifiers & FINAL) != 0;
+ }
+
+ public boolean isNative(int modifiers) {
+ return (modifiers & NATIVE) != 0;
+ }
+
+ public boolean isStrictfp(int modifiers) {
+ return (modifiers & STRICTFP) != 0;
+ }
+
+ public boolean isSynchronized(int modifiers) {
+ return (modifiers & SYNCHRONIZED) != 0;
+ }
+
+ public boolean isTransient(int modifiers) {
+ return (modifiers & TRANSIENT) != 0;
+ }
+
+ public boolean isVolatile(int modifiers) {
+ return (modifiers & VOLATILE) != 0;
+ }
+
+ /** Removes the given modifier. */
+ static int removeModifier(int modifiers, int mod) {
+ return modifiers & ~mod;
+ }
+ }
+
+ public JavaParser(String fileName) {
+ this(System.in);
+ try {
+ ReInit(new FileInputStream(new File(fileName)));
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ void jjtreeOpenNodeScope(Node n) {
+ ((SimpleNode) n).firstToken = getToken(1);
+ }
+
+ void jjtreeCloseNodeScope(Node n) {
+ ((SimpleNode) n).lastToken = getToken(0);
+ }
+
+ public SimpleNode popNode() {
+ if (jjtree.nodeArity() > 0) // number of child nodes
+ return (SimpleNode) jjtree.popNode();
+ else
+ return null;
+ }
+
+ public static void main(String args[]) {
+ JavaParser parser;
+ if (args.length == 0) {
+ System.out.println("Java Parser Version 1.1: Reading from standard input . . .");
+ parser = new JavaParser(System.in);
+ } else if (args.length == 1) {
+ System.out.println("Java Parser Version 1.1: Reading from file " + args[0] + " . . .");
+ try {
+ parser = new JavaParser(new java.io.FileInputStream(args[0]));
+ } catch (java.io.FileNotFoundException e) {
+ System.out.println("Java Parser Version 1.1: File " + args[0] + " not found.");
+ return;
+ }
+ } else {
+ System.out.println("Java Parser Version 1.1: Usage is one of:");
+ System.out.println(" java JavaParser < inputfile");
+ System.out.println("OR");
+ System.out.println(" java JavaParser inputfile");
+ return;
+ }
+ try {
+ parser.CompilationUnit();
+ System.out.println("Java Parser Version 1.1: Java program parsed successfully.");
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ System.out.println("Java Parser Version 1.1: Encountered errors during parse.");
+ }
+ }
+
+ final public boolean Line() throws ParseException {
+ /*@bgen(jjtree) Line */
+ SimpleNode jjtn000 = new SimpleNode(JJTLINE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 0:
+ jj_consume_token(0);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return true;
+ }
+ break;
+ default:
+ if (jj_2_1(2147483647)) {
+ BlockStatement();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else if (jj_2_2(2147483647)) {
+ ClassOrInterfaceBodyDeclaration(false);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else if (jj_2_3(2147483647)) {
+ ClassOrInterfaceBodyDeclaration(false);
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else if (jj_2_4(2147483647)) {
+ Expression();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPORT:
+ ImportDeclaration();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return false;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ /**
+ * **************************************
+ * THE JAVA LANGUAGE GRAMMAR STARTS HERE *
+ * ***************************************
+ */
+
+/*
+ * Program structuring syntax follows.
+ */
+ final public void CompilationUnit() throws ParseException {
+ /*@bgen(jjtree) CompilationUnit */
+ SimpleNode jjtn000 = new SimpleNode(JJTCOMPILATIONUNIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_5(2147483647)) {
+ PackageDeclaration();
+ } else {
+ ;
+ }
+ label_1:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPORT:
+ ;
+ break;
+ default:
+ break label_1;
+ }
+ ImportDeclaration();
+ }
+ label_2:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case CLASS:
+ case ENUM:
+ case FINAL:
+ case INTERFACE:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case SEMICOLON:
+ case AT:
+ ;
+ break;
+ default:
+ break label_2;
+ }
+ TypeDeclaration();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case 123:
+ jj_consume_token(123);
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STUFF_TO_IGNORE:
+ jj_consume_token(STUFF_TO_IGNORE);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(0);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PackageDeclaration() throws ParseException {
+ /*@bgen(jjtree) PackageDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTPACKAGEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ jj_consume_token(PACKAGE);
+ Name();
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ImportDeclaration() throws ParseException {
+ /*@bgen(jjtree) ImportDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPORTDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IMPORT);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STATIC:
+ jj_consume_token(STATIC);
+ break;
+ default:
+ ;
+ }
+ Name();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case DOT:
+ jj_consume_token(DOT);
+ jj_consume_token(STAR);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Modifiers. We match all modifiers in a single rule to reduce the chances of
+ * syntax errors for simple modifier mistakes. It will also enable us to give
+ * better error messages.
+ */
+ final public int Modifiers() throws ParseException {
+ /*@bgen(jjtree) Modifiers */
+ SimpleNode jjtn000 = new SimpleNode(JJTMODIFIERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers = 0;
+ try {
+ label_3:
+ while (true) {
+ if (jj_2_6(2)) {
+ ;
+ } else {
+ break label_3;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PUBLIC:
+ jj_consume_token(PUBLIC);
+ modifiers |= ModifierSet.PUBLIC;
+ break;
+ case STATIC:
+ jj_consume_token(STATIC);
+ modifiers |= ModifierSet.STATIC;
+ break;
+ case PROTECTED:
+ jj_consume_token(PROTECTED);
+ modifiers |= ModifierSet.PROTECTED;
+ break;
+ case PRIVATE:
+ jj_consume_token(PRIVATE);
+ modifiers |= ModifierSet.PRIVATE;
+ break;
+ case FINAL:
+ jj_consume_token(FINAL);
+ modifiers |= ModifierSet.FINAL;
+ break;
+ case ABSTRACT:
+ jj_consume_token(ABSTRACT);
+ modifiers |= ModifierSet.ABSTRACT;
+ break;
+ case SYNCHRONIZED:
+ jj_consume_token(SYNCHRONIZED);
+ modifiers |= ModifierSet.SYNCHRONIZED;
+ break;
+ case NATIVE:
+ jj_consume_token(NATIVE);
+ modifiers |= ModifierSet.NATIVE;
+ break;
+ case TRANSIENT:
+ jj_consume_token(TRANSIENT);
+ modifiers |= ModifierSet.TRANSIENT;
+ break;
+ case VOLATILE:
+ jj_consume_token(VOLATILE);
+ modifiers |= ModifierSet.VOLATILE;
+ break;
+ case STRICTFP:
+ jj_consume_token(STRICTFP);
+ modifiers |= ModifierSet.STRICTFP;
+ break;
+ case AT:
+ Annotation();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ {
+ if (true) return modifiers;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ throw new Error("Missing return statement in function");
+ }
+
+ /*
+ * Declaration syntax follows.
+ */
+ final public void TypeDeclaration() throws ParseException {
+ /*@bgen(jjtree) TypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ case ABSTRACT:
+ case CLASS:
+ case ENUM:
+ case FINAL:
+ case INTERFACE:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case AT:
+ modifiers = Modifiers();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(modifiers);
+ break;
+ case ENUM:
+ EnumDeclaration(modifiers);
+ break;
+ case AT:
+ AnnotationTypeDeclaration(modifiers);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ boolean isInterface = false;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ jj_consume_token(CLASS);
+ break;
+ case INTERFACE:
+ jj_consume_token(INTERFACE);
+ isInterface = true;
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeParameters();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ ExtendsList(isInterface);
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPLEMENTS:
+ ImplementsList(isInterface);
+ break;
+ default:
+ ;
+ }
+ ClassOrInterfaceBody(isInterface);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ExtendsList(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ExtendsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXTENDSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ boolean extendsMoreThanOne = false;
+ try {
+ jj_consume_token(EXTENDS);
+ ClassOrInterfaceType();
+ label_4:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_4;
+ }
+ jj_consume_token(COMMA);
+ ClassOrInterfaceType();
+ extendsMoreThanOne = true;
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ if (extendsMoreThanOne && !isInterface) {
+ if (true)
+ throw new ParseException("A class cannot extend more than one other class");
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ImplementsList(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ImplementsList */
+ SimpleNode jjtn000 = new SimpleNode(JJTIMPLEMENTSLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IMPLEMENTS);
+ ClassOrInterfaceType();
+ label_5:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_5;
+ }
+ jj_consume_token(COMMA);
+ ClassOrInterfaceType();
+ }
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ if (isInterface) {
+ if (true)
+ throw new ParseException("An interface cannot implement other interfaces");
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EnumDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) EnumDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(ENUM);
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IMPLEMENTS:
+ ImplementsList(false);
+ break;
+ default:
+ ;
+ }
+ EnumBody();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EnumBody() throws ParseException {
+ /*@bgen(jjtree) EnumBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case FINAL:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ EnumConstant();
+ label_6:
+ while (true) {
+ if (jj_2_7(2)) {
+ ;
+ } else {
+ break label_6;
+ }
+ jj_consume_token(COMMA);
+ EnumConstant();
+ }
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ jj_consume_token(COMMA);
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ label_7:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOID:
+ case VOLATILE:
+ case IDENTIFIER:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case LT:
+ ;
+ break;
+ default:
+ break label_7;
+ }
+ ClassOrInterfaceBodyDeclaration(false);
+ }
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EnumConstant() throws ParseException {
+ /*@bgen(jjtree) EnumConstant */
+ SimpleNode jjtn000 = new SimpleNode(JJTENUMCONSTANT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LPAREN:
+ Arguments();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ ClassOrInterfaceBody(false);
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeParameters() throws ParseException {
+ /*@bgen(jjtree) TypeParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LT);
+ TypeParameter();
+ label_8:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_8;
+ }
+ jj_consume_token(COMMA);
+ TypeParameter();
+ }
+ jj_consume_token(GT);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeParameter() throws ParseException {
+ /*@bgen(jjtree) TypeParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ TypeBound();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeBound() throws ParseException {
+ /*@bgen(jjtree) TypeBound */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEBOUND);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(EXTENDS);
+ ClassOrInterfaceType();
+ label_9:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BIT_AND:
+ ;
+ break;
+ default:
+ break label_9;
+ }
+ jj_consume_token(BIT_AND);
+ ClassOrInterfaceType();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceBody(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ label_10:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOID:
+ case VOLATILE:
+ case IDENTIFIER:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case LT:
+ ;
+ break;
+ default:
+ break label_10;
+ }
+ ClassOrInterfaceBodyDeclaration(isInterface);
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceBodyDeclaration(boolean isInterface) throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceBodyDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACEBODYDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ boolean isNestedInterface = false;
+ int modifiers;
+ try {
+ if (jj_2_10(2)) {
+ Initializer();
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtc000 = false;
+ jjtreeCloseNodeScope(jjtn000);
+ if (isInterface) {
+ if (true)
+ throw new ParseException("An interface cannot have initializers");
+ }
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOID:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ case LT:
+ modifiers = Modifiers();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(modifiers);
+ break;
+ case ENUM:
+ EnumDeclaration(modifiers);
+ break;
+ default:
+ if (jj_2_8(2147483647)) {
+ ConstructorDeclaration();
+ } else if (jj_2_9(2147483647)) {
+ FieldDeclaration(modifiers);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case VOID:
+ case IDENTIFIER:
+ case LT:
+ MethodDeclaration(modifiers);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ break;
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void FieldDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) FieldDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTFIELDDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Type();
+ VariableDeclarator();
+ label_11:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_11;
+ }
+ jj_consume_token(COMMA);
+ VariableDeclarator();
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void VariableDeclarator() throws ParseException {
+ /*@bgen(jjtree) VariableDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ VariableDeclaratorId();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSIGN:
+ jj_consume_token(ASSIGN);
+ VariableInitializer();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void VariableDeclaratorId() throws ParseException {
+ /*@bgen(jjtree) VariableDeclaratorId */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEDECLARATORID);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ label_12:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ;
+ break;
+ default:
+ break label_12;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void VariableInitializer() throws ParseException {
+ /*@bgen(jjtree) VariableInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTVARIABLEINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ ArrayInitializer();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ Expression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ArrayInitializer() throws ParseException {
+ /*@bgen(jjtree) ArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ VariableInitializer();
+ label_13:
+ while (true) {
+ if (jj_2_11(2)) {
+ ;
+ } else {
+ break label_13;
+ }
+ jj_consume_token(COMMA);
+ VariableInitializer();
+ }
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ jj_consume_token(COMMA);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MethodDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) MethodDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeParameters();
+ break;
+ default:
+ ;
+ }
+ ResultType();
+ MethodDeclarator();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case THROWS:
+ jj_consume_token(THROWS);
+ NameList();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ Block();
+ break;
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MethodDeclarator() throws ParseException {
+ /*@bgen(jjtree) MethodDeclarator */
+ SimpleNode jjtn000 = new SimpleNode(JJTMETHODDECLARATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ FormalParameters();
+ label_14:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ;
+ break;
+ default:
+ break label_14;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void FormalParameters() throws ParseException {
+ /*@bgen(jjtree) FormalParameters */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETERS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ FormalParameter();
+ label_15:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_15;
+ }
+ jj_consume_token(COMMA);
+ FormalParameter();
+ }
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void FormalParameter() throws ParseException {
+ /*@bgen(jjtree) FormalParameter */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORMALPARAMETER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ Type();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ELLIPSIS:
+ jj_consume_token(ELLIPSIS);
+ break;
+ default:
+ ;
+ }
+ VariableDeclaratorId();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConstructorDeclaration() throws ParseException {
+ /*@bgen(jjtree) ConstructorDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONSTRUCTORDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeParameters();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(IDENTIFIER);
+ FormalParameters();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case THROWS:
+ jj_consume_token(THROWS);
+ NameList();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(LBRACE);
+ if (jj_2_12(2147483647)) {
+ ExplicitConstructorInvocation();
+ } else {
+ ;
+ }
+ label_16:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case RETURN:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRANSIENT:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case VOLATILE:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ ;
+ break;
+ default:
+ break label_16;
+ }
+ BlockStatement();
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ExplicitConstructorInvocation() throws ParseException {
+ /*@bgen(jjtree) ExplicitConstructorInvocation */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPLICITCONSTRUCTORINVOCATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ label_17:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ break label_17;
+ }
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(DOT);
+ }
+ if (jj_2_13(2)) {
+ jj_consume_token(THIS);
+ jj_consume_token(DOT);
+ } else {
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeArguments();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case THIS:
+ jj_consume_token(THIS);
+ break;
+ case SUPER:
+ jj_consume_token(SUPER);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ Arguments();
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Initializer() throws ParseException {
+ /*@bgen(jjtree) Initializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STATIC:
+ jj_consume_token(STATIC);
+ break;
+ default:
+ ;
+ }
+ Block();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Type, name and expression syntax follows.
+ */
+ final public void Type() throws ParseException {
+ /*@bgen(jjtree) Type */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_14(2)) {
+ ReferenceType();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ PrimitiveType();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ReferenceType() throws ParseException {
+ /*@bgen(jjtree) ReferenceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTREFERENCETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ PrimitiveType();
+ label_18:
+ while (true) {
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ if (jj_2_15(2)) {
+ ;
+ } else {
+ break label_18;
+ }
+ }
+ break;
+ case IDENTIFIER:
+ ClassOrInterfaceType();
+ label_19:
+ while (true) {
+ if (jj_2_16(2)) {
+ ;
+ } else {
+ break label_19;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ClassOrInterfaceType() throws ParseException {
+ /*@bgen(jjtree) ClassOrInterfaceType */
+ SimpleNode jjtn000 = new SimpleNode(JJTCLASSORINTERFACETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ if (jj_2_17(2)) {
+ TypeArguments();
+ } else {
+ ;
+ }
+ label_20:
+ while (true) {
+ if (jj_2_18(2)) {
+ ;
+ } else {
+ break label_20;
+ }
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ if (jj_2_19(2)) {
+ TypeArguments();
+ } else {
+ ;
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeArguments() throws ParseException {
+ /*@bgen(jjtree) TypeArguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LT);
+ TypeArgument();
+ label_21:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_21;
+ }
+ jj_consume_token(COMMA);
+ TypeArgument();
+ }
+ jj_consume_token(GT);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TypeArgument() throws ParseException {
+ /*@bgen(jjtree) TypeArgument */
+ SimpleNode jjtn000 = new SimpleNode(JJTTYPEARGUMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case IDENTIFIER:
+ ReferenceType();
+ break;
+ case HOOK:
+ jj_consume_token(HOOK);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ case SUPER:
+ WildcardBounds();
+ break;
+ default:
+ ;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void WildcardBounds() throws ParseException {
+ /*@bgen(jjtree) WildcardBounds */
+ SimpleNode jjtn000 = new SimpleNode(JJTWILDCARDBOUNDS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EXTENDS:
+ jj_consume_token(EXTENDS);
+ ReferenceType();
+ break;
+ case SUPER:
+ jj_consume_token(SUPER);
+ ReferenceType();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimitiveType() throws ParseException {
+ /*@bgen(jjtree) PrimitiveType */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMITIVETYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ jj_consume_token(BOOLEAN);
+ break;
+ case CHAR:
+ jj_consume_token(CHAR);
+ break;
+ case BYTE:
+ jj_consume_token(BYTE);
+ break;
+ case SHORT:
+ jj_consume_token(SHORT);
+ break;
+ case INT:
+ jj_consume_token(INT);
+ break;
+ case LONG:
+ jj_consume_token(LONG);
+ break;
+ case FLOAT:
+ jj_consume_token(FLOAT);
+ break;
+ case DOUBLE:
+ jj_consume_token(DOUBLE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ResultType() throws ParseException {
+ /*@bgen(jjtree) ResultType */
+ SimpleNode jjtn000 = new SimpleNode(JJTRESULTTYPE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case VOID:
+ jj_consume_token(VOID);
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case IDENTIFIER:
+ Type();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Name() throws ParseException {
+ /*@bgen(jjtree) Name */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAME);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ label_22:
+ while (true) {
+ if (jj_2_20(2)) {
+ ;
+ } else {
+ break label_22;
+ }
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void NameList() throws ParseException {
+ /*@bgen(jjtree) NameList */
+ SimpleNode jjtn000 = new SimpleNode(JJTNAMELIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Name();
+ label_23:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_23;
+ }
+ jj_consume_token(COMMA);
+ Name();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Expression syntax follows.
+ */
+ final public void Expression() throws ParseException {
+ /*@bgen(jjtree) Expression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ConditionalExpression();
+ if (jj_2_21(2)) {
+ AssignmentOperator();
+ Expression();
+ } else {
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AssignmentOperator() throws ParseException {
+ /*@bgen(jjtree) AssignmentOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSIGN:
+ jj_consume_token(ASSIGN);
+ break;
+ case STARASSIGN:
+ jj_consume_token(STARASSIGN);
+ break;
+ case SLASHASSIGN:
+ jj_consume_token(SLASHASSIGN);
+ break;
+ case REMASSIGN:
+ jj_consume_token(REMASSIGN);
+ break;
+ case PLUSASSIGN:
+ jj_consume_token(PLUSASSIGN);
+ break;
+ case MINUSASSIGN:
+ jj_consume_token(MINUSASSIGN);
+ break;
+ case LSHIFTASSIGN:
+ jj_consume_token(LSHIFTASSIGN);
+ break;
+ case RSIGNEDSHIFTASSIGN:
+ jj_consume_token(RSIGNEDSHIFTASSIGN);
+ break;
+ case RUNSIGNEDSHIFTASSIGN:
+ jj_consume_token(RUNSIGNEDSHIFTASSIGN);
+ break;
+ case ANDASSIGN:
+ jj_consume_token(ANDASSIGN);
+ break;
+ case XORASSIGN:
+ jj_consume_token(XORASSIGN);
+ break;
+ case ORASSIGN:
+ jj_consume_token(ORASSIGN);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AssignmentExpression() throws ParseException {
+ /*@bgen(jjtree) AssignmentExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSIGNMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ PrimaryExpression();
+ AssignmentOperator();
+ Expression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConditionalExpression() throws ParseException {
+ /*@bgen(jjtree) ConditionalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ConditionalOrExpression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case HOOK:
+ jj_consume_token(HOOK);
+ Expression();
+ jj_consume_token(COLON);
+ Expression();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConditionalOrExpression() throws ParseException {
+ /*@bgen(jjtree) ConditionalOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ConditionalAndExpression();
+ label_24:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SC_OR:
+ ;
+ break;
+ default:
+ break label_24;
+ }
+ jj_consume_token(SC_OR);
+ ConditionalAndExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ConditionalAndExpression() throws ParseException {
+ /*@bgen(jjtree) ConditionalAndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONDITIONALANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ InclusiveOrExpression();
+ label_25:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SC_AND:
+ ;
+ break;
+ default:
+ break label_25;
+ }
+ jj_consume_token(SC_AND);
+ InclusiveOrExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void InclusiveOrExpression() throws ParseException {
+ /*@bgen(jjtree) InclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ExclusiveOrExpression();
+ label_26:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BIT_OR:
+ ;
+ break;
+ default:
+ break label_26;
+ }
+ jj_consume_token(BIT_OR);
+ ExclusiveOrExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ExclusiveOrExpression() throws ParseException {
+ /*@bgen(jjtree) ExclusiveOrExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEXCLUSIVEOREXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ AndExpression();
+ label_27:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case XOR:
+ ;
+ break;
+ default:
+ break label_27;
+ }
+ jj_consume_token(XOR);
+ AndExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AndExpression() throws ParseException {
+ /*@bgen(jjtree) AndExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTANDEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ EqualityExpression();
+ label_28:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BIT_AND:
+ ;
+ break;
+ default:
+ break label_28;
+ }
+ jj_consume_token(BIT_AND);
+ EqualityExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EqualityExpression() throws ParseException {
+ /*@bgen(jjtree) EqualityExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTEQUALITYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ InstanceOfExpression();
+ label_29:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EQ:
+ case NE:
+ ;
+ break;
+ default:
+ break label_29;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case EQ:
+ jj_consume_token(EQ);
+ break;
+ case NE:
+ jj_consume_token(NE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ InstanceOfExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void InstanceOfExpression() throws ParseException {
+ /*@bgen(jjtree) InstanceOfExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTINSTANCEOFEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ RelationalExpression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INSTANCEOF:
+ jj_consume_token(INSTANCEOF);
+ Type();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void RelationalExpression() throws ParseException {
+ /*@bgen(jjtree) RelationalExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTRELATIONALEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ ShiftExpression();
+ label_30:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ case LE:
+ case GE:
+ case GT:
+ ;
+ break;
+ default:
+ break label_30;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ jj_consume_token(LT);
+ break;
+ case GT:
+ jj_consume_token(GT);
+ break;
+ case LE:
+ jj_consume_token(LE);
+ break;
+ case GE:
+ jj_consume_token(GE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ ShiftExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ShiftExpression() throws ParseException {
+ /*@bgen(jjtree) ShiftExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSHIFTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ AdditiveExpression();
+ label_31:
+ while (true) {
+ if (jj_2_22(1)) {
+ ;
+ } else {
+ break label_31;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LSHIFT:
+ jj_consume_token(LSHIFT);
+ break;
+ default:
+ if (jj_2_23(1)) {
+ RSIGNEDSHIFT();
+ } else if (jj_2_24(1)) {
+ RUNSIGNEDSHIFT();
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ AdditiveExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AdditiveExpression() throws ParseException {
+ /*@bgen(jjtree) AdditiveExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTADDITIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ MultiplicativeExpression();
+ label_32:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ case MINUS:
+ ;
+ break;
+ default:
+ break label_32;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ jj_consume_token(PLUS);
+ break;
+ case MINUS:
+ jj_consume_token(MINUS);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ MultiplicativeExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MultiplicativeExpression() throws ParseException {
+ /*@bgen(jjtree) MultiplicativeExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTMULTIPLICATIVEEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ UnaryExpression();
+ label_33:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STAR:
+ case SLASH:
+ case REM:
+ ;
+ break;
+ default:
+ break label_33;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case STAR:
+ jj_consume_token(STAR);
+ break;
+ case SLASH:
+ jj_consume_token(SLASH);
+ break;
+ case REM:
+ jj_consume_token(REM);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ UnaryExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void UnaryExpression() throws ParseException {
+ /*@bgen(jjtree) UnaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ case MINUS:
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case PLUS:
+ jj_consume_token(PLUS);
+ break;
+ case MINUS:
+ jj_consume_token(MINUS);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ UnaryExpression();
+ break;
+ case INCR:
+ PreIncrementExpression();
+ break;
+ case DECR:
+ PreDecrementExpression();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ UnaryExpressionNotPlusMinus();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PreIncrementExpression() throws ParseException {
+ /*@bgen(jjtree) PreIncrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREINCREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(INCR);
+ PrimaryExpression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PreDecrementExpression() throws ParseException {
+ /*@bgen(jjtree) PreDecrementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPREDECREMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(DECR);
+ PrimaryExpression();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void UnaryExpressionNotPlusMinus() throws ParseException {
+ /*@bgen(jjtree) UnaryExpressionNotPlusMinus */
+ SimpleNode jjtn000 = new SimpleNode(JJTUNARYEXPRESSIONNOTPLUSMINUS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BANG:
+ case TILDE:
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case TILDE:
+ jj_consume_token(TILDE);
+ break;
+ case BANG:
+ jj_consume_token(BANG);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ UnaryExpression();
+ break;
+ default:
+ if (jj_2_25(2147483647)) {
+ CastExpression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ PostfixExpression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+// This production is to determine lookahead only. The LOOKAHEAD specifications
+// below are not used, but they are there just to indicate that we know about
+
+ // this.
+ final public void CastLookahead() throws ParseException {
+ /*@bgen(jjtree) CastLookahead */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTLOOKAHEAD);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_26(2)) {
+ jj_consume_token(LPAREN);
+ PrimitiveType();
+ } else if (jj_2_27(2147483647)) {
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(RPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case TILDE:
+ jj_consume_token(TILDE);
+ break;
+ case BANG:
+ jj_consume_token(BANG);
+ break;
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ break;
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ case THIS:
+ jj_consume_token(THIS);
+ break;
+ case SUPER:
+ jj_consume_token(SUPER);
+ break;
+ case NEW:
+ jj_consume_token(NEW);
+ break;
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ Literal();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PostfixExpression() throws ParseException {
+ /*@bgen(jjtree) PostfixExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ PrimaryExpression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INCR:
+ case DECR:
+ PostfixOperator();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PostfixOperator() throws ParseException {
+ /*@bgen(jjtree) PostfixOperator */
+ SimpleNode jjtn000 = new SimpleNode(JJTPOSTFIXOPERATOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INCR:
+ jj_consume_token(INCR);
+ break;
+ case DECR:
+ jj_consume_token(DECR);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void CastExpression() throws ParseException {
+ /*@bgen(jjtree) CastExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTCASTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_28(2147483647)) {
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(RPAREN);
+ UnaryExpression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ Type();
+ jj_consume_token(RPAREN);
+ UnaryExpressionNotPlusMinus();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimaryExpression() throws ParseException {
+ /*@bgen(jjtree) PrimaryExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ PrimaryPrefix();
+ label_34:
+ while (true) {
+ if (jj_2_29(2)) {
+ ;
+ } else {
+ break label_34;
+ }
+ PrimarySuffix();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberSelector() throws ParseException {
+ /*@bgen(jjtree) MemberSelector */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERSELECTOR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(DOT);
+ TypeArguments();
+ jj_consume_token(IDENTIFIER);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimaryPrefix() throws ParseException {
+ /*@bgen(jjtree) PrimaryPrefix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYPREFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case FALSE:
+ case NULL:
+ case TRUE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ Literal();
+ break;
+ default:
+ if (jj_2_30(2147483647)) {
+ label_35:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ ;
+ break;
+ default:
+ break label_35;
+ }
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(DOT);
+ }
+ jj_consume_token(THIS);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case SUPER:
+ jj_consume_token(SUPER);
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ break;
+ case LPAREN:
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ break;
+ case NEW:
+ AllocationExpression();
+ break;
+ default:
+ if (jj_2_31(2147483647)) {
+ ResultType();
+ jj_consume_token(DOT);
+ jj_consume_token(CLASS);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ Name();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void PrimarySuffix() throws ParseException {
+ /*@bgen(jjtree) PrimarySuffix */
+ SimpleNode jjtn000 = new SimpleNode(JJTPRIMARYSUFFIX);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_32(2147483647)) {
+ jj_consume_token(DOT);
+ jj_consume_token(SUPER);
+ } else if (jj_2_33(2147483647)) {
+ jj_consume_token(DOT);
+ jj_consume_token(THIS);
+ } else if (jj_2_34(2)) {
+ jj_consume_token(DOT);
+ AllocationExpression();
+ } else if (jj_2_35(3)) {
+ MemberSelector();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ jj_consume_token(LBRACKET);
+ Expression();
+ jj_consume_token(RBRACKET);
+ break;
+ case DOT:
+ jj_consume_token(DOT);
+ jj_consume_token(IDENTIFIER);
+ break;
+ case LPAREN:
+ Arguments();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Literal() throws ParseException {
+ /*@bgen(jjtree) Literal */
+ SimpleNode jjtn000 = new SimpleNode(JJTLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INTEGER_LITERAL:
+ jj_consume_token(INTEGER_LITERAL);
+ break;
+ case FLOATING_POINT_LITERAL:
+ jj_consume_token(FLOATING_POINT_LITERAL);
+ break;
+ case CHARACTER_LITERAL:
+ jj_consume_token(CHARACTER_LITERAL);
+ break;
+ case STRING_LITERAL:
+ jj_consume_token(STRING_LITERAL);
+ break;
+ case FALSE:
+ case TRUE:
+ BooleanLiteral();
+ break;
+ case NULL:
+ NullLiteral();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void BooleanLiteral() throws ParseException {
+ /*@bgen(jjtree) BooleanLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTBOOLEANLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case TRUE:
+ jj_consume_token(TRUE);
+ break;
+ case FALSE:
+ jj_consume_token(FALSE);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void NullLiteral() throws ParseException {
+ /*@bgen(jjtree) NullLiteral */
+ SimpleNode jjtn000 = new SimpleNode(JJTNULLLITERAL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(NULL);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Arguments() throws ParseException {
+ /*@bgen(jjtree) Arguments */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ ArgumentList();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ArgumentList() throws ParseException {
+ /*@bgen(jjtree) ArgumentList */
+ SimpleNode jjtn000 = new SimpleNode(JJTARGUMENTLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Expression();
+ label_36:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_36;
+ }
+ jj_consume_token(COMMA);
+ Expression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AllocationExpression() throws ParseException {
+ /*@bgen(jjtree) AllocationExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTALLOCATIONEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_36(2)) {
+ jj_consume_token(NEW);
+ PrimitiveType();
+ ArrayDimsAndInits();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case NEW:
+ jj_consume_token(NEW);
+ ClassOrInterfaceType();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LT:
+ TypeArguments();
+ break;
+ default:
+ ;
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ArrayDimsAndInits();
+ break;
+ case LPAREN:
+ Arguments();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACE:
+ ClassOrInterfaceBody(false);
+ break;
+ default:
+ ;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * The third LOOKAHEAD specification below is to parse to PrimarySuffix
+ * if there is an expression between the "[...]".
+ */
+ final public void ArrayDimsAndInits() throws ParseException {
+ /*@bgen(jjtree) ArrayDimsAndInits */
+ SimpleNode jjtn000 = new SimpleNode(JJTARRAYDIMSANDINITS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_39(2)) {
+ label_37:
+ while (true) {
+ jj_consume_token(LBRACKET);
+ Expression();
+ jj_consume_token(RBRACKET);
+ if (jj_2_37(2)) {
+ ;
+ } else {
+ break label_37;
+ }
+ }
+ label_38:
+ while (true) {
+ if (jj_2_38(2)) {
+ ;
+ } else {
+ break label_38;
+ }
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ }
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ label_39:
+ while (true) {
+ jj_consume_token(LBRACKET);
+ jj_consume_token(RBRACKET);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case LBRACKET:
+ ;
+ break;
+ default:
+ break label_39;
+ }
+ }
+ ArrayInitializer();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /*
+ * Statement syntax follows.
+ */
+ final public void Statement() throws ParseException {
+ /*@bgen(jjtree) Statement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_40(2)) {
+ LabeledStatement();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSERT:
+ AssertStatement();
+ break;
+ case LBRACE:
+ Block();
+ break;
+ case SEMICOLON:
+ EmptyStatement();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case INCR:
+ case DECR:
+ StatementExpression();
+ jj_consume_token(SEMICOLON);
+ break;
+ case SWITCH:
+ SwitchStatement();
+ break;
+ case IF:
+ IfStatement();
+ break;
+ case WHILE:
+ WhileStatement();
+ break;
+ case DO:
+ DoStatement();
+ break;
+ case FOR:
+ ForStatement();
+ break;
+ case BREAK:
+ BreakStatement();
+ break;
+ case CONTINUE:
+ ContinueStatement();
+ break;
+ case RETURN:
+ ReturnStatement();
+ break;
+ case THROW:
+ ThrowStatement();
+ break;
+ case SYNCHRONIZED:
+ SynchronizedStatement();
+ break;
+ case TRY:
+ TryStatement();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AssertStatement() throws ParseException {
+ /*@bgen(jjtree) AssertStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTASSERTSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(ASSERT);
+ Expression();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COLON:
+ jj_consume_token(COLON);
+ Expression();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void LabeledStatement() throws ParseException {
+ /*@bgen(jjtree) LabeledStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTLABELEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(COLON);
+ Statement();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void Block() throws ParseException {
+ /*@bgen(jjtree) Block */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCK);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ label_40:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case RETURN:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRANSIENT:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case VOLATILE:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ ;
+ break;
+ default:
+ break label_40;
+ }
+ BlockStatement();
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void BlockStatement() throws ParseException {
+ /*@bgen(jjtree) BlockStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBLOCKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_41(2147483647)) {
+ LocalVariableDeclaration();
+ jj_consume_token(SEMICOLON);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case RETURN:
+ case SHORT:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case INCR:
+ case DECR:
+ Statement();
+ break;
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(0);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void LocalVariableDeclaration() throws ParseException {
+ /*@bgen(jjtree) LocalVariableDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTLOCALVARIABLEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ Modifiers();
+ Type();
+ VariableDeclarator();
+ label_41:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_41;
+ }
+ jj_consume_token(COMMA);
+ VariableDeclarator();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void EmptyStatement() throws ParseException {
+ /*@bgen(jjtree) EmptyStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTEMPTYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(SEMICOLON);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void StatementExpression() throws ParseException {
+ /*@bgen(jjtree) StatementExpression */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case INCR:
+ PreIncrementExpression();
+ break;
+ case DECR:
+ PreDecrementExpression();
+ break;
+ default:
+ if (jj_2_42(2147483647)) {
+ AssignmentExpression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ PostfixExpression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SwitchStatement() throws ParseException {
+ /*@bgen(jjtree) SwitchStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(SWITCH);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ jj_consume_token(LBRACE);
+ label_42:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CASE:
+ case _DEFAULT:
+ ;
+ break;
+ default:
+ break label_42;
+ }
+ SwitchLabel();
+ label_43:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case ASSERT:
+ case BOOLEAN:
+ case BREAK:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case CONTINUE:
+ case DO:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case FOR:
+ case IF:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case RETURN:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SWITCH:
+ case SYNCHRONIZED:
+ case THIS:
+ case THROW:
+ case TRANSIENT:
+ case TRUE:
+ case TRY:
+ case VOID:
+ case VOLATILE:
+ case WHILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case LBRACE:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ ;
+ break;
+ default:
+ break label_43;
+ }
+ BlockStatement();
+ }
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SwitchLabel() throws ParseException {
+ /*@bgen(jjtree) SwitchLabel */
+ SimpleNode jjtn000 = new SimpleNode(JJTSWITCHLABEL);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CASE:
+ jj_consume_token(CASE);
+ Expression();
+ jj_consume_token(COLON);
+ break;
+ case _DEFAULT:
+ jj_consume_token(_DEFAULT);
+ jj_consume_token(COLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void IfStatement() throws ParseException {
+ /*@bgen(jjtree) IfStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTIFSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IF);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ Statement();
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ELSE:
+ jj_consume_token(ELSE);
+ Statement();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void WhileStatement() throws ParseException {
+ /*@bgen(jjtree) WhileStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTWHILESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(WHILE);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ Statement();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void DoStatement() throws ParseException {
+ /*@bgen(jjtree) DoStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTDOSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(DO);
+ Statement();
+ jj_consume_token(WHILE);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ForStatement() throws ParseException {
+ /*@bgen(jjtree) ForStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(FOR);
+ jj_consume_token(LPAREN);
+ if (jj_2_43(2147483647)) {
+ Modifiers();
+ Type();
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(COLON);
+ Expression();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SYNCHRONIZED:
+ case THIS:
+ case TRANSIENT:
+ case TRUE:
+ case VOID:
+ case VOLATILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case SEMICOLON:
+ case AT:
+ case INCR:
+ case DECR:
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NATIVE:
+ case NEW:
+ case NULL:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SUPER:
+ case SYNCHRONIZED:
+ case THIS:
+ case TRANSIENT:
+ case TRUE:
+ case VOID:
+ case VOLATILE:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case AT:
+ case INCR:
+ case DECR:
+ ForInit();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ Expression();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case INCR:
+ case DECR:
+ ForUpdate();
+ break;
+ default:
+ ;
+ }
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ jj_consume_token(RPAREN);
+ Statement();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ForInit() throws ParseException {
+ /*@bgen(jjtree) ForInit */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORINIT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_44(2147483647)) {
+ LocalVariableDeclaration();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case INCR:
+ case DECR:
+ StatementExpressionList();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void StatementExpressionList() throws ParseException {
+ /*@bgen(jjtree) StatementExpressionList */
+ SimpleNode jjtn000 = new SimpleNode(JJTSTATEMENTEXPRESSIONLIST);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ StatementExpression();
+ label_44:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_44;
+ }
+ jj_consume_token(COMMA);
+ StatementExpression();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ForUpdate() throws ParseException {
+ /*@bgen(jjtree) ForUpdate */
+ SimpleNode jjtn000 = new SimpleNode(JJTFORUPDATE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ StatementExpressionList();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void BreakStatement() throws ParseException {
+ /*@bgen(jjtree) BreakStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTBREAKSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(BREAK);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ContinueStatement() throws ParseException {
+ /*@bgen(jjtree) ContinueStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTCONTINUESTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(CONTINUE);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ jj_consume_token(IDENTIFIER);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ReturnStatement() throws ParseException {
+ /*@bgen(jjtree) ReturnStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTRETURNSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(RETURN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ Expression();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void ThrowStatement() throws ParseException {
+ /*@bgen(jjtree) ThrowStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTHROWSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(THROW);
+ Expression();
+ jj_consume_token(SEMICOLON);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SynchronizedStatement() throws ParseException {
+ /*@bgen(jjtree) SynchronizedStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTSYNCHRONIZEDSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(SYNCHRONIZED);
+ jj_consume_token(LPAREN);
+ Expression();
+ jj_consume_token(RPAREN);
+ Block();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void TryStatement() throws ParseException {
+ /*@bgen(jjtree) TryStatement */
+ SimpleNode jjtn000 = new SimpleNode(JJTTRYSTATEMENT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(TRY);
+ Block();
+ label_45:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CATCH:
+ ;
+ break;
+ default:
+ break label_45;
+ }
+ jj_consume_token(CATCH);
+ jj_consume_token(LPAREN);
+ FormalParameter();
+ jj_consume_token(RPAREN);
+ Block();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case FINALLY:
+ jj_consume_token(FINALLY);
+ Block();
+ break;
+ default:
+ ;
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /* We use productions to match >>>, >> and > so that we can keep the
+ * type declaration syntax with generics clean
+ */
+ final public void RUNSIGNEDSHIFT() throws ParseException {
+ /*@bgen(jjtree) RUNSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRUNSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT) {
+
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(GT);
+ jj_consume_token(GT);
+ jj_consume_token(GT);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void RSIGNEDSHIFT() throws ParseException {
+ /*@bgen(jjtree) RSIGNEDSHIFT */
+ SimpleNode jjtn000 = new SimpleNode(JJTRSIGNEDSHIFT);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT) {
+
+ } else {
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ jj_consume_token(GT);
+ jj_consume_token(GT);
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /* Annotation syntax follows. */
+ final public void Annotation() throws ParseException {
+ /*@bgen(jjtree) Annotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ if (jj_2_45(2147483647)) {
+ NormalAnnotation();
+ } else if (jj_2_46(2147483647)) {
+ SingleMemberAnnotation();
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case AT:
+ MarkerAnnotation();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void NormalAnnotation() throws ParseException {
+ /*@bgen(jjtree) NormalAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTNORMALANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ Name();
+ jj_consume_token(LPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case IDENTIFIER:
+ MemberValuePairs();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MarkerAnnotation() throws ParseException {
+ /*@bgen(jjtree) MarkerAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTMARKERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ Name();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void SingleMemberAnnotation() throws ParseException {
+ /*@bgen(jjtree) SingleMemberAnnotation */
+ SimpleNode jjtn000 = new SimpleNode(JJTSINGLEMEMBERANNOTATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ Name();
+ jj_consume_token(LPAREN);
+ MemberValue();
+ jj_consume_token(RPAREN);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValuePairs() throws ParseException {
+ /*@bgen(jjtree) MemberValuePairs */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIRS);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ MemberValuePair();
+ label_46:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ ;
+ break;
+ default:
+ break label_46;
+ }
+ jj_consume_token(COMMA);
+ MemberValuePair();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValuePair() throws ParseException {
+ /*@bgen(jjtree) MemberValuePair */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEPAIR);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(ASSIGN);
+ MemberValue();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValue() throws ParseException {
+ /*@bgen(jjtree) MemberValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case AT:
+ Annotation();
+ break;
+ case LBRACE:
+ MemberValueArrayInitializer();
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FALSE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case NEW:
+ case NULL:
+ case SHORT:
+ case SUPER:
+ case THIS:
+ case TRUE:
+ case VOID:
+ case INTEGER_LITERAL:
+ case FLOATING_POINT_LITERAL:
+ case CHARACTER_LITERAL:
+ case STRING_LITERAL:
+ case IDENTIFIER:
+ case LPAREN:
+ case BANG:
+ case TILDE:
+ case INCR:
+ case DECR:
+ case PLUS:
+ case MINUS:
+ ConditionalExpression();
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void MemberValueArrayInitializer() throws ParseException {
+ /*@bgen(jjtree) MemberValueArrayInitializer */
+ SimpleNode jjtn000 = new SimpleNode(JJTMEMBERVALUEARRAYINITIALIZER);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ MemberValue();
+ label_47:
+ while (true) {
+ if (jj_2_47(2)) {
+ ;
+ } else {
+ break label_47;
+ }
+ jj_consume_token(COMMA);
+ MemberValue();
+ }
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case COMMA:
+ jj_consume_token(COMMA);
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ /* Annotation Types. */
+ final public void AnnotationTypeDeclaration(int modifiers) throws ParseException {
+ /*@bgen(jjtree) AnnotationTypeDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(AT);
+ jj_consume_token(INTERFACE);
+ jj_consume_token(IDENTIFIER);
+ AnnotationTypeBody();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnnotationTypeBody() throws ParseException {
+ /*@bgen(jjtree) AnnotationTypeBody */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEBODY);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(LBRACE);
+ label_48:
+ while (true) {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case SEMICOLON:
+ case AT:
+ ;
+ break;
+ default:
+ break label_48;
+ }
+ AnnotationTypeMemberDeclaration();
+ }
+ jj_consume_token(RBRACE);
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void AnnotationTypeMemberDeclaration() throws ParseException {
+ /*@bgen(jjtree) AnnotationTypeMemberDeclaration */
+ SimpleNode jjtn000 = new SimpleNode(JJTANNOTATIONTYPEMEMBERDECLARATION);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ int modifiers;
+ try {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case ABSTRACT:
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case CLASS:
+ case DOUBLE:
+ case ENUM:
+ case FINAL:
+ case FLOAT:
+ case INT:
+ case INTERFACE:
+ case LONG:
+ case NATIVE:
+ case PRIVATE:
+ case PROTECTED:
+ case PUBLIC:
+ case SHORT:
+ case STATIC:
+ case STRICTFP:
+ case SYNCHRONIZED:
+ case TRANSIENT:
+ case VOLATILE:
+ case IDENTIFIER:
+ case AT:
+ modifiers = Modifiers();
+ if (jj_2_48(2147483647)) {
+ Type();
+ jj_consume_token(IDENTIFIER);
+ jj_consume_token(LPAREN);
+ jj_consume_token(RPAREN);
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case _DEFAULT:
+ DefaultValue();
+ break;
+ default:
+ ;
+ }
+ jj_consume_token(SEMICOLON);
+ } else {
+ switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
+ case CLASS:
+ case INTERFACE:
+ ClassOrInterfaceDeclaration(modifiers);
+ break;
+ case ENUM:
+ EnumDeclaration(modifiers);
+ break;
+ case AT:
+ AnnotationTypeDeclaration(modifiers);
+ break;
+ case BOOLEAN:
+ case BYTE:
+ case CHAR:
+ case DOUBLE:
+ case FLOAT:
+ case INT:
+ case LONG:
+ case SHORT:
+ case IDENTIFIER:
+ FieldDeclaration(modifiers);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ }
+ break;
+ case SEMICOLON:
+ jj_consume_token(SEMICOLON);
+ break;
+ default:
+ jj_consume_token(-1);
+ throw new ParseException();
+ }
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final public void DefaultValue() throws ParseException {
+ /*@bgen(jjtree) DefaultValue */
+ SimpleNode jjtn000 = new SimpleNode(JJTDEFAULTVALUE);
+ boolean jjtc000 = true;
+ jjtree.openNodeScope(jjtn000);
+ jjtreeOpenNodeScope(jjtn000);
+ try {
+ jj_consume_token(_DEFAULT);
+ MemberValue();
+ } catch (Throwable jjte000) {
+ if (jjtc000) {
+ jjtree.clearNodeScope(jjtn000);
+ jjtc000 = false;
+ } else {
+ jjtree.popNode();
+ }
+ if (jjte000 instanceof RuntimeException) {
+ {
+ if (true) throw (RuntimeException) jjte000;
+ }
+ }
+ if (jjte000 instanceof ParseException) {
+ {
+ if (true) throw (ParseException) jjte000;
+ }
+ }
+ {
+ if (true) throw (Error) jjte000;
+ }
+ } finally {
+ if (jjtc000) {
+ jjtree.closeNodeScope(jjtn000, true);
+ jjtreeCloseNodeScope(jjtn000);
+ }
+ }
+ }
+
+ final private boolean jj_2_1(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_1();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_2(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_2();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_3(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_3();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_4(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_4();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_5(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_5();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_6(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_6();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_7(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_7();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_8(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_8();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_9(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_9();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_10(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_10();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_11(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_11();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_12(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_12();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_13(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_13();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_14(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_14();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_15(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_15();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_16(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_16();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_17(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_17();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_18(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_18();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_19(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_19();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_20(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_20();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_21(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_21();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_22(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_22();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_23(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_23();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_24(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_24();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_25(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_25();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_26(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_26();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_27(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_27();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_28(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_28();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_29(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_29();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_30(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_30();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_31(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_31();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_32(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_32();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_33(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_33();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_34(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_34();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_35(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_35();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_36(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_36();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_37(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_37();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_38(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_38();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_39(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_39();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_40(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_40();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_41(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_41();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_42(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_42();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_43(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_43();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_44(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_44();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_45(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_45();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_46(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_46();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_47(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_47();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_2_48(int xla) {
+ jj_la = xla;
+ jj_lastpos = jj_scanpos = token;
+ try {
+ return !jj_3_48();
+ }
+ catch (LookaheadSuccess ls) {
+ return true;
+ }
+ }
+
+ final private boolean jj_3R_56() {
+ if (jj_3R_101()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_21()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_135() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_91()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_99() {
+ if (jj_3R_91()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_135()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_20() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_91() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_20()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_122() {
+ if (jj_3R_72()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_86() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(58)) {
+ jj_scanpos = xsp;
+ if (jj_3R_122()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_19() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_83() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(10)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(15)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(12)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(46)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(35)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(37)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(28)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(21)) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_194() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_112()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_290() {
+ if (jj_scan_token(SUPER)) return true;
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_16() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_289() {
+ if (jj_scan_token(EXTENDS)) return true;
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_277() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_289()) {
+ jj_scanpos = xsp;
+ if (jj_3R_290()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_256() {
+ if (jj_3R_277()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_151() {
+ if (jj_scan_token(HOOK)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_256()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3_17() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_112() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_150()) {
+ jj_scanpos = xsp;
+ if (jj_3R_151()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_150() {
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_15() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_78() {
+ if (jj_scan_token(LT)) return true;
+ if (jj_3R_112()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_194()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_18() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_19()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_149() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_17()) jj_scanpos = xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_18()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_111() {
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_16()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_110() {
+ if (jj_3R_83()) return true;
+ Token xsp;
+ if (jj_3_15()) return true;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_15()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_77() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_110()) {
+ jj_scanpos = xsp;
+ if (jj_3R_111()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_13() {
+ if (jj_scan_token(THIS)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_221() {
+ if (jj_scan_token(THROWS)) return true;
+ if (jj_3R_99()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_103() {
+ if (jj_3R_83()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_72() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_14()) {
+ jj_scanpos = xsp;
+ if (jj_3R_103()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_14() {
+ if (jj_3R_77()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_74() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(47)) jj_scanpos = xsp;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_12() {
+ if (jj_3R_76()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_108() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_107() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_252() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_76() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_107()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_3_13()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_108()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(52)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(49)) return true;
+ }
+ if (jj_3R_109()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_134() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_133()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_223() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_222() {
+ if (jj_3R_76()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_220() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_186() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_220()) jj_scanpos = xsp;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_3R_53()) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_221()) jj_scanpos = xsp;
+ if (jj_scan_token(LBRACE)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_222()) jj_scanpos = xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_223()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_11() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_75()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_227() {
+ if (jj_scan_token(THROWS)) return true;
+ if (jj_3R_99()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_98() {
+ if (jj_3R_133()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_134()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_133() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(119)) jj_scanpos = xsp;
+ if (jj_3R_184()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_53() {
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_98()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_48() {
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_226() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_3R_53()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_252()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_228() {
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_225() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_292() {
+ if (jj_3R_75()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_11()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_188() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_225()) jj_scanpos = xsp;
+ if (jj_3R_86()) return true;
+ if (jj_3R_226()) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_227()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_228()) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(81)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_198() {
+ if (jj_scan_token(ASSIGN)) return true;
+ if (jj_3R_75()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_224() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_161()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_47() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_93()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_217() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_147() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_292()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) jj_scanpos = xsp;
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_73() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_106() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_105() {
+ if (jj_3R_147()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_75() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_105()) {
+ jj_scanpos = xsp;
+ if (jj_3R_106()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_184() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_217()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_160() {
+ if (jj_scan_token(LBRACE)) return true;
+ if (jj_3R_93()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_47()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) jj_scanpos = xsp;
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_276() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_275()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_161() {
+ if (jj_3R_184()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_198()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_127() {
+ if (jj_3R_101()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_9() {
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_73()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(85)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(81)) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_126() {
+ if (jj_3R_160()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_71() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_93() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_125()) {
+ jj_scanpos = xsp;
+ if (jj_3R_126()) {
+ jj_scanpos = xsp;
+ if (jj_3R_127()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_125() {
+ if (jj_3R_102()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_8() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_71()) jj_scanpos = xsp;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_187() {
+ if (jj_3R_72()) return true;
+ if (jj_3R_161()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_224()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_275() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(ASSIGN)) return true;
+ if (jj_3R_93()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_140() {
+ if (jj_3R_188()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_139() {
+ if (jj_3R_187()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_249() {
+ if (jj_scan_token(BIT_AND)) return true;
+ if (jj_3R_149()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_138() {
+ if (jj_3R_186()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_255() {
+ if (jj_3R_275()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_276()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_231() {
+ if (jj_3R_255()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_137() {
+ if (jj_3R_185()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_92() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(ASSIGN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_136() {
+ if (jj_3R_130()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_192() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_93()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_286() {
+ if (jj_3R_182()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_100() {
+ if (jj_3R_50()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_136()) {
+ jj_scanpos = xsp;
+ if (jj_3R_137()) {
+ jj_scanpos = xsp;
+ if (jj_3R_138()) {
+ jj_scanpos = xsp;
+ if (jj_3R_139()) {
+ jj_scanpos = xsp;
+ if (jj_3R_140()) return true;
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_193() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_46() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_10() {
+ if (jj_3R_74()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_55() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_10()) {
+ jj_scanpos = xsp;
+ if (jj_3R_100()) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(81)) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_191() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_231()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_45() {
+ if (jj_scan_token(AT)) return true;
+ if (jj_3R_91()) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_92()) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(76)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_215() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_132() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_131()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_183() {
+ if (jj_3R_216()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_285() {
+ if (jj_3R_109()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_145() {
+ if (jj_3R_193()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_182() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_215()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_144() {
+ if (jj_3R_192()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_113() {
+ return false;
+ }
+
+ final private boolean jj_3R_102() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_143()) {
+ jj_scanpos = xsp;
+ if (jj_3R_144()) {
+ jj_scanpos = xsp;
+ if (jj_3R_145()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_143() {
+ if (jj_3R_191()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_216() {
+ if (jj_scan_token(EXTENDS)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_249()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_131() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_183()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_114() {
+ return false;
+ }
+
+ final private boolean jj_3_7() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_70()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_80() {
+ Token xsp;
+ xsp = jj_scanpos;
+ lookingAhead = true;
+ jj_semLA = getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RSIGNEDSHIFT;
+ lookingAhead = false;
+ if (!jj_semLA || jj_3R_113()) return true;
+ if (jj_scan_token(GT)) return true;
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_97() {
+ if (jj_scan_token(LT)) return true;
+ if (jj_3R_131()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_132()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_272() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_70() {
+ if (jj_3R_50()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_285()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_286()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_81() {
+ Token xsp;
+ xsp = jj_scanpos;
+ lookingAhead = true;
+ jj_semLA = getToken(1).kind == GT &&
+ ((Token.GTToken) getToken(1)).realKind == RUNSIGNEDSHIFT;
+ lookingAhead = false;
+ if (!jj_semLA || jj_3R_114()) return true;
+ if (jj_scan_token(GT)) return true;
+ if (jj_scan_token(GT)) return true;
+ if (jj_scan_token(GT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_251() {
+ if (jj_scan_token(SEMICOLON)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_272()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_250() {
+ if (jj_3R_70()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_7()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_246() {
+ if (jj_scan_token(FINALLY)) return true;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_219() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_250()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(82)) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_251()) jj_scanpos = xsp;
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_245() {
+ if (jj_scan_token(CATCH)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_133()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_212() {
+ if (jj_scan_token(TRY)) return true;
+ if (jj_3R_104()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_245()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ xsp = jj_scanpos;
+ if (jj_3R_246()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_218() {
+ if (jj_3R_214()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_185() {
+ if (jj_scan_token(ENUM)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_218()) jj_scanpos = xsp;
+ if (jj_3R_219()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_211() {
+ if (jj_scan_token(SYNCHRONIZED)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_244() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_248() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_149()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_214() {
+ if (jj_scan_token(IMPLEMENTS)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_248()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_210() {
+ if (jj_scan_token(THROW)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_271() {
+ if (jj_3R_284()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_299() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_201()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_209() {
+ if (jj_scan_token(RETURN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_244()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_247() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_149()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_213() {
+ if (jj_scan_token(EXTENDS)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_247()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_208() {
+ if (jj_scan_token(CONTINUE)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(72)) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_178() {
+ if (jj_scan_token(INTERFACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_207() {
+ if (jj_scan_token(BREAK)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(72)) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_181() {
+ if (jj_3R_214()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_180() {
+ if (jj_3R_213()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_179() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_284() {
+ if (jj_3R_296()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_270() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_130() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(16)) {
+ jj_scanpos = xsp;
+ if (jj_3R_178()) return true;
+ }
+ if (jj_scan_token(IDENTIFIER)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_179()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_180()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_181()) jj_scanpos = xsp;
+ if (jj_3R_182()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_44() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_296() {
+ if (jj_3R_201()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_299()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_241() {
+ if (jj_scan_token(ELSE)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_295() {
+ if (jj_3R_296()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_43() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_294() {
+ if (jj_3R_128()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_283() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_294()) {
+ jj_scanpos = xsp;
+ if (jj_3R_295()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_269() {
+ if (jj_3R_283()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_243() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_269()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_270()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_271()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_242() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_54() {
+ if (jj_scan_token(THROWS)) return true;
+ if (jj_3R_99()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_206() {
+ if (jj_scan_token(FOR)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_242()) {
+ jj_scanpos = xsp;
+ if (jj_3R_243()) return true;
+ }
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_69() {
+ if (jj_3R_102()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_205() {
+ if (jj_scan_token(DO)) return true;
+ if (jj_3R_129()) return true;
+ if (jj_scan_token(WHILE)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_68() {
+ if (jj_scan_token(STRICTFP)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_67() {
+ if (jj_scan_token(VOLATILE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_66() {
+ if (jj_scan_token(TRANSIENT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_204() {
+ if (jj_scan_token(WHILE)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_65() {
+ if (jj_scan_token(NATIVE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_64() {
+ if (jj_scan_token(SYNCHRONIZED)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_63() {
+ if (jj_scan_token(ABSTRACT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_268() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_203() {
+ if (jj_scan_token(IF)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_129()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_241()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_62() {
+ if (jj_scan_token(FINAL)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_61() {
+ if (jj_scan_token(PRIVATE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_162() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_161()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_60() {
+ if (jj_scan_token(PROTECTED)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_59() {
+ if (jj_scan_token(STATIC)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_58() {
+ if (jj_scan_token(PUBLIC)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_282() {
+ if (jj_scan_token(_DEFAULT)) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_6() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_58()) {
+ jj_scanpos = xsp;
+ if (jj_3R_59()) {
+ jj_scanpos = xsp;
+ if (jj_3R_60()) {
+ jj_scanpos = xsp;
+ if (jj_3R_61()) {
+ jj_scanpos = xsp;
+ if (jj_3R_62()) {
+ jj_scanpos = xsp;
+ if (jj_3R_63()) {
+ jj_scanpos = xsp;
+ if (jj_3R_64()) {
+ jj_scanpos = xsp;
+ if (jj_3R_65()) {
+ jj_scanpos = xsp;
+ if (jj_3R_66()) {
+ jj_scanpos = xsp;
+ if (jj_3R_67()) {
+ jj_scanpos = xsp;
+ if (jj_3R_68()) {
+ jj_scanpos = xsp;
+ if (jj_3R_69()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_281() {
+ if (jj_scan_token(CASE)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(COLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_267() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_281()) {
+ jj_scanpos = xsp;
+ if (jj_3R_282()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_50() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_6()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_240() {
+ if (jj_3R_267()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_268()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_42() {
+ if (jj_3R_90()) return true;
+ if (jj_3R_79()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_202() {
+ if (jj_scan_token(SWITCH)) return true;
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_240()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_239() {
+ if (jj_3R_266()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_57() {
+ if (jj_3R_102()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_52() {
+ if (jj_3R_86()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_238() {
+ if (jj_3R_265()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_5() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_57()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(PACKAGE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_237() {
+ if (jj_3R_264()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_201() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_236()) {
+ jj_scanpos = xsp;
+ if (jj_3R_237()) {
+ jj_scanpos = xsp;
+ if (jj_3R_238()) {
+ jj_scanpos = xsp;
+ if (jj_3R_239()) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_236() {
+ if (jj_3R_263()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_200() {
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_41() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_128() {
+ if (jj_3R_50()) return true;
+ if (jj_3R_72()) return true;
+ if (jj_3R_161()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_162()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_51() {
+ if (jj_3R_97()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_235() {
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_96() {
+ if (jj_3R_130()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_95() {
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_4() {
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_94() {
+ if (jj_3R_128()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_49() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_94()) {
+ jj_scanpos = xsp;
+ if (jj_3R_95()) {
+ jj_scanpos = xsp;
+ if (jj_3R_96()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_146() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_3() {
+ if (jj_3R_55()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_104() {
+ if (jj_scan_token(LBRACE)) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_146()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(RBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_2() {
+ if (jj_3R_50()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_51()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_52()) jj_scanpos = xsp;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_3R_53()) return true;
+ xsp = jj_scanpos;
+ if (jj_3R_54()) jj_scanpos = xsp;
+ if (jj_scan_token(LBRACE)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_89() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_129()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_1() {
+ if (jj_3R_49()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_199() {
+ if (jj_scan_token(ASSERT)) return true;
+ if (jj_3R_56()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_235()) jj_scanpos = xsp;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_177() {
+ if (jj_3R_212()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_176() {
+ if (jj_3R_211()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_38() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_175() {
+ if (jj_3R_210()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_174() {
+ if (jj_3R_209()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_173() {
+ if (jj_3R_208()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_172() {
+ if (jj_3R_207()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_171() {
+ if (jj_3R_206()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_170() {
+ if (jj_3R_205()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_169() {
+ if (jj_3R_204()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_168() {
+ if (jj_3R_203()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_167() {
+ if (jj_3R_202()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_166() {
+ if (jj_3R_201()) return true;
+ if (jj_scan_token(SEMICOLON)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_165() {
+ if (jj_3R_200()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_164() {
+ if (jj_3R_104()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_163() {
+ if (jj_3R_199()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_260() {
+ if (jj_3R_78()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_40() {
+ if (jj_3R_89()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_129() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_40()) {
+ jj_scanpos = xsp;
+ if (jj_3R_163()) {
+ jj_scanpos = xsp;
+ if (jj_3R_164()) {
+ jj_scanpos = xsp;
+ if (jj_3R_165()) {
+ jj_scanpos = xsp;
+ if (jj_3R_166()) {
+ jj_scanpos = xsp;
+ if (jj_3R_167()) {
+ jj_scanpos = xsp;
+ if (jj_3R_168()) {
+ jj_scanpos = xsp;
+ if (jj_3R_169()) {
+ jj_scanpos = xsp;
+ if (jj_3R_170()) {
+ jj_scanpos = xsp;
+ if (jj_3R_171()) {
+ jj_scanpos = xsp;
+ if (jj_3R_172()) {
+ jj_scanpos = xsp;
+ if (jj_3R_173()) {
+ jj_scanpos = xsp;
+ if (jj_3R_174()) {
+ jj_scanpos = xsp;
+ if (jj_3R_175()) {
+ jj_scanpos = xsp;
+ if (jj_3R_176()) {
+ jj_scanpos = xsp;
+ if (jj_3R_177())
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_279() {
+ if (jj_3R_182()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_291() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_278() {
+ Token xsp;
+ if (jj_3R_291()) return true;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_291()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_3R_147()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_37() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_39() {
+ Token xsp;
+ if (jj_3_37()) return true;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_37()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_38()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_259() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_39()) {
+ jj_scanpos = xsp;
+ if (jj_3R_278()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_262() {
+ if (jj_3R_109()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_279()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_232() {
+ if (jj_scan_token(COMMA)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_261() {
+ if (jj_3R_259()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_123() {
+ if (jj_scan_token(NEW)) return true;
+ if (jj_3R_149()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_260()) jj_scanpos = xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_261()) {
+ jj_scanpos = xsp;
+ if (jj_3R_262()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_87() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_36()) {
+ jj_scanpos = xsp;
+ if (jj_3R_123()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_36() {
+ if (jj_scan_token(NEW)) return true;
+ if (jj_3R_83()) return true;
+ if (jj_3R_259()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_148() {
+ if (jj_3R_195()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_195() {
+ if (jj_3R_56()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_232()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_109() {
+ if (jj_scan_token(LPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_148()) jj_scanpos = xsp;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_258() {
+ if (jj_scan_token(NULL)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_257() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(56)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(25)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_234() {
+ if (jj_3R_258()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_233() {
+ if (jj_3R_257()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_196() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(61)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(65)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(70)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(71)) {
+ jj_scanpos = xsp;
+ if (jj_3R_233()) {
+ jj_scanpos = xsp;
+ if (jj_3R_234()) return true;
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_152() {
+ if (jj_3R_196()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_121() {
+ if (jj_3R_109()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_120() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_33() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_119() {
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_32() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(SUPER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_35() {
+ if (jj_3R_88()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_34() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_3R_87()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_118() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_31() {
+ if (jj_3R_86()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(CLASS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_117() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(SUPER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_84() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_117()) {
+ jj_scanpos = xsp;
+ if (jj_3R_118()) {
+ jj_scanpos = xsp;
+ if (jj_3_34()) {
+ jj_scanpos = xsp;
+ if (jj_3_35()) {
+ jj_scanpos = xsp;
+ if (jj_3R_119()) {
+ jj_scanpos = xsp;
+ if (jj_3R_120()) {
+ jj_scanpos = xsp;
+ if (jj_3R_121()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_85() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_159() {
+ if (jj_3R_91()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_30() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_85()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_158() {
+ if (jj_3R_86()) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(CLASS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_157() {
+ if (jj_3R_87()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_156() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ return false;
+ }
+
+ final private boolean jj_3_29() {
+ if (jj_3R_84()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_155() {
+ if (jj_scan_token(SUPER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_197() {
+ if (jj_scan_token(IDENTIFIER)) return true;
+ if (jj_scan_token(DOT)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_154() {
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_197()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ if (jj_scan_token(THIS)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_124() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_153()) {
+ jj_scanpos = xsp;
+ if (jj_3R_154()) {
+ jj_scanpos = xsp;
+ if (jj_3R_155()) {
+ jj_scanpos = xsp;
+ if (jj_3R_156()) {
+ jj_scanpos = xsp;
+ if (jj_3R_157()) {
+ jj_scanpos = xsp;
+ if (jj_3R_158()) {
+ jj_scanpos = xsp;
+ if (jj_3R_159()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_153() {
+ if (jj_3R_196()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_88() {
+ if (jj_scan_token(DOT)) return true;
+ if (jj_3R_78()) return true;
+ if (jj_scan_token(IDENTIFIER)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_280() {
+ if (jj_3R_293()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_28() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_83()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_90() {
+ if (jj_3R_124()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_29()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_319() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_313()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_318() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_317() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_318()) {
+ jj_scanpos = xsp;
+ if (jj_3R_319()) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_293() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(97)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(98)) return true;
+ }
+ return false;
+ }
+
+ final private boolean jj_3_27() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(LBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_266() {
+ if (jj_3R_90()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_280()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_116() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(RPAREN)) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(88)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(87)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(75)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(72)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(52)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(49)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(39)) {
+ jj_scanpos = xsp;
+ if (jj_3R_152()) return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_115() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_72()) return true;
+ if (jj_scan_token(LBRACKET)) return true;
+ if (jj_scan_token(RBRACKET)) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_82() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3_26()) {
+ jj_scanpos = xsp;
+ if (jj_3R_115()) {
+ jj_scanpos = xsp;
+ if (jj_3R_116()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_26() {
+ if (jj_scan_token(LPAREN)) return true;
+ if (jj_3R_83()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_25() {
+ if (jj_3R_82()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_24() {
+ if (jj_3R_81()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_316() {
+ if (jj_3R_266()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_315() {
+ if (jj_3R_317()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_314() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(88)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(87)) return true;
+ }
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_313() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_314()) {
+ jj_scanpos = xsp;
+ if (jj_3R_315()) {
+ jj_scanpos = xsp;
+ if (jj_3R_316()) return true;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_264() {
+ if (jj_scan_token(DECR)) return true;
+ if (jj_3R_90()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_306() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(99)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(100)) return true;
+ }
+ if (jj_3R_305()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_308() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(101)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(102)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(106)) return true;
+ }
+ }
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_23() {
+ if (jj_3R_80()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_263() {
+ if (jj_scan_token(INCR)) return true;
+ if (jj_3R_90()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_312() {
+ if (jj_3R_313()) return true;
+ return false;
+ }
+
+ final private boolean jj_3_22() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(107)) {
+ jj_scanpos = xsp;
+ if (jj_3_23()) {
+ jj_scanpos = xsp;
+ if (jj_3_24()) return true;
+ }
+ }
+ if (jj_3R_304()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_311() {
+ if (jj_3R_264()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_310() {
+ if (jj_3R_263()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_309() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(99)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(100)) return true;
+ }
+ if (jj_3R_307()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_307() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_309()) {
+ jj_scanpos = xsp;
+ if (jj_3R_310()) {
+ jj_scanpos = xsp;
+ if (jj_3R_311()) {
+ jj_scanpos = xsp;
+ if (jj_3R_312()) return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_303() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(86)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(122)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(92)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(93)) return true;
+ }
+ }
+ }
+ if (jj_3R_302()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_301() {
+ if (jj_scan_token(INSTANCEOF)) return true;
+ if (jj_3R_72()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_305() {
+ if (jj_3R_307()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_308()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_298() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(91)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(94)) return true;
+ }
+ if (jj_3R_297()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_304() {
+ if (jj_3R_305()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_306()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_302() {
+ if (jj_3R_304()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3_22()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_288() {
+ if (jj_scan_token(BIT_AND)) return true;
+ if (jj_3R_287()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_300() {
+ if (jj_3R_302()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_303()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_254() {
+ if (jj_scan_token(BIT_OR)) return true;
+ if (jj_3R_253()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_297() {
+ if (jj_3R_300()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_301()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_274() {
+ if (jj_scan_token(XOR)) return true;
+ if (jj_3R_273()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_230() {
+ if (jj_scan_token(SC_AND)) return true;
+ if (jj_3R_229()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_287() {
+ if (jj_3R_297()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_298()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_190() {
+ if (jj_scan_token(SC_OR)) return true;
+ if (jj_3R_189()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_273() {
+ if (jj_3R_287()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_288()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_142() {
+ if (jj_scan_token(HOOK)) return true;
+ if (jj_3R_56()) return true;
+ if (jj_scan_token(COLON)) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_253() {
+ if (jj_3R_273()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_274()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_229() {
+ if (jj_3R_253()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_254()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_189() {
+ if (jj_3R_229()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_230()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_141() {
+ if (jj_3R_189()) return true;
+ Token xsp;
+ while (true) {
+ xsp = jj_scanpos;
+ if (jj_3R_190()) {
+ jj_scanpos = xsp;
+ break;
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3R_101() {
+ if (jj_3R_141()) return true;
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_3R_142()) jj_scanpos = xsp;
+ return false;
+ }
+
+ final private boolean jj_3R_265() {
+ if (jj_3R_90()) return true;
+ if (jj_3R_79()) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ final private boolean jj_3R_79() {
+ Token xsp;
+ xsp = jj_scanpos;
+ if (jj_scan_token(85)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(110)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(111)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(115)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(108)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(109)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(116)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(117)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(118)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(112)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(114)) {
+ jj_scanpos = xsp;
+ if (jj_scan_token(113))
+ return true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ return false;
+ }
+
+ final private boolean jj_3_21() {
+ if (jj_3R_79()) return true;
+ if (jj_3R_56()) return true;
+ return false;
+ }
+
+ public JavaParserTokenManager token_source;
+ JavaCharStream jj_input_stream;
+ public Token token, jj_nt;
+ private int jj_ntk;
+ private Token jj_scanpos, jj_lastpos;
+ private int jj_la;
+ public boolean lookingAhead = false;
+ private boolean jj_semLA;
+
+ public JavaParser(java.io.InputStream stream) {
+ this(stream, null);
+ }
+
+ public JavaParser(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream = new JavaCharStream(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source = new JavaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ }
+
+ public void ReInit(java.io.InputStream stream) {
+ ReInit(stream, null);
+ }
+
+ public void ReInit(java.io.InputStream stream, String encoding) {
+ try {
+ jj_input_stream.ReInit(stream, encoding, 1, 1);
+ } catch (java.io.UnsupportedEncodingException e) {
+ throw new RuntimeException(e);
+ }
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ }
+
+ public JavaParser(java.io.Reader stream) {
+ jj_input_stream = new JavaCharStream(stream, 1, 1);
+ token_source = new JavaParserTokenManager(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ }
+
+ public void ReInit(java.io.Reader stream) {
+ jj_input_stream.ReInit(stream, 1, 1);
+ token_source.ReInit(jj_input_stream);
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ }
+
+ public JavaParser(JavaParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ }
+
+ public void ReInit(JavaParserTokenManager tm) {
+ token_source = tm;
+ token = new Token();
+ jj_ntk = -1;
+ jjtree.reset();
+ }
+
+ final private Token jj_consume_token(int kind) throws ParseException {
+ Token oldToken;
+ if ((oldToken = token).next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ if (token.kind == kind) {
+ return token;
+ }
+ token = oldToken;
+ throw generateParseException();
+ }
+
+ static private final class LookaheadSuccess extends java.lang.Error {
+ }
+
+ final private LookaheadSuccess jj_ls = new LookaheadSuccess();
+
+ final private boolean jj_scan_token(int kind) {
+ if (jj_scanpos == jj_lastpos) {
+ jj_la--;
+ if (jj_scanpos.next == null) {
+ jj_lastpos = jj_scanpos = jj_scanpos.next = token_source.getNextToken();
+ } else {
+ jj_lastpos = jj_scanpos = jj_scanpos.next;
+ }
+ } else {
+ jj_scanpos = jj_scanpos.next;
+ }
+ if (jj_scanpos.kind != kind) return true;
+ if (jj_la == 0 && jj_scanpos == jj_lastpos) throw jj_ls;
+ return false;
+ }
+
+ final public Token getNextToken() {
+ if (token.next != null) token = token.next;
+ else token = token.next = token_source.getNextToken();
+ jj_ntk = -1;
+ return token;
+ }
+
+ final public Token getToken(int index) {
+ Token t = lookingAhead ? jj_scanpos : token;
+ for (int i = 0; i < index; i++) {
+ if (t.next != null) t = t.next;
+ else t = t.next = token_source.getNextToken();
+ }
+ return t;
+ }
+
+ final private int jj_ntk() {
+ if ((jj_nt = token.next) == null)
+ return (jj_ntk = (token.next = token_source.getNextToken()).kind);
+ else
+ return (jj_ntk = jj_nt.kind);
+ }
+
+ public ParseException generateParseException() {
+ Token errortok = token.next;
+ int line = errortok.beginLine, column = errortok.beginColumn;
+ String mess = (errortok.kind == 0) ? tokenImage[0] : errortok.image;
+ return new ParseException("Unable to parse Java code near token: " + mess, line, column);
+ }
+
+ final public void enable_tracing() {
+ }
+
+ final public void disable_tracing() {
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParser.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParserConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,260 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserConstants.java */
+package jaxx.compiler.parser.java;
+
+public interface JavaParserConstants {
+
+ int EOF = 0;
+ int WHITE_SPACE = 3;
+ int SINGLE_LINE_COMMENT = 4;
+ int FORMAL_COMMENT = 5;
+ int MULTI_LINE_COMMENT = 6;
+ int ABSTRACT = 8;
+ int ASSERT = 9;
+ int BOOLEAN = 10;
+ int BREAK = 11;
+ int BYTE = 12;
+ int CASE = 13;
+ int CATCH = 14;
+ int CHAR = 15;
+ int CLASS = 16;
+ int CONST = 17;
+ int CONTINUE = 18;
+ int _DEFAULT = 19;
+ int DO = 20;
+ int DOUBLE = 21;
+ int ELSE = 22;
+ int ENUM = 23;
+ int EXTENDS = 24;
+ int FALSE = 25;
+ int FINAL = 26;
+ int FINALLY = 27;
+ int FLOAT = 28;
+ int FOR = 29;
+ int GOTO = 30;
+ int IF = 31;
+ int IMPLEMENTS = 32;
+ int IMPORT = 33;
+ int INSTANCEOF = 34;
+ int INT = 35;
+ int INTERFACE = 36;
+ int LONG = 37;
+ int NATIVE = 38;
+ int NEW = 39;
+ int NULL = 40;
+ int PACKAGE = 41;
+ int PRIVATE = 42;
+ int PROTECTED = 43;
+ int PUBLIC = 44;
+ int RETURN = 45;
+ int SHORT = 46;
+ int STATIC = 47;
+ int STRICTFP = 48;
+ int SUPER = 49;
+ int SWITCH = 50;
+ int SYNCHRONIZED = 51;
+ int THIS = 52;
+ int THROW = 53;
+ int THROWS = 54;
+ int TRANSIENT = 55;
+ int TRUE = 56;
+ int TRY = 57;
+ int VOID = 58;
+ int VOLATILE = 59;
+ int WHILE = 60;
+ int INTEGER_LITERAL = 61;
+ int DECIMAL_LITERAL = 62;
+ int HEX_LITERAL = 63;
+ int OCTAL_LITERAL = 64;
+ int FLOATING_POINT_LITERAL = 65;
+ int DECIMAL_FLOATING_POINT_LITERAL = 66;
+ int DECIMAL_EXPONENT = 67;
+ int HEXADECIMAL_FLOATING_POINT_LITERAL = 68;
+ int HEXADECIMAL_EXPONENT = 69;
+ int CHARACTER_LITERAL = 70;
+ int STRING_LITERAL = 71;
+ int IDENTIFIER = 72;
+ int LETTER = 73;
+ int PART_LETTER = 74;
+ int LPAREN = 75;
+ int RPAREN = 76;
+ int LBRACE = 77;
+ int RBRACE = 78;
+ int LBRACKET = 79;
+ int RBRACKET = 80;
+ int SEMICOLON = 81;
+ int COMMA = 82;
+ int DOT = 83;
+ int AT = 84;
+ int ASSIGN = 85;
+ int LT = 86;
+ int BANG = 87;
+ int TILDE = 88;
+ int HOOK = 89;
+ int COLON = 90;
+ int EQ = 91;
+ int LE = 92;
+ int GE = 93;
+ int NE = 94;
+ int SC_OR = 95;
+ int SC_AND = 96;
+ int INCR = 97;
+ int DECR = 98;
+ int PLUS = 99;
+ int MINUS = 100;
+ int STAR = 101;
+ int SLASH = 102;
+ int BIT_AND = 103;
+ int BIT_OR = 104;
+ int XOR = 105;
+ int REM = 106;
+ int LSHIFT = 107;
+ int PLUSASSIGN = 108;
+ int MINUSASSIGN = 109;
+ int STARASSIGN = 110;
+ int SLASHASSIGN = 111;
+ int ANDASSIGN = 112;
+ int ORASSIGN = 113;
+ int XORASSIGN = 114;
+ int REMASSIGN = 115;
+ int LSHIFTASSIGN = 116;
+ int RSIGNEDSHIFTASSIGN = 117;
+ int RUNSIGNEDSHIFTASSIGN = 118;
+ int ELLIPSIS = 119;
+ int RUNSIGNEDSHIFT = 120;
+ int RSIGNEDSHIFT = 121;
+ int GT = 122;
+ int STUFF_TO_IGNORE = 124;
+
+ int DEFAULT = 0;
+ int IN_FORMAL_COMMENT = 1;
+ int IN_MULTI_LINE_COMMENT = 2;
+
+ String[] tokenImage = {
+ "<EOF>",
+ "<token of kind 1>",
+ "\"/*\"",
+ "<WHITE_SPACE>",
+ "<SINGLE_LINE_COMMENT>",
+ "\"*/\"",
+ "\"*/\"",
+ "<token of kind 7>",
+ "\"abstract\"",
+ "\"assert\"",
+ "\"boolean\"",
+ "\"break\"",
+ "\"byte\"",
+ "\"case\"",
+ "\"catch\"",
+ "\"char\"",
+ "\"class\"",
+ "\"const\"",
+ "\"continue\"",
+ "\"default\"",
+ "\"do\"",
+ "\"double\"",
+ "\"else\"",
+ "\"enum\"",
+ "\"extends\"",
+ "\"false\"",
+ "\"final\"",
+ "\"finally\"",
+ "\"float\"",
+ "\"for\"",
+ "\"goto\"",
+ "\"if\"",
+ "\"implements\"",
+ "\"import\"",
+ "\"instanceof\"",
+ "\"int\"",
+ "\"interface\"",
+ "\"long\"",
+ "\"native\"",
+ "\"new\"",
+ "\"null\"",
+ "\"package\"",
+ "\"private\"",
+ "\"protected\"",
+ "\"public\"",
+ "\"return\"",
+ "\"short\"",
+ "\"static\"",
+ "\"strictfp\"",
+ "\"super\"",
+ "\"switch\"",
+ "\"synchronized\"",
+ "\"this\"",
+ "\"throw\"",
+ "\"throws\"",
+ "\"transient\"",
+ "\"true\"",
+ "\"try\"",
+ "\"void\"",
+ "\"volatile\"",
+ "\"while\"",
+ "<INTEGER_LITERAL>",
+ "<DECIMAL_LITERAL>",
+ "<HEX_LITERAL>",
+ "<OCTAL_LITERAL>",
+ "<FLOATING_POINT_LITERAL>",
+ "<DECIMAL_FLOATING_POINT_LITERAL>",
+ "<DECIMAL_EXPONENT>",
+ "<HEXADECIMAL_FLOATING_POINT_LITERAL>",
+ "<HEXADECIMAL_EXPONENT>",
+ "<CHARACTER_LITERAL>",
+ "<STRING_LITERAL>",
+ "<IDENTIFIER>",
+ "<LETTER>",
+ "<PART_LETTER>",
+ "\"(\"",
+ "\")\"",
+ "\"{\"",
+ "\"}\"",
+ "\"[\"",
+ "\"]\"",
+ "\";\"",
+ "\",\"",
+ "\".\"",
+ "\"@\"",
+ "\"=\"",
+ "\"<\"",
+ "\"!\"",
+ "\"~\"",
+ "\"?\"",
+ "\":\"",
+ "\"==\"",
+ "\"<=\"",
+ "\">=\"",
+ "\"!=\"",
+ "\"||\"",
+ "\"&&\"",
+ "\"++\"",
+ "\"--\"",
+ "\"+\"",
+ "\"-\"",
+ "\"*\"",
+ "\"/\"",
+ "\"&\"",
+ "\"|\"",
+ "\"^\"",
+ "\"%\"",
+ "\"<<\"",
+ "\"+=\"",
+ "\"-=\"",
+ "\"*=\"",
+ "\"/=\"",
+ "\"&=\"",
+ "\"|=\"",
+ "\"^=\"",
+ "\"%=\"",
+ "\"<<=\"",
+ "\">>=\"",
+ "\">>>=\"",
+ "\"...\"",
+ "\">>>\"",
+ "\">>\"",
+ "\">\"",
+ "\"\\u001a\"",
+ "<STUFF_TO_IGNORE>",
+ };
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParserTokenManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,2072 @@
+/* Generated By:JJTree&JavaCC: Do not edit this line. JavaParserTokenManager.java */
+package jaxx.compiler.parser.java;
+
+public class JavaParserTokenManager implements JavaParserConstants {
+ public java.io.PrintStream debugStream = System.out;
+
+ public void setDebugStream(java.io.PrintStream ds) {
+ debugStream = ds;
+ }
+
+ private int jjStopStringLiteralDfa_0(int pos, long active0, long active1) {
+ switch (pos) {
+ case 0:
+ if ((active0 & 0x4L) != 0L || (active1 & 0x804000000000L) != 0L)
+ return 48;
+ if ((active1 & 0x80000000080000L) != 0L)
+ return 5;
+ if ((active0 & 0x1fffffffffffff00L) != 0L) {
+ jjmatchedKind = 72;
+ return 29;
+ }
+ return -1;
+ case 1:
+ if ((active0 & 0x4L) != 0L)
+ return 46;
+ if ((active0 & 0x1fffffff7fcfff00L) != 0L) {
+ if (jjmatchedPos != 1) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 1;
+ }
+ return 29;
+ }
+ if ((active0 & 0x80300000L) != 0L)
+ return 29;
+ return -1;
+ case 2:
+ if ((active0 & 0x1dffff675fefff00L) != 0L) {
+ if (jjmatchedPos != 2) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 2;
+ }
+ return 29;
+ }
+ if ((active0 & 0x200009820000000L) != 0L)
+ return 29;
+ return -1;
+ case 3:
+ if ((active0 & 0x18effe571f2f4f00L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 3;
+ return 29;
+ }
+ if ((active0 & 0x510012040c0b000L) != 0L)
+ return 29;
+ return -1;
+ case 4:
+ if ((active0 & 0x88dbe57012c0700L) != 0L) {
+ if (jjmatchedPos != 4) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 4;
+ }
+ return 29;
+ }
+ if ((active0 & 0x106240001e034800L) != 0L)
+ return 29;
+ return -1;
+ case 5:
+ if ((active0 & 0x8890e15090c0500L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 5;
+ return 29;
+ }
+ if ((active0 & 0x44b04200200200L) != 0L)
+ return 29;
+ return -1;
+ case 6:
+ if ((active0 & 0x889081500040100L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 6;
+ return 29;
+ }
+ if ((active0 & 0x60009080400L) != 0L)
+ return 29;
+ return -1;
+ case 7:
+ if ((active0 & 0x801000000040100L) != 0L)
+ return 29;
+ if ((active0 & 0x88081500000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 7;
+ return 29;
+ }
+ return -1;
+ case 8:
+ if ((active0 & 0x8000500000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 8;
+ return 29;
+ }
+ if ((active0 & 0x80081000000000L) != 0L)
+ return 29;
+ return -1;
+ case 9:
+ if ((active0 & 0x8000000000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 9;
+ return 29;
+ }
+ if ((active0 & 0x500000000L) != 0L)
+ return 29;
+ return -1;
+ case 10:
+ if ((active0 & 0x8000000000000L) != 0L) {
+ jjmatchedKind = 72;
+ jjmatchedPos = 10;
+ return 29;
+ }
+ return -1;
+ default:
+ return -1;
+ }
+ }
+
+ private int jjStartNfa_0(int pos, long active0, long active1) {
+ return jjMoveNfa_0(jjStopStringLiteralDfa_0(pos, active0, active1), pos + 1);
+ }
+
+ private int jjStopAtPos(int pos, int kind) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ return pos + 1;
+ }
+
+ private int jjStartNfaWithStates_0(int pos, int kind, int state) {
+ jjmatchedKind = kind;
+ jjmatchedPos = pos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return pos + 1;
+ }
+ return jjMoveNfa_0(state, pos + 1);
+ }
+
+ private int jjMoveStringLiteralDfa0_0() {
+ switch (curChar) {
+ case 26:
+ return jjStopAtPos(0, 123);
+ case 33:
+ jjmatchedKind = 87;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x40000000L);
+ case 37:
+ jjmatchedKind = 106;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000000000L);
+ case 38:
+ jjmatchedKind = 103;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x1000100000000L);
+ case 40:
+ return jjStopAtPos(0, 75);
+ case 41:
+ return jjStopAtPos(0, 76);
+ case 42:
+ jjmatchedKind = 101;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x400000000000L);
+ case 43:
+ jjmatchedKind = 99;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x100200000000L);
+ case 44:
+ return jjStopAtPos(0, 82);
+ case 45:
+ jjmatchedKind = 100;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x200400000000L);
+ case 46:
+ jjmatchedKind = 83;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x80000000000000L);
+ case 47:
+ jjmatchedKind = 102;
+ return jjMoveStringLiteralDfa1_0(0x4L, 0x800000000000L);
+ case 58:
+ return jjStopAtPos(0, 90);
+ case 59:
+ return jjStopAtPos(0, 81);
+ case 60:
+ jjmatchedKind = 86;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x10080010000000L);
+ case 61:
+ jjmatchedKind = 85;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x8000000L);
+ case 62:
+ jjmatchedKind = 122;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x360000020000000L);
+ case 63:
+ return jjStopAtPos(0, 89);
+ case 64:
+ return jjStopAtPos(0, 84);
+ case 91:
+ return jjStopAtPos(0, 79);
+ case 93:
+ return jjStopAtPos(0, 80);
+ case 94:
+ jjmatchedKind = 105;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x4000000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa1_0(0x300L, 0x0L);
+ case 98:
+ return jjMoveStringLiteralDfa1_0(0x1c00L, 0x0L);
+ case 99:
+ return jjMoveStringLiteralDfa1_0(0x7e000L, 0x0L);
+ case 100:
+ return jjMoveStringLiteralDfa1_0(0x380000L, 0x0L);
+ case 101:
+ return jjMoveStringLiteralDfa1_0(0x1c00000L, 0x0L);
+ case 102:
+ return jjMoveStringLiteralDfa1_0(0x3e000000L, 0x0L);
+ case 103:
+ return jjMoveStringLiteralDfa1_0(0x40000000L, 0x0L);
+ case 105:
+ return jjMoveStringLiteralDfa1_0(0x1f80000000L, 0x0L);
+ case 108:
+ return jjMoveStringLiteralDfa1_0(0x2000000000L, 0x0L);
+ case 110:
+ return jjMoveStringLiteralDfa1_0(0x1c000000000L, 0x0L);
+ case 112:
+ return jjMoveStringLiteralDfa1_0(0x1e0000000000L, 0x0L);
+ case 114:
+ return jjMoveStringLiteralDfa1_0(0x200000000000L, 0x0L);
+ case 115:
+ return jjMoveStringLiteralDfa1_0(0xfc00000000000L, 0x0L);
+ case 116:
+ return jjMoveStringLiteralDfa1_0(0x3f0000000000000L, 0x0L);
+ case 118:
+ return jjMoveStringLiteralDfa1_0(0xc00000000000000L, 0x0L);
+ case 119:
+ return jjMoveStringLiteralDfa1_0(0x1000000000000000L, 0x0L);
+ case 123:
+ return jjStopAtPos(0, 77);
+ case 124:
+ jjmatchedKind = 104;
+ return jjMoveStringLiteralDfa1_0(0x0L, 0x2000080000000L);
+ case 125:
+ return jjStopAtPos(0, 78);
+ case 126:
+ return jjStopAtPos(0, 88);
+ default:
+ return jjMoveNfa_0(1, 0);
+ }
+ }
+
+ private int jjMoveStringLiteralDfa1_0(long active0, long active1) {
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(0, active0, active1);
+ return 1;
+ }
+ switch (curChar) {
+ case 38:
+ if ((active1 & 0x100000000L) != 0L)
+ return jjStopAtPos(1, 96);
+ break;
+ case 42:
+ if ((active0 & 0x4L) != 0L)
+ return jjStartNfaWithStates_0(1, 2, 46);
+ break;
+ case 43:
+ if ((active1 & 0x200000000L) != 0L)
+ return jjStopAtPos(1, 97);
+ break;
+ case 45:
+ if ((active1 & 0x400000000L) != 0L)
+ return jjStopAtPos(1, 98);
+ break;
+ case 46:
+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x80000000000000L);
+ case 60:
+ if ((active1 & 0x80000000000L) != 0L) {
+ jjmatchedKind = 107;
+ jjmatchedPos = 1;
+ }
+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x10000000000000L);
+ case 61:
+ if ((active1 & 0x8000000L) != 0L)
+ return jjStopAtPos(1, 91);
+ else if ((active1 & 0x10000000L) != 0L)
+ return jjStopAtPos(1, 92);
+ else if ((active1 & 0x20000000L) != 0L)
+ return jjStopAtPos(1, 93);
+ else if ((active1 & 0x40000000L) != 0L)
+ return jjStopAtPos(1, 94);
+ else if ((active1 & 0x100000000000L) != 0L)
+ return jjStopAtPos(1, 108);
+ else if ((active1 & 0x200000000000L) != 0L)
+ return jjStopAtPos(1, 109);
+ else if ((active1 & 0x400000000000L) != 0L)
+ return jjStopAtPos(1, 110);
+ else if ((active1 & 0x800000000000L) != 0L)
+ return jjStopAtPos(1, 111);
+ else if ((active1 & 0x1000000000000L) != 0L)
+ return jjStopAtPos(1, 112);
+ else if ((active1 & 0x2000000000000L) != 0L)
+ return jjStopAtPos(1, 113);
+ else if ((active1 & 0x4000000000000L) != 0L)
+ return jjStopAtPos(1, 114);
+ else if ((active1 & 0x8000000000000L) != 0L)
+ return jjStopAtPos(1, 115);
+ break;
+ case 62:
+ if ((active1 & 0x200000000000000L) != 0L) {
+ jjmatchedKind = 121;
+ jjmatchedPos = 1;
+ }
+ return jjMoveStringLiteralDfa2_0(active0, 0L, active1, 0x160000000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa2_0(active0, 0x24002006000L, active1, 0L);
+ case 98:
+ return jjMoveStringLiteralDfa2_0(active0, 0x100L, active1, 0L);
+ case 101:
+ return jjMoveStringLiteralDfa2_0(active0, 0x208000080000L, active1, 0L);
+ case 102:
+ if ((active0 & 0x80000000L) != 0L)
+ return jjStartNfaWithStates_0(1, 31, 29);
+ break;
+ case 104:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1070400000008000L, active1, 0L);
+ case 105:
+ return jjMoveStringLiteralDfa2_0(active0, 0xc000000L, active1, 0L);
+ case 108:
+ return jjMoveStringLiteralDfa2_0(active0, 0x10410000L, active1, 0L);
+ case 109:
+ return jjMoveStringLiteralDfa2_0(active0, 0x300000000L, active1, 0L);
+ case 110:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1c00800000L, active1, 0L);
+ case 111:
+ if ((active0 & 0x100000L) != 0L) {
+ jjmatchedKind = 20;
+ jjmatchedPos = 1;
+ }
+ return jjMoveStringLiteralDfa2_0(active0, 0xc00002060260400L, active1, 0L);
+ case 114:
+ return jjMoveStringLiteralDfa2_0(active0, 0x3800c0000000800L, active1, 0L);
+ case 115:
+ return jjMoveStringLiteralDfa2_0(active0, 0x200L, active1, 0L);
+ case 116:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1800000000000L, active1, 0L);
+ case 117:
+ return jjMoveStringLiteralDfa2_0(active0, 0x2110000000000L, active1, 0L);
+ case 119:
+ return jjMoveStringLiteralDfa2_0(active0, 0x4000000000000L, active1, 0L);
+ case 120:
+ return jjMoveStringLiteralDfa2_0(active0, 0x1000000L, active1, 0L);
+ case 121:
+ return jjMoveStringLiteralDfa2_0(active0, 0x8000000001000L, active1, 0L);
+ case 124:
+ if ((active1 & 0x80000000L) != 0L)
+ return jjStopAtPos(1, 95);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(0, active0, active1);
+ }
+
+ private int jjMoveStringLiteralDfa2_0(long old0, long active0, long old1, long active1) {
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(0, old0, old1);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(1, active0, active1);
+ return 2;
+ }
+ switch (curChar) {
+ case 46:
+ if ((active1 & 0x80000000000000L) != 0L)
+ return jjStopAtPos(2, 119);
+ break;
+ case 61:
+ if ((active1 & 0x10000000000000L) != 0L)
+ return jjStopAtPos(2, 116);
+ else if ((active1 & 0x20000000000000L) != 0L)
+ return jjStopAtPos(2, 117);
+ break;
+ case 62:
+ if ((active1 & 0x100000000000000L) != 0L) {
+ jjmatchedKind = 120;
+ jjmatchedPos = 2;
+ }
+ return jjMoveStringLiteralDfa3_0(active0, 0L, active1, 0x40000000000000L);
+ case 97:
+ return jjMoveStringLiteralDfa3_0(active0, 0x80800000018000L, active1, 0L);
+ case 98:
+ return jjMoveStringLiteralDfa3_0(active0, 0x100000000000L, active1, 0L);
+ case 99:
+ return jjMoveStringLiteralDfa3_0(active0, 0x20000000000L, active1, 0L);
+ case 101:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800L, active1, 0L);
+ case 102:
+ return jjMoveStringLiteralDfa3_0(active0, 0x80000L, active1, 0L);
+ case 105:
+ return jjMoveStringLiteralDfa3_0(active0, 0x1414040000000000L, active1, 0L);
+ case 108:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800010002000000L, active1, 0L);
+ case 110:
+ return jjMoveStringLiteralDfa3_0(active0, 0x800200c060000L, active1, 0L);
+ case 111:
+ return jjMoveStringLiteralDfa3_0(active0, 0x480010000400L, active1, 0L);
+ case 112:
+ return jjMoveStringLiteralDfa3_0(active0, 0x2000300000000L, active1, 0L);
+ case 114:
+ if ((active0 & 0x20000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 29, 29);
+ return jjMoveStringLiteralDfa3_0(active0, 0x61000000000000L, active1, 0L);
+ case 115:
+ return jjMoveStringLiteralDfa3_0(active0, 0x400402300L, active1, 0L);
+ case 116:
+ if ((active0 & 0x800000000L) != 0L) {
+ jjmatchedKind = 35;
+ jjmatchedPos = 2;
+ }
+ return jjMoveStringLiteralDfa3_0(active0, 0x205041005000L, active1, 0L);
+ case 117:
+ return jjMoveStringLiteralDfa3_0(active0, 0x100000000a00000L, active1, 0L);
+ case 119:
+ if ((active0 & 0x8000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 39, 29);
+ break;
+ case 121:
+ if ((active0 & 0x200000000000000L) != 0L)
+ return jjStartNfaWithStates_0(2, 57, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(1, active0, active1);
+ }
+
+ private int jjMoveStringLiteralDfa3_0(long old0, long active0, long old1, long active1) {
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(1, old0, old1);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(2, active0, active1);
+ return 3;
+ }
+ switch (curChar) {
+ case 61:
+ if ((active1 & 0x40000000000000L) != 0L)
+ return jjStopAtPos(3, 118);
+ break;
+ case 97:
+ return jjMoveStringLiteralDfa4_0(active0, 0x80000001c080800L, active1, 0L);
+ case 98:
+ return jjMoveStringLiteralDfa4_0(active0, 0x200000L, active1, 0L);
+ case 99:
+ return jjMoveStringLiteralDfa4_0(active0, 0x8000000004000L, active1, 0L);
+ case 100:
+ if ((active0 & 0x400000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 58, 29);
+ break;
+ case 101:
+ if ((active0 & 0x1000L) != 0L)
+ return jjStartNfaWithStates_0(3, 12, 29);
+ else if ((active0 & 0x2000L) != 0L)
+ return jjStartNfaWithStates_0(3, 13, 29);
+ else if ((active0 & 0x400000L) != 0L)
+ return jjStartNfaWithStates_0(3, 22, 29);
+ else if ((active0 & 0x100000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 56, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x2001001000200L, active1, 0L);
+ case 103:
+ if ((active0 & 0x2000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 37, 29);
+ break;
+ case 105:
+ return jjMoveStringLiteralDfa4_0(active0, 0x1004000000000L, active1, 0L);
+ case 107:
+ return jjMoveStringLiteralDfa4_0(active0, 0x20000000000L, active1, 0L);
+ case 108:
+ if ((active0 & 0x10000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 40, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x1000100100000400L, active1, 0L);
+ case 109:
+ if ((active0 & 0x800000L) != 0L)
+ return jjStartNfaWithStates_0(3, 23, 29);
+ break;
+ case 110:
+ return jjMoveStringLiteralDfa4_0(active0, 0x80000000000000L, active1, 0L);
+ case 111:
+ if ((active0 & 0x40000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 30, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x60000200000000L, active1, 0L);
+ case 114:
+ if ((active0 & 0x8000L) != 0L)
+ return jjStartNfaWithStates_0(3, 15, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x400000000000L, active1, 0L);
+ case 115:
+ if ((active0 & 0x10000000000000L) != 0L)
+ return jjStartNfaWithStates_0(3, 52, 29);
+ return jjMoveStringLiteralDfa4_0(active0, 0x2030000L, active1, 0L);
+ case 116:
+ return jjMoveStringLiteralDfa4_0(active0, 0x4880400040100L, active1, 0L);
+ case 117:
+ return jjMoveStringLiteralDfa4_0(active0, 0x200000000000L, active1, 0L);
+ case 118:
+ return jjMoveStringLiteralDfa4_0(active0, 0x40000000000L, active1, 0L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(2, active0, active1);
+ }
+
+ private int jjMoveStringLiteralDfa4_0(long old0, long active0, long old1, long active1) {
+ if (((active0 &= old0) | (active1 &= old1)) == 0L)
+ return jjStartNfa_0(2, old0, old1);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(3, active0, 0L);
+ return 4;
+ }
+ switch (curChar) {
+ case 97:
+ return jjMoveStringLiteralDfa5_0(active0, 0x60400000000L);
+ case 99:
+ return jjMoveStringLiteralDfa5_0(active0, 0x5000000000000L);
+ case 101:
+ if ((active0 & 0x2000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 25, 29);
+ else if ((active0 & 0x1000000000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 60, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x80100000400L);
+ case 104:
+ if ((active0 & 0x4000L) != 0L)
+ return jjStartNfaWithStates_0(4, 14, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x8000000000000L);
+ case 105:
+ return jjMoveStringLiteralDfa5_0(active0, 0x900000040000L);
+ case 107:
+ if ((active0 & 0x800L) != 0L)
+ return jjStartNfaWithStates_0(4, 11, 29);
+ break;
+ case 108:
+ if ((active0 & 0x4000000L) != 0L) {
+ jjmatchedKind = 26;
+ jjmatchedPos = 4;
+ }
+ return jjMoveStringLiteralDfa5_0(active0, 0x8200000L);
+ case 110:
+ return jjMoveStringLiteralDfa5_0(active0, 0x1000000L);
+ case 114:
+ if ((active0 & 0x2000000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 49, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x201200000300L);
+ case 115:
+ if ((active0 & 0x10000L) != 0L)
+ return jjStartNfaWithStates_0(4, 16, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x80000000000000L);
+ case 116:
+ if ((active0 & 0x20000L) != 0L)
+ return jjStartNfaWithStates_0(4, 17, 29);
+ else if ((active0 & 0x10000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 28, 29);
+ else if ((active0 & 0x400000000000L) != 0L)
+ return jjStartNfaWithStates_0(4, 46, 29);
+ return jjMoveStringLiteralDfa5_0(active0, 0x800000000000000L);
+ case 117:
+ return jjMoveStringLiteralDfa5_0(active0, 0x80000L);
+ case 118:
+ return jjMoveStringLiteralDfa5_0(active0, 0x4000000000L);
+ case 119:
+ if ((active0 & 0x20000000000000L) != 0L) {
+ jjmatchedKind = 53;
+ jjmatchedPos = 4;
+ }
+ return jjMoveStringLiteralDfa5_0(active0, 0x40000000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(3, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa5_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(3, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(4, active0, 0L);
+ return 5;
+ }
+ switch (curChar) {
+ case 97:
+ return jjMoveStringLiteralDfa6_0(active0, 0x500L);
+ case 99:
+ if ((active0 & 0x100000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 44, 29);
+ else if ((active0 & 0x800000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 47, 29);
+ return jjMoveStringLiteralDfa6_0(active0, 0x80000000000L);
+ case 100:
+ return jjMoveStringLiteralDfa6_0(active0, 0x1000000L);
+ case 101:
+ if ((active0 & 0x200000L) != 0L)
+ return jjStartNfaWithStates_0(5, 21, 29);
+ else if ((active0 & 0x4000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 38, 29);
+ break;
+ case 102:
+ return jjMoveStringLiteralDfa6_0(active0, 0x1000000000L);
+ case 103:
+ return jjMoveStringLiteralDfa6_0(active0, 0x20000000000L);
+ case 104:
+ if ((active0 & 0x4000000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 50, 29);
+ break;
+ case 105:
+ return jjMoveStringLiteralDfa6_0(active0, 0x880000000000000L);
+ case 108:
+ return jjMoveStringLiteralDfa6_0(active0, 0x8080000L);
+ case 109:
+ return jjMoveStringLiteralDfa6_0(active0, 0x100000000L);
+ case 110:
+ if ((active0 & 0x200000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 45, 29);
+ return jjMoveStringLiteralDfa6_0(active0, 0x400040000L);
+ case 114:
+ return jjMoveStringLiteralDfa6_0(active0, 0x8000000000000L);
+ case 115:
+ if ((active0 & 0x40000000000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 54, 29);
+ break;
+ case 116:
+ if ((active0 & 0x200L) != 0L)
+ return jjStartNfaWithStates_0(5, 9, 29);
+ else if ((active0 & 0x200000000L) != 0L)
+ return jjStartNfaWithStates_0(5, 33, 29);
+ return jjMoveStringLiteralDfa6_0(active0, 0x1040000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(4, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa6_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(4, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(5, active0, 0L);
+ return 6;
+ }
+ switch (curChar) {
+ case 97:
+ return jjMoveStringLiteralDfa7_0(active0, 0x1000000000L);
+ case 99:
+ return jjMoveStringLiteralDfa7_0(active0, 0x400000100L);
+ case 101:
+ if ((active0 & 0x20000000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 41, 29);
+ else if ((active0 & 0x40000000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 42, 29);
+ return jjMoveStringLiteralDfa7_0(active0, 0x80000100000000L);
+ case 102:
+ return jjMoveStringLiteralDfa7_0(active0, 0x1000000000000L);
+ case 108:
+ return jjMoveStringLiteralDfa7_0(active0, 0x800000000000000L);
+ case 110:
+ if ((active0 & 0x400L) != 0L)
+ return jjStartNfaWithStates_0(6, 10, 29);
+ break;
+ case 111:
+ return jjMoveStringLiteralDfa7_0(active0, 0x8000000000000L);
+ case 115:
+ if ((active0 & 0x1000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 24, 29);
+ break;
+ case 116:
+ if ((active0 & 0x80000L) != 0L)
+ return jjStartNfaWithStates_0(6, 19, 29);
+ return jjMoveStringLiteralDfa7_0(active0, 0x80000000000L);
+ case 117:
+ return jjMoveStringLiteralDfa7_0(active0, 0x40000L);
+ case 121:
+ if ((active0 & 0x8000000L) != 0L)
+ return jjStartNfaWithStates_0(6, 27, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(5, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa7_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(5, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(6, active0, 0L);
+ return 7;
+ }
+ switch (curChar) {
+ case 99:
+ return jjMoveStringLiteralDfa8_0(active0, 0x1000000000L);
+ case 101:
+ if ((active0 & 0x40000L) != 0L)
+ return jjStartNfaWithStates_0(7, 18, 29);
+ else if ((active0 & 0x800000000000000L) != 0L)
+ return jjStartNfaWithStates_0(7, 59, 29);
+ return jjMoveStringLiteralDfa8_0(active0, 0x80400000000L);
+ case 110:
+ return jjMoveStringLiteralDfa8_0(active0, 0x88000100000000L);
+ case 112:
+ if ((active0 & 0x1000000000000L) != 0L)
+ return jjStartNfaWithStates_0(7, 48, 29);
+ break;
+ case 116:
+ if ((active0 & 0x100L) != 0L)
+ return jjStartNfaWithStates_0(7, 8, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(6, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa8_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(6, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(7, active0, 0L);
+ return 8;
+ }
+ switch (curChar) {
+ case 100:
+ if ((active0 & 0x80000000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 43, 29);
+ break;
+ case 101:
+ if ((active0 & 0x1000000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 36, 29);
+ break;
+ case 105:
+ return jjMoveStringLiteralDfa9_0(active0, 0x8000000000000L);
+ case 111:
+ return jjMoveStringLiteralDfa9_0(active0, 0x400000000L);
+ case 116:
+ if ((active0 & 0x80000000000000L) != 0L)
+ return jjStartNfaWithStates_0(8, 55, 29);
+ return jjMoveStringLiteralDfa9_0(active0, 0x100000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(7, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa9_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(7, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(8, active0, 0L);
+ return 9;
+ }
+ switch (curChar) {
+ case 102:
+ if ((active0 & 0x400000000L) != 0L)
+ return jjStartNfaWithStates_0(9, 34, 29);
+ break;
+ case 115:
+ if ((active0 & 0x100000000L) != 0L)
+ return jjStartNfaWithStates_0(9, 32, 29);
+ break;
+ case 122:
+ return jjMoveStringLiteralDfa10_0(active0, 0x8000000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(8, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa10_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(8, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(9, active0, 0L);
+ return 10;
+ }
+ switch (curChar) {
+ case 101:
+ return jjMoveStringLiteralDfa11_0(active0, 0x8000000000000L);
+ default:
+ break;
+ }
+ return jjStartNfa_0(9, active0, 0L);
+ }
+
+ private int jjMoveStringLiteralDfa11_0(long old0, long active0) {
+ if (((active0 &= old0)) == 0L)
+ return jjStartNfa_0(9, old0, 0L);
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ jjStopStringLiteralDfa_0(10, active0, 0L);
+ return 11;
+ }
+ switch (curChar) {
+ case 100:
+ if ((active0 & 0x8000000000000L) != 0L)
+ return jjStartNfaWithStates_0(11, 51, 29);
+ break;
+ default:
+ break;
+ }
+ return jjStartNfa_0(10, active0, 0L);
+ }
+
+ private void jjCheckNAdd(int state) {
+ if (jjrounds[state] != jjround) {
+ jjstateSet[jjnewStateCnt++] = state;
+ jjrounds[state] = jjround;
+ }
+ }
+
+ private void jjAddStates(int start, int end) {
+ do {
+ jjstateSet[jjnewStateCnt++] = jjnextStates[start];
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddTwoStates(int state1, int state2) {
+ jjCheckNAdd(state1);
+ jjCheckNAdd(state2);
+ }
+
+ private void jjCheckNAddStates(int start, int end) {
+ do {
+ jjCheckNAdd(jjnextStates[start]);
+ } while (start++ != end);
+ }
+
+ private void jjCheckNAddStates(int start) {
+ jjCheckNAdd(jjnextStates[start]);
+ jjCheckNAdd(jjnextStates[start + 1]);
+ }
+
+ static final long[] jjbitVec0 = {
+ 0xfffffffffffffffeL, 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffffffffffffL
+ };
+ static final long[] jjbitVec2 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0xffffffffffffffffL
+ };
+ static final long[] jjbitVec3 = {
+ 0xfff0000000200002L, 0xffffffffffffdfffL, 0xfffff00f7fffffffL, 0x12000000007fffffL
+ };
+ static final long[] jjbitVec4 = {
+ 0x0L, 0x0L, 0x420043c00000000L, 0xff7fffffff7fffffL
+ };
+ static final long[] jjbitVec5 = {
+ 0xffffcffffffffL, 0xffffffffffff0000L, 0xf9ff3fffffffffffL, 0x401f00030003L
+ };
+ static final long[] jjbitVec6 = {
+ 0x0L, 0x400000000000000L, 0xfffffffbffffd740L, 0xffffffcff7fffL
+ };
+ static final long[] jjbitVec7 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff003L, 0x33fffffffff199fL
+ };
+ static final long[] jjbitVec8 = {
+ 0xfffe000000000000L, 0xfffffffe027fffffL, 0xffL, 0x707ffffff0000L
+ };
+ static final long[] jjbitVec9 = {
+ 0x7fffffe00000000L, 0xfffe0000000007ffL, 0xffffffffffffffffL, 0x1c000060002fffffL
+ };
+ static final long[] jjbitVec10 = {
+ 0x1ffffffd0000L, 0x0L, 0x3fffffffffL, 0x0L
+ };
+ static final long[] jjbitVec11 = {
+ 0x23ffffffffffffe0L, 0x3ff010000L, 0x3c5fdfffff99fe0L, 0xf0003b0000000L
+ };
+ static final long[] jjbitVec12 = {
+ 0x36dfdfffff987e0L, 0x1c00005e000000L, 0x23edfdfffffbafe0L, 0x100010000L
+ };
+ static final long[] jjbitVec13 = {
+ 0x23cdfdfffff99fe0L, 0x3b0000000L, 0x3bfc718d63dc7e0L, 0x0L
+ };
+ static final long[] jjbitVec14 = {
+ 0x3effdfffffddfe0L, 0x300000000L, 0x3effdfffffddfe0L, 0x340000000L
+ };
+ static final long[] jjbitVec15 = {
+ 0x3fffdfffffddfe0L, 0x300000000L, 0x2ffbfffffc7fffe0L, 0x7fL
+ };
+ static final long[] jjbitVec16 = {
+ 0x800dfffffffffffeL, 0x7fL, 0x200decaefef02596L, 0x3000005fL
+ };
+ static final long[] jjbitVec17 = {
+ 0x1L, 0x7fffffffeffL, 0xf00L, 0x0L
+ };
+ static final long[] jjbitVec18 = {
+ 0x6fbffffffffL, 0x3f0000L, 0xffffffff00000000L, 0x7fffffffff003fL
+ };
+ static final long[] jjbitVec19 = {
+ 0xffffffffffffffffL, 0xffffffff83ffffffL, 0xffffff07ffffffffL, 0x3ffffffffffffffL
+ };
+ static final long[] jjbitVec20 = {
+ 0xffffffffffffff7fL, 0xffffffff3d7f3d7fL, 0x7f3d7fffffff3d7fL, 0xffff7fffff7f7f3dL
+ };
+ static final long[] jjbitVec21 = {
+ 0xffffffff7f3d7fffL, 0x7ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL
+ };
+ static final long[] jjbitVec22 = {
+ 0xffffffffffffffffL, 0x7f9fffffffffffL, 0xffffffff07fffffeL, 0x7ffffffffffL
+ };
+ static final long[] jjbitVec23 = {
+ 0x0L, 0x0L, 0xfffffffffffffL, 0x8000000L
+ };
+ static final long[] jjbitVec24 = {
+ 0xffffffff00000000L, 0xffffffffffffffL, 0x1ffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec25 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xffffffff0fffffffL, 0x3ffffffffffffffL
+ };
+ static final long[] jjbitVec26 = {
+ 0xffffffff3f3fffffL, 0x3fffffffaaff3f3fL, 0x5fdfffffffffffffL, 0x1fdc1fff0fcf1fdcL
+ };
+ static final long[] jjbitVec27 = {
+ 0x8000000000000000L, 0x8000000000000001L, 0xffff00000000L, 0x0L
+ };
+ static final long[] jjbitVec28 = {
+ 0x3fbbd503e2ffc84L, 0xffffffff00000000L, 0xfL, 0x0L
+ };
+ static final long[] jjbitVec29 = {
+ 0x73e03fe000000e0L, 0xfffffffffffffffeL, 0xfffffffe601fffffL, 0x7fffffffffffffffL
+ };
+ static final long[] jjbitVec30 = {
+ 0xfffe1fffffffffe0L, 0xffffffffffffffffL, 0xffffff00007fffL, 0x0L
+ };
+ static final long[] jjbitVec31 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec32 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x3fffffffffL, 0x0L
+ };
+ static final long[] jjbitVec33 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0x1fffL, 0x0L
+ };
+ static final long[] jjbitVec34 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffL, 0x0L
+ };
+ static final long[] jjbitVec35 = {
+ 0x3fffffffffffL, 0x0L, 0x0L, 0x0L
+ };
+ static final long[] jjbitVec36 = {
+ 0x5f7ffdffa0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L
+ };
+ static final long[] jjbitVec37 = {
+ 0x3fffffffffffffffL, 0xffffffffffff0000L, 0xfffffffffffcffffL, 0xfff0000000000ffL
+ };
+ static final long[] jjbitVec38 = {
+ 0x18000000000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x1fffffffffffffffL
+ };
+ static final long[] jjbitVec39 = {
+ 0x87fffffe00000010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0x631cfcfcfcL
+ };
+ static final long[] jjbitVec40 = {
+ 0x0L, 0x0L, 0x420043cffffffffL, 0xff7fffffff7fffffL
+ };
+ static final long[] jjbitVec41 = {
+ 0xffffffffffffffffL, 0x400000700007fffL, 0xfffffffbffffd740L, 0xffffffcff7fffL
+ };
+ static final long[] jjbitVec42 = {
+ 0xffffffffffffffffL, 0xffffffffffffffffL, 0xfffffffffffff07bL, 0x33fffffffff199fL
+ };
+ static final long[] jjbitVec43 = {
+ 0xfffe000000000000L, 0xfffffffe027fffffL, 0xbbfffffbfffe00ffL, 0x707ffffff0016L
+ };
+ static final long[] jjbitVec44 = {
+ 0x7fffffe00000000L, 0xffff03ff003fffffL, 0xffffffffffffffffL, 0x1fff3dff9fefffffL
+ };
+ static final long[] jjbitVec45 = {
+ 0xffff1fffffff8000L, 0x7ffL, 0x1ffffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec46 = {
+ 0xf3ffffffffffffeeL, 0xffcfff1f3fffL, 0xd3c5fdfffff99feeL, 0xfffcfb080399fL
+ };
+ static final long[] jjbitVec47 = {
+ 0xd36dfdfffff987e4L, 0x1fffc05e003987L, 0xf3edfdfffffbafeeL, 0xffc100013bbfL
+ };
+ static final long[] jjbitVec48 = {
+ 0xf3cdfdfffff99feeL, 0xffc3b0c0398fL, 0xc3bfc718d63dc7ecL, 0xff8000803dc7L
+ };
+ static final long[] jjbitVec49 = {
+ 0xc3effdfffffddfeeL, 0xffc300603ddfL, 0xc3effdfffffddfecL, 0xffc340603ddfL
+ };
+ static final long[] jjbitVec50 = {
+ 0xc3fffdfffffddfecL, 0xffc300803dcfL, 0x2ffbfffffc7fffecL, 0xc0000ff5f847fL
+ };
+ static final long[] jjbitVec51 = {
+ 0x87fffffffffffffeL, 0x3ff7fffL, 0x3bffecaefef02596L, 0x33ff3f5fL
+ };
+ static final long[] jjbitVec52 = {
+ 0xc2a003ff03000001L, 0xfffe07fffffffeffL, 0x1ffffffffeff0fdfL, 0x40L
+ };
+ static final long[] jjbitVec53 = {
+ 0x3c7f6fbffffffffL, 0x3ff03ffL, 0xffffffff00000000L, 0x7fffffffff003fL
+ };
+ static final long[] jjbitVec54 = {
+ 0xffffffff7f3d7fffL, 0x3fe0007ffff7fL, 0xffffffff00000000L, 0x1fffffffffffffL
+ };
+ static final long[] jjbitVec55 = {
+ 0x0L, 0x0L, 0xffffffffffffffffL, 0x3ff080fffffL
+ };
+ static final long[] jjbitVec56 = {
+ 0xffffffff03ff7800L, 0xffffffffffffffL, 0x3ffffffffffL, 0x0L
+ };
+ static final long[] jjbitVec57 = {
+ 0x80007c000000f000L, 0x8000fc0000000001L, 0xffff00000000L, 0x21fff0000L
+ };
+ static final long[] jjbitVec58 = {
+ 0x73efffe000000e0L, 0xfffffffffffffffeL, 0xfffffffe661fffffL, 0x7fffffffffffffffL
+ };
+ static final long[] jjbitVec59 = {
+ 0x5f7ffdffe0f8007fL, 0xffffffffffffffdbL, 0x3ffffffffffffL, 0xfffffffffff80000L
+ };
+ static final long[] jjbitVec60 = {
+ 0x18000f00000000L, 0xffd702000000e000L, 0xffffffffffffffffL, 0x9fffffffffffffffL
+ };
+ static final long[] jjbitVec61 = {
+ 0x87fffffe03ff0010L, 0xffffffe007fffffeL, 0x7fffffffffffffffL, 0xe0000631cfcfcfcL
+ };
+
+ private int jjMoveNfa_0(int startState, int curPos) {
+ int[] nextStates;
+ int startsAt = 0;
+ jjnewStateCnt = 71;
+ int i = 1;
+ jjstateSet[0] = startState;
+ int j, kind = 0x7fffffff;
+ for (; ;) {
+ if (++jjround == 0x7fffffff)
+ ReInitRounds();
+ if (curChar < 64) {
+ long l = 1L << curChar;
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 1:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(0, 6);
+ else if ((0x100003600L & l) != 0L) {
+ if (kind > 3)
+ kind = 3;
+ jjCheckNAdd(0);
+ } else if (curChar == 47)
+ jjAddStates(7, 8);
+ else if (curChar == 36) {
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ } else if (curChar == 34)
+ jjCheckNAddStates(9, 11);
+ else if (curChar == 39)
+ jjAddStates(12, 13);
+ else if (curChar == 46)
+ jjCheckNAdd(5);
+ if ((0x3fe000000000000L & l) != 0L) {
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(2, 3);
+ } else if (curChar == 48) {
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddStates(14, 18);
+ }
+ break;
+ case 48:
+ if (curChar == 47) {
+ if (kind > 4)
+ kind = 4;
+ jjCheckNAddStates(19, 21);
+ } else if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 46;
+ break;
+ case 0:
+ if ((0x100003600L & l) == 0L)
+ break;
+ if (kind > 3)
+ kind = 3;
+ jjCheckNAdd(0);
+ break;
+ case 2:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(2, 3);
+ break;
+ case 4:
+ if (curChar == 46)
+ jjCheckNAdd(5);
+ break;
+ case 5:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddStates(22, 24);
+ break;
+ case 7:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(8);
+ break;
+ case 8:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(8, 9);
+ break;
+ case 10:
+ if (curChar == 39)
+ jjAddStates(12, 13);
+ break;
+ case 11:
+ if ((0xffffff7fffffdbffL & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 12:
+ if (curChar == 39 && kind > 70)
+ kind = 70;
+ break;
+ case 14:
+ if ((0x8400000000L & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 15:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(16, 12);
+ break;
+ case 16:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 17:
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 18;
+ break;
+ case 18:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAdd(16);
+ break;
+ case 19:
+ if (curChar == 34)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 20:
+ if ((0xfffffffbffffdbffL & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 22:
+ if ((0x8400000000L & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 23:
+ if (curChar == 34 && kind > 71)
+ kind = 71;
+ break;
+ case 24:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(25, 28);
+ break;
+ case 25:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 26:
+ if ((0xf000000000000L & l) != 0L)
+ jjstateSet[jjnewStateCnt++] = 27;
+ break;
+ case 27:
+ if ((0xff000000000000L & l) != 0L)
+ jjCheckNAdd(25);
+ break;
+ case 28:
+ if (curChar != 36)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 29:
+ if ((0x3ff00100fffc1ffL & l) == 0L)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 30:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(0, 6);
+ break;
+ case 31:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(29, 31);
+ break;
+ case 33:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(34);
+ break;
+ case 34:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(34, 9);
+ break;
+ case 35:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(35, 36);
+ break;
+ case 37:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(38);
+ break;
+ case 38:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(38, 9);
+ break;
+ case 39:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(39, 40);
+ break;
+ case 40:
+ if (curChar != 46)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddStates(32, 34);
+ break;
+ case 41:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddStates(32, 34);
+ break;
+ case 43:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(44);
+ break;
+ case 44:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(44, 9);
+ break;
+ case 45:
+ if (curChar == 47)
+ jjAddStates(7, 8);
+ break;
+ case 46:
+ if (curChar == 42)
+ jjstateSet[jjnewStateCnt++] = 47;
+ break;
+ case 47:
+ if ((0xffff7fffffffffffL & l) != 0L && kind > 1)
+ kind = 1;
+ break;
+ case 49:
+ if (curChar != 47)
+ break;
+ if (kind > 4)
+ kind = 4;
+ jjCheckNAddStates(19, 21);
+ break;
+ case 50:
+ if ((0xffffffffffffdbffL & l) == 0L)
+ break;
+ if (kind > 4)
+ kind = 4;
+ jjCheckNAddStates(19, 21);
+ break;
+ case 51:
+ if ((0x2400L & l) != 0L && kind > 4)
+ kind = 4;
+ break;
+ case 52:
+ if (curChar == 10 && kind > 4)
+ kind = 4;
+ break;
+ case 53:
+ if (curChar == 13)
+ jjstateSet[jjnewStateCnt++] = 52;
+ break;
+ case 54:
+ if (curChar != 48)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddStates(14, 18);
+ break;
+ case 56:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(56, 3);
+ break;
+ case 57:
+ if ((0xff000000000000L & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(57, 3);
+ break;
+ case 59:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjAddStates(35, 36);
+ break;
+ case 60:
+ if (curChar == 46)
+ jjCheckNAdd(61);
+ break;
+ case 61:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddTwoStates(61, 62);
+ break;
+ case 63:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(64);
+ break;
+ case 64:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(64, 9);
+ break;
+ case 66:
+ if ((0x3ff000000000000L & l) != 0L)
+ jjCheckNAddStates(37, 39);
+ break;
+ case 67:
+ if (curChar == 46)
+ jjCheckNAdd(68);
+ break;
+ case 69:
+ if ((0x280000000000L & l) != 0L)
+ jjCheckNAdd(70);
+ break;
+ case 70:
+ if ((0x3ff000000000000L & l) == 0L)
+ break;
+ if (kind > 65)
+ kind = 65;
+ jjCheckNAddTwoStates(70, 9);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else if (curChar < 128) {
+ long l = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 1:
+ if ((0x7fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 3:
+ if ((0x100000001000L & l) != 0L && kind > 61)
+ kind = 61;
+ break;
+ case 6:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(40, 41);
+ break;
+ case 9:
+ if ((0x5000000050L & l) != 0L && kind > 65)
+ kind = 65;
+ break;
+ case 11:
+ if ((0xffffffffefffffffL & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 13:
+ if (curChar == 92)
+ jjAddStates(42, 44);
+ break;
+ case 14:
+ if ((0x14404410000000L & l) != 0L)
+ jjCheckNAdd(12);
+ break;
+ case 20:
+ if ((0xffffffffefffffffL & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 21:
+ if (curChar == 92)
+ jjAddStates(45, 47);
+ break;
+ case 22:
+ if ((0x14404410000000L & l) != 0L)
+ jjCheckNAddStates(9, 11);
+ break;
+ case 29:
+ if ((0x87fffffe87fffffeL & l) == 0L)
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 32:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(48, 49);
+ break;
+ case 36:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(50, 51);
+ break;
+ case 42:
+ if ((0x2000000020L & l) != 0L)
+ jjAddStates(52, 53);
+ break;
+ case 47:
+ if (kind > 1)
+ kind = 1;
+ break;
+ case 50:
+ if (kind > 4)
+ kind = 4;
+ jjAddStates(19, 21);
+ break;
+ case 55:
+ if ((0x100000001000000L & l) != 0L)
+ jjCheckNAdd(56);
+ break;
+ case 56:
+ if ((0x7e0000007eL & l) == 0L)
+ break;
+ if (kind > 61)
+ kind = 61;
+ jjCheckNAddTwoStates(56, 3);
+ break;
+ case 58:
+ if ((0x100000001000000L & l) != 0L)
+ jjCheckNAddTwoStates(59, 60);
+ break;
+ case 59:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAddTwoStates(59, 60);
+ break;
+ case 61:
+ if ((0x7e0000007eL & l) != 0L)
+ jjAddStates(54, 55);
+ break;
+ case 62:
+ if ((0x1000000010000L & l) != 0L)
+ jjAddStates(56, 57);
+ break;
+ case 65:
+ if ((0x100000001000000L & l) != 0L)
+ jjCheckNAdd(66);
+ break;
+ case 66:
+ if ((0x7e0000007eL & l) != 0L)
+ jjCheckNAddStates(37, 39);
+ break;
+ case 68:
+ if ((0x1000000010000L & l) != 0L)
+ jjAddStates(58, 59);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ } else {
+ int hiByte = (int) (curChar >> 8);
+ int i1 = hiByte >> 6;
+ long l1 = 1L << (hiByte & 077);
+ int i2 = (curChar & 0xff) >> 6;
+ long l2 = 1L << (curChar & 077);
+ MatchLoop:
+ do {
+ switch (jjstateSet[--i]) {
+ case 1:
+ if (!jjCanMove_1(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 11:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjstateSet[jjnewStateCnt++] = 12;
+ break;
+ case 20:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2))
+ jjAddStates(9, 11);
+ break;
+ case 29:
+ if (!jjCanMove_2(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 72)
+ kind = 72;
+ jjCheckNAdd(29);
+ break;
+ case 47:
+ if (jjCanMove_0(hiByte, i1, i2, l1, l2) && kind > 1)
+ kind = 1;
+ break;
+ case 50:
+ if (!jjCanMove_0(hiByte, i1, i2, l1, l2))
+ break;
+ if (kind > 4)
+ kind = 4;
+ jjAddStates(19, 21);
+ break;
+ default:
+ break;
+ }
+ } while (i != startsAt);
+ }
+ if (kind != 0x7fffffff) {
+ jjmatchedKind = kind;
+ jjmatchedPos = curPos;
+ kind = 0x7fffffff;
+ }
+ ++curPos;
+ if ((i = jjnewStateCnt) == (startsAt = 71 - (jjnewStateCnt = startsAt)))
+ return curPos;
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return curPos;
+ }
+ }
+ }
+
+ private int jjMoveStringLiteralDfa0_2() {
+ switch (curChar) {
+ case 42:
+ return jjMoveStringLiteralDfa1_2(0x40L);
+ default:
+ return 1;
+ }
+ }
+
+ private int jjMoveStringLiteralDfa1_2(long active0) {
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return 1;
+ }
+ switch (curChar) {
+ case 47:
+ if ((active0 & 0x40L) != 0L)
+ return jjStopAtPos(1, 6);
+ break;
+ default:
+ return 2;
+ }
+ return 2;
+ }
+
+ private int jjMoveStringLiteralDfa0_1() {
+ switch (curChar) {
+ case 42:
+ return jjMoveStringLiteralDfa1_1(0x20L);
+ default:
+ return 1;
+ }
+ }
+
+ private int jjMoveStringLiteralDfa1_1(long active0) {
+ try {
+ curChar = input_stream.readChar();
+ }
+ catch (java.io.IOException e) {
+ return 1;
+ }
+ switch (curChar) {
+ case 47:
+ if ((active0 & 0x20L) != 0L)
+ return jjStopAtPos(1, 5);
+ break;
+ default:
+ return 2;
+ }
+ return 2;
+ }
+
+ static final int[] jjnextStates = {
+ 31, 32, 9, 35, 36, 39, 40, 48, 49, 20, 21, 23, 11, 13, 55, 57,
+ 3, 58, 65, 50, 51, 53, 5, 6, 9, 20, 21, 25, 23, 31, 32, 9,
+ 41, 42, 9, 59, 60, 66, 67, 68, 7, 8, 14, 15, 17, 22, 24, 26,
+ 33, 34, 37, 38, 43, 44, 61, 62, 63, 64, 69, 70,
+ };
+
+ private static boolean jjCanMove_0(int hiByte, int i1, int i2, long l1, long l2) {
+ switch (hiByte) {
+ case 0:
+ return ((jjbitVec2[i2] & l2) != 0L);
+ default:
+ if ((jjbitVec0[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+ }
+
+ private static boolean jjCanMove_1(int hiByte, int i1, int i2, long l1, long l2) {
+ switch (hiByte) {
+ case 0:
+ return ((jjbitVec4[i2] & l2) != 0L);
+ case 2:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 3:
+ return ((jjbitVec6[i2] & l2) != 0L);
+ case 4:
+ return ((jjbitVec7[i2] & l2) != 0L);
+ case 5:
+ return ((jjbitVec8[i2] & l2) != 0L);
+ case 6:
+ return ((jjbitVec9[i2] & l2) != 0L);
+ case 7:
+ return ((jjbitVec10[i2] & l2) != 0L);
+ case 9:
+ return ((jjbitVec11[i2] & l2) != 0L);
+ case 10:
+ return ((jjbitVec12[i2] & l2) != 0L);
+ case 11:
+ return ((jjbitVec13[i2] & l2) != 0L);
+ case 12:
+ return ((jjbitVec14[i2] & l2) != 0L);
+ case 13:
+ return ((jjbitVec15[i2] & l2) != 0L);
+ case 14:
+ return ((jjbitVec16[i2] & l2) != 0L);
+ case 15:
+ return ((jjbitVec17[i2] & l2) != 0L);
+ case 16:
+ return ((jjbitVec18[i2] & l2) != 0L);
+ case 17:
+ return ((jjbitVec19[i2] & l2) != 0L);
+ case 18:
+ return ((jjbitVec20[i2] & l2) != 0L);
+ case 19:
+ return ((jjbitVec21[i2] & l2) != 0L);
+ case 20:
+ return ((jjbitVec0[i2] & l2) != 0L);
+ case 22:
+ return ((jjbitVec22[i2] & l2) != 0L);
+ case 23:
+ return ((jjbitVec23[i2] & l2) != 0L);
+ case 24:
+ return ((jjbitVec24[i2] & l2) != 0L);
+ case 30:
+ return ((jjbitVec25[i2] & l2) != 0L);
+ case 31:
+ return ((jjbitVec26[i2] & l2) != 0L);
+ case 32:
+ return ((jjbitVec27[i2] & l2) != 0L);
+ case 33:
+ return ((jjbitVec28[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec29[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec30[i2] & l2) != 0L);
+ case 77:
+ return ((jjbitVec31[i2] & l2) != 0L);
+ case 159:
+ return ((jjbitVec32[i2] & l2) != 0L);
+ case 164:
+ return ((jjbitVec33[i2] & l2) != 0L);
+ case 215:
+ return ((jjbitVec34[i2] & l2) != 0L);
+ case 250:
+ return ((jjbitVec35[i2] & l2) != 0L);
+ case 251:
+ return ((jjbitVec36[i2] & l2) != 0L);
+ case 253:
+ return ((jjbitVec37[i2] & l2) != 0L);
+ case 254:
+ return ((jjbitVec38[i2] & l2) != 0L);
+ case 255:
+ return ((jjbitVec39[i2] & l2) != 0L);
+ default:
+ if ((jjbitVec3[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+ }
+
+ private static boolean jjCanMove_2(int hiByte, int i1, int i2, long l1, long l2) {
+ switch (hiByte) {
+ case 0:
+ return ((jjbitVec40[i2] & l2) != 0L);
+ case 2:
+ return ((jjbitVec5[i2] & l2) != 0L);
+ case 3:
+ return ((jjbitVec41[i2] & l2) != 0L);
+ case 4:
+ return ((jjbitVec42[i2] & l2) != 0L);
+ case 5:
+ return ((jjbitVec43[i2] & l2) != 0L);
+ case 6:
+ return ((jjbitVec44[i2] & l2) != 0L);
+ case 7:
+ return ((jjbitVec45[i2] & l2) != 0L);
+ case 9:
+ return ((jjbitVec46[i2] & l2) != 0L);
+ case 10:
+ return ((jjbitVec47[i2] & l2) != 0L);
+ case 11:
+ return ((jjbitVec48[i2] & l2) != 0L);
+ case 12:
+ return ((jjbitVec49[i2] & l2) != 0L);
+ case 13:
+ return ((jjbitVec50[i2] & l2) != 0L);
+ case 14:
+ return ((jjbitVec51[i2] & l2) != 0L);
+ case 15:
+ return ((jjbitVec52[i2] & l2) != 0L);
+ case 16:
+ return ((jjbitVec53[i2] & l2) != 0L);
+ case 17:
+ return ((jjbitVec19[i2] & l2) != 0L);
+ case 18:
+ return ((jjbitVec20[i2] & l2) != 0L);
+ case 19:
+ return ((jjbitVec54[i2] & l2) != 0L);
+ case 20:
+ return ((jjbitVec0[i2] & l2) != 0L);
+ case 22:
+ return ((jjbitVec22[i2] & l2) != 0L);
+ case 23:
+ return ((jjbitVec55[i2] & l2) != 0L);
+ case 24:
+ return ((jjbitVec56[i2] & l2) != 0L);
+ case 30:
+ return ((jjbitVec25[i2] & l2) != 0L);
+ case 31:
+ return ((jjbitVec26[i2] & l2) != 0L);
+ case 32:
+ return ((jjbitVec57[i2] & l2) != 0L);
+ case 33:
+ return ((jjbitVec28[i2] & l2) != 0L);
+ case 48:
+ return ((jjbitVec58[i2] & l2) != 0L);
+ case 49:
+ return ((jjbitVec30[i2] & l2) != 0L);
+ case 77:
+ return ((jjbitVec31[i2] & l2) != 0L);
+ case 159:
+ return ((jjbitVec32[i2] & l2) != 0L);
+ case 164:
+ return ((jjbitVec33[i2] & l2) != 0L);
+ case 215:
+ return ((jjbitVec34[i2] & l2) != 0L);
+ case 250:
+ return ((jjbitVec35[i2] & l2) != 0L);
+ case 251:
+ return ((jjbitVec59[i2] & l2) != 0L);
+ case 253:
+ return ((jjbitVec37[i2] & l2) != 0L);
+ case 254:
+ return ((jjbitVec60[i2] & l2) != 0L);
+ case 255:
+ return ((jjbitVec61[i2] & l2) != 0L);
+ default:
+ if ((jjbitVec3[i1] & l1) != 0L)
+ return true;
+ return false;
+ }
+ }
+
+ public static final String[] jjstrLiteralImages = {
+ "", null, null, null, null, null, null, null,
+ "\141\142\163\164\162\141\143\164", "\141\163\163\145\162\164", "\142\157\157\154\145\141\156",
+ "\142\162\145\141\153", "\142\171\164\145", "\143\141\163\145", "\143\141\164\143\150",
+ "\143\150\141\162", "\143\154\141\163\163", "\143\157\156\163\164",
+ "\143\157\156\164\151\156\165\145", "\144\145\146\141\165\154\164", "\144\157", "\144\157\165\142\154\145",
+ "\145\154\163\145", "\145\156\165\155", "\145\170\164\145\156\144\163", "\146\141\154\163\145",
+ "\146\151\156\141\154", "\146\151\156\141\154\154\171", "\146\154\157\141\164", "\146\157\162",
+ "\147\157\164\157", "\151\146", "\151\155\160\154\145\155\145\156\164\163",
+ "\151\155\160\157\162\164", "\151\156\163\164\141\156\143\145\157\146", "\151\156\164",
+ "\151\156\164\145\162\146\141\143\145", "\154\157\156\147", "\156\141\164\151\166\145", "\156\145\167",
+ "\156\165\154\154", "\160\141\143\153\141\147\145", "\160\162\151\166\141\164\145",
+ "\160\162\157\164\145\143\164\145\144", "\160\165\142\154\151\143", "\162\145\164\165\162\156",
+ "\163\150\157\162\164", "\163\164\141\164\151\143", "\163\164\162\151\143\164\146\160",
+ "\163\165\160\145\162", "\163\167\151\164\143\150",
+ "\163\171\156\143\150\162\157\156\151\172\145\144", "\164\150\151\163", "\164\150\162\157\167", "\164\150\162\157\167\163",
+ "\164\162\141\156\163\151\145\156\164", "\164\162\165\145", "\164\162\171", "\166\157\151\144",
+ "\166\157\154\141\164\151\154\145", "\167\150\151\154\145", null, null, null, null, null, null, null, null, null,
+ null, null, null, null, null, "\50", "\51", "\173", "\175", "\133", "\135", "\73",
+ "\54", "\56", "\100", "\75", "\74", "\41", "\176", "\77", "\72", "\75\75", "\74\75",
+ "\76\75", "\41\75", "\174\174", "\46\46", "\53\53", "\55\55", "\53", "\55", "\52",
+ "\57", "\46", "\174", "\136", "\45", "\74\74", "\53\75", "\55\75", "\52\75",
+ "\57\75", "\46\75", "\174\75", "\136\75", "\45\75", "\74\74\75", "\76\76\75",
+ "\76\76\76\75", "\56\56\56", "\76\76\76", "\76\76", "\76", "\32", null,};
+ public static final String[] lexStateNames = {
+ "DEFAULT",
+ "IN_FORMAL_COMMENT",
+ "IN_MULTI_LINE_COMMENT",
+ };
+ public static final int[] jjnewLexState = {
+ -1, 1, 2, -1, -1, 0, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
+ };
+ static final long[] jjtoToken = {
+ 0x3fffffffffffff01L, 0x1ffffffffffff9c2L,
+ };
+ static final long[] jjtoSkip = {
+ 0x78L, 0x0L,
+ };
+ static final long[] jjtoSpecial = {
+ 0x78L, 0x0L,
+ };
+ static final long[] jjtoMore = {
+ 0x86L, 0x0L,
+ };
+ protected JavaCharStream input_stream;
+ private final int[] jjrounds = new int[71];
+ private final int[] jjstateSet = new int[142];
+ StringBuffer image;
+ int jjimageLen;
+ int lengthOfMatch;
+ protected char curChar;
+
+ public JavaParserTokenManager(JavaCharStream stream) {
+ if (JavaCharStream.staticFlag)
+ throw new Error("ERROR: Cannot use a static CharStream class with a non-static lexical analyzer.");
+ input_stream = stream;
+ }
+
+ public JavaParserTokenManager(JavaCharStream stream, int lexState) {
+ this(stream);
+ SwitchTo(lexState);
+ }
+
+ public void ReInit(JavaCharStream stream) {
+ jjmatchedPos = jjnewStateCnt = 0;
+ curLexState = defaultLexState;
+ input_stream = stream;
+ ReInitRounds();
+ }
+
+ private void ReInitRounds() {
+ int i;
+ jjround = 0x80000001;
+ for (i = 71; i-- > 0;)
+ jjrounds[i] = 0x80000000;
+ }
+
+ public void ReInit(JavaCharStream stream, int lexState) {
+ ReInit(stream);
+ SwitchTo(lexState);
+ }
+
+ public void SwitchTo(int lexState) {
+ if (lexState >= 3 || lexState < 0)
+ throw new TokenMgrError("Error: Ignoring invalid lexical state : " + lexState + ". State unchanged.", TokenMgrError.INVALID_LEXICAL_STATE);
+ else
+ curLexState = lexState;
+ }
+
+ protected Token jjFillToken() {
+ Token t = Token.newToken(jjmatchedKind);
+ t.kind = jjmatchedKind;
+ String im = jjstrLiteralImages[jjmatchedKind];
+ t.image = (im == null) ? input_stream.GetImage() : im;
+ t.beginLine = input_stream.getBeginLine();
+ t.beginColumn = input_stream.getBeginColumn();
+ t.endLine = input_stream.getEndLine();
+ t.endColumn = input_stream.getEndColumn();
+ return t;
+ }
+
+ int curLexState = 0;
+ int defaultLexState = 0;
+ int jjnewStateCnt;
+ int jjround;
+ int jjmatchedPos;
+ int jjmatchedKind;
+
+ public Token getNextToken() {
+ int kind;
+ Token specialToken = null;
+ Token matchedToken;
+ int curPos = 0;
+
+ EOFLoop:
+ for (; ;) {
+ try {
+ curChar = input_stream.BeginToken();
+ }
+ catch (java.io.IOException e) {
+ jjmatchedKind = 0;
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ return matchedToken;
+ }
+ image = null;
+ jjimageLen = 0;
+
+ for (; ;) {
+ switch (curLexState) {
+ case 0:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_0();
+ if (jjmatchedPos == 0 && jjmatchedKind > 124) {
+ jjmatchedKind = 124;
+ }
+ break;
+ case 1:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_1();
+ if (jjmatchedPos == 0 && jjmatchedKind > 7) {
+ jjmatchedKind = 7;
+ }
+ break;
+ case 2:
+ jjmatchedKind = 0x7fffffff;
+ jjmatchedPos = 0;
+ curPos = jjMoveStringLiteralDfa0_2();
+ if (jjmatchedPos == 0 && jjmatchedKind > 7) {
+ jjmatchedKind = 7;
+ }
+ break;
+ }
+ if (jjmatchedKind != 0x7fffffff) {
+ if (jjmatchedPos + 1 < curPos)
+ input_stream.backup(curPos - jjmatchedPos - 1);
+ if ((jjtoToken[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ matchedToken = jjFillToken();
+ matchedToken.specialToken = specialToken;
+ TokenLexicalActions(matchedToken);
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ return matchedToken;
+ } else
+ if ((jjtoSkip[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ if ((jjtoSpecial[jjmatchedKind >> 6] & (1L << (jjmatchedKind & 077))) != 0L) {
+ matchedToken = jjFillToken();
+ if (specialToken == null)
+ specialToken = matchedToken;
+ else {
+ matchedToken.specialToken = specialToken;
+ specialToken = (specialToken.next = matchedToken);
+ }
+ SkipLexicalActions(matchedToken);
+ } else
+ SkipLexicalActions(null);
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ continue EOFLoop;
+ }
+ MoreLexicalActions();
+ if (jjnewLexState[jjmatchedKind] != -1)
+ curLexState = jjnewLexState[jjmatchedKind];
+ curPos = 0;
+ jjmatchedKind = 0x7fffffff;
+ try {
+ curChar = input_stream.readChar();
+ continue;
+ }
+ catch (java.io.IOException e1) {
+ }
+ }
+ int error_line = input_stream.getEndLine();
+ int error_column = input_stream.getEndColumn();
+ String error_after = null;
+ boolean EOFSeen = false;
+ try {
+ input_stream.readChar();
+ input_stream.backup(1);
+ }
+ catch (java.io.IOException e1) {
+ EOFSeen = true;
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ if (curChar == '\n' || curChar == '\r') {
+ error_line++;
+ error_column = 0;
+ } else
+ error_column++;
+ }
+ if (!EOFSeen) {
+ input_stream.backup(1);
+ error_after = curPos <= 1 ? "" : input_stream.GetImage();
+ }
+ throw new TokenMgrError(EOFSeen, curLexState, error_line, error_column, error_after, curChar, TokenMgrError.LEXICAL_ERROR);
+ }
+ }
+ }
+
+ void SkipLexicalActions(Token matchedToken) {
+ switch (jjmatchedKind) {
+ default:
+ break;
+ }
+ }
+
+ void MoreLexicalActions() {
+ jjimageLen += (lengthOfMatch = jjmatchedPos + 1);
+ switch (jjmatchedKind) {
+ case 1:
+ if (image == null)
+ image = new StringBuffer();
+ image.append(input_stream.GetSuffix(jjimageLen));
+ jjimageLen = 0;
+ input_stream.backup(1);
+ break;
+ default:
+ break;
+ }
+ }
+
+ void TokenLexicalActions(Token matchedToken) {
+ switch (jjmatchedKind) {
+ case 120:
+ if (image == null)
+ image = new StringBuffer();
+ image.append(jjstrLiteralImages[120]);
+ matchedToken.kind = GT;
+ ((Token.GTToken) matchedToken).realKind = RUNSIGNEDSHIFT;
+ input_stream.backup(2);
+ matchedToken.image = ">";
+ break;
+ case 121:
+ if (image == null)
+ image = new StringBuffer();
+ image.append(jjstrLiteralImages[121]);
+ matchedToken.kind = GT;
+ ((Token.GTToken) matchedToken).realKind = RSIGNEDSHIFT;
+ input_stream.backup(1);
+ matchedToken.image = ">";
+ break;
+ default:
+ break;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTokenManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/JavaParserTreeConstants.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,230 @@
+/* Generated By:JJTree: Do not edit this line. ./JavaParserTreeConstants.java */
+
+package jaxx.compiler.parser.java;
+
+public interface JavaParserTreeConstants {
+ public int JJTLINE = 0;
+ public int JJTCOMPILATIONUNIT = 1;
+ public int JJTPACKAGEDECLARATION = 2;
+ public int JJTIMPORTDECLARATION = 3;
+ public int JJTMODIFIERS = 4;
+ public int JJTTYPEDECLARATION = 5;
+ public int JJTCLASSORINTERFACEDECLARATION = 6;
+ public int JJTEXTENDSLIST = 7;
+ public int JJTIMPLEMENTSLIST = 8;
+ public int JJTENUMDECLARATION = 9;
+ public int JJTENUMBODY = 10;
+ public int JJTENUMCONSTANT = 11;
+ public int JJTTYPEPARAMETERS = 12;
+ public int JJTTYPEPARAMETER = 13;
+ public int JJTTYPEBOUND = 14;
+ public int JJTCLASSORINTERFACEBODY = 15;
+ public int JJTCLASSORINTERFACEBODYDECLARATION = 16;
+ public int JJTFIELDDECLARATION = 17;
+ public int JJTVARIABLEDECLARATOR = 18;
+ public int JJTVARIABLEDECLARATORID = 19;
+ public int JJTVARIABLEINITIALIZER = 20;
+ public int JJTARRAYINITIALIZER = 21;
+ public int JJTMETHODDECLARATION = 22;
+ public int JJTMETHODDECLARATOR = 23;
+ public int JJTFORMALPARAMETERS = 24;
+ public int JJTFORMALPARAMETER = 25;
+ public int JJTCONSTRUCTORDECLARATION = 26;
+ public int JJTEXPLICITCONSTRUCTORINVOCATION = 27;
+ public int JJTINITIALIZER = 28;
+ public int JJTTYPE = 29;
+ public int JJTREFERENCETYPE = 30;
+ public int JJTCLASSORINTERFACETYPE = 31;
+ public int JJTTYPEARGUMENTS = 32;
+ public int JJTTYPEARGUMENT = 33;
+ public int JJTWILDCARDBOUNDS = 34;
+ public int JJTPRIMITIVETYPE = 35;
+ public int JJTRESULTTYPE = 36;
+ public int JJTNAME = 37;
+ public int JJTNAMELIST = 38;
+ public int JJTEXPRESSION = 39;
+ public int JJTASSIGNMENTOPERATOR = 40;
+ public int JJTASSIGNMENTEXPRESSION = 41;
+ public int JJTCONDITIONALEXPRESSION = 42;
+ public int JJTCONDITIONALOREXPRESSION = 43;
+ public int JJTCONDITIONALANDEXPRESSION = 44;
+ public int JJTINCLUSIVEOREXPRESSION = 45;
+ public int JJTEXCLUSIVEOREXPRESSION = 46;
+ public int JJTANDEXPRESSION = 47;
+ public int JJTEQUALITYEXPRESSION = 48;
+ public int JJTINSTANCEOFEXPRESSION = 49;
+ public int JJTRELATIONALEXPRESSION = 50;
+ public int JJTSHIFTEXPRESSION = 51;
+ public int JJTADDITIVEEXPRESSION = 52;
+ public int JJTMULTIPLICATIVEEXPRESSION = 53;
+ public int JJTUNARYEXPRESSION = 54;
+ public int JJTPREINCREMENTEXPRESSION = 55;
+ public int JJTPREDECREMENTEXPRESSION = 56;
+ public int JJTUNARYEXPRESSIONNOTPLUSMINUS = 57;
+ public int JJTCASTLOOKAHEAD = 58;
+ public int JJTPOSTFIXEXPRESSION = 59;
+ public int JJTPOSTFIXOPERATOR = 60;
+ public int JJTCASTEXPRESSION = 61;
+ public int JJTPRIMARYEXPRESSION = 62;
+ public int JJTMEMBERSELECTOR = 63;
+ public int JJTPRIMARYPREFIX = 64;
+ public int JJTPRIMARYSUFFIX = 65;
+ public int JJTLITERAL = 66;
+ public int JJTBOOLEANLITERAL = 67;
+ public int JJTNULLLITERAL = 68;
+ public int JJTARGUMENTS = 69;
+ public int JJTARGUMENTLIST = 70;
+ public int JJTALLOCATIONEXPRESSION = 71;
+ public int JJTARRAYDIMSANDINITS = 72;
+ public int JJTSTATEMENT = 73;
+ public int JJTASSERTSTATEMENT = 74;
+ public int JJTLABELEDSTATEMENT = 75;
+ public int JJTBLOCK = 76;
+ public int JJTBLOCKSTATEMENT = 77;
+ public int JJTLOCALVARIABLEDECLARATION = 78;
+ public int JJTEMPTYSTATEMENT = 79;
+ public int JJTSTATEMENTEXPRESSION = 80;
+ public int JJTSWITCHSTATEMENT = 81;
+ public int JJTSWITCHLABEL = 82;
+ public int JJTIFSTATEMENT = 83;
+ public int JJTWHILESTATEMENT = 84;
+ public int JJTDOSTATEMENT = 85;
+ public int JJTFORSTATEMENT = 86;
+ public int JJTFORINIT = 87;
+ public int JJTSTATEMENTEXPRESSIONLIST = 88;
+ public int JJTFORUPDATE = 89;
+ public int JJTBREAKSTATEMENT = 90;
+ public int JJTCONTINUESTATEMENT = 91;
+ public int JJTRETURNSTATEMENT = 92;
+ public int JJTTHROWSTATEMENT = 93;
+ public int JJTSYNCHRONIZEDSTATEMENT = 94;
+ public int JJTTRYSTATEMENT = 95;
+ public int JJTRUNSIGNEDSHIFT = 96;
+ public int JJTRSIGNEDSHIFT = 97;
+ public int JJTANNOTATION = 98;
+ public int JJTNORMALANNOTATION = 99;
+ public int JJTMARKERANNOTATION = 100;
+ public int JJTSINGLEMEMBERANNOTATION = 101;
+ public int JJTMEMBERVALUEPAIRS = 102;
+ public int JJTMEMBERVALUEPAIR = 103;
+ public int JJTMEMBERVALUE = 104;
+ public int JJTMEMBERVALUEARRAYINITIALIZER = 105;
+ public int JJTANNOTATIONTYPEDECLARATION = 106;
+ public int JJTANNOTATIONTYPEBODY = 107;
+ public int JJTANNOTATIONTYPEMEMBERDECLARATION = 108;
+ public int JJTDEFAULTVALUE = 109;
+
+
+ public String[] jjtNodeName = {
+ "Line",
+ "CompilationUnit",
+ "PackageDeclaration",
+ "ImportDeclaration",
+ "Modifiers",
+ "TypeDeclaration",
+ "ClassOrInterfaceDeclaration",
+ "ExtendsList",
+ "ImplementsList",
+ "EnumDeclaration",
+ "EnumBody",
+ "EnumConstant",
+ "TypeParameters",
+ "TypeParameter",
+ "TypeBound",
+ "ClassOrInterfaceBody",
+ "ClassOrInterfaceBodyDeclaration",
+ "FieldDeclaration",
+ "VariableDeclarator",
+ "VariableDeclaratorId",
+ "VariableInitializer",
+ "ArrayInitializer",
+ "MethodDeclaration",
+ "MethodDeclarator",
+ "FormalParameters",
+ "FormalParameter",
+ "ConstructorDeclaration",
+ "ExplicitConstructorInvocation",
+ "Initializer",
+ "Type",
+ "ReferenceType",
+ "ClassOrInterfaceType",
+ "TypeArguments",
+ "TypeArgument",
+ "WildcardBounds",
+ "PrimitiveType",
+ "ResultType",
+ "Name",
+ "NameList",
+ "Expression",
+ "AssignmentOperator",
+ "AssignmentExpression",
+ "ConditionalExpression",
+ "ConditionalOrExpression",
+ "ConditionalAndExpression",
+ "InclusiveOrExpression",
+ "ExclusiveOrExpression",
+ "AndExpression",
+ "EqualityExpression",
+ "InstanceOfExpression",
+ "RelationalExpression",
+ "ShiftExpression",
+ "AdditiveExpression",
+ "MultiplicativeExpression",
+ "UnaryExpression",
+ "PreIncrementExpression",
+ "PreDecrementExpression",
+ "UnaryExpressionNotPlusMinus",
+ "CastLookahead",
+ "PostfixExpression",
+ "PostfixOperator",
+ "CastExpression",
+ "PrimaryExpression",
+ "MemberSelector",
+ "PrimaryPrefix",
+ "PrimarySuffix",
+ "Literal",
+ "BooleanLiteral",
+ "NullLiteral",
+ "Arguments",
+ "ArgumentList",
+ "AllocationExpression",
+ "ArrayDimsAndInits",
+ "Statement",
+ "AssertStatement",
+ "LabeledStatement",
+ "Block",
+ "BlockStatement",
+ "LocalVariableDeclaration",
+ "EmptyStatement",
+ "StatementExpression",
+ "SwitchStatement",
+ "SwitchLabel",
+ "IfStatement",
+ "WhileStatement",
+ "DoStatement",
+ "ForStatement",
+ "ForInit",
+ "StatementExpressionList",
+ "ForUpdate",
+ "BreakStatement",
+ "ContinueStatement",
+ "ReturnStatement",
+ "ThrowStatement",
+ "SynchronizedStatement",
+ "TryStatement",
+ "RUNSIGNEDSHIFT",
+ "RSIGNEDSHIFT",
+ "Annotation",
+ "NormalAnnotation",
+ "MarkerAnnotation",
+ "SingleMemberAnnotation",
+ "MemberValuePairs",
+ "MemberValuePair",
+ "MemberValue",
+ "MemberValueArrayInitializer",
+ "AnnotationTypeDeclaration",
+ "AnnotationTypeBody",
+ "AnnotationTypeMemberDeclaration",
+ "DefaultValue",
+ };
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/JavaParserTreeConstants.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Node.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,51 @@
+/* Generated By:JJTree: Do not edit this line. Node.java */
+
+package jaxx.compiler.parser.java;
+
+/* All AST nodes must implement this interface. It provides basic
+ machinery for constructing the parent and child relationships
+ between nodes. */
+
+public interface Node {
+
+ /**
+ * This method is called after the node has been made the current
+ * node. It indicates that child nodes can now be added to it.
+ */
+ public void jjtOpen();
+
+ /**
+ * This method is called after all the child nodes have been
+ * added.
+ */
+ public void jjtClose();
+
+ /**
+ * This pair of methods are used to inform the node of its
+ * parent.
+ *
+ * @param n node
+ */
+ public void jjtSetParent(Node n);
+
+ public Node jjtGetParent();
+
+ /**
+ * This method tells the node to add its argument to the node's
+ * list of children.
+ *
+ * @param n node
+ * @param i index ?
+ */
+ public void jjtAddChild(Node n, int i);
+
+ /**
+ * @param i index of child
+ * @return a child node. The children are numbered
+ * from zero, left to right.
+ */
+ public Node jjtGetChild(int i);
+
+ /** @return the number of children the node has. */
+ public int jjtGetNumChildren();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Node.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/ParseException.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,214 @@
+/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 3.0 */
+package jaxx.compiler.parser.java;
+
+/**
+ * This exception is thrown when parse errors are encountered.
+ * You can explicitly create objects of this exception type by
+ * calling the method generateParseException in the generated
+ * parser.
+ * <p/>
+ * You can modify this class to customize your error reporting
+ * mechanisms so long as you retain the public fields.
+ */
+public class ParseException extends jaxx.compiler.CompilerException {
+ int line;
+ int column;
+ private static final long serialVersionUID = 6179854408401024700L;
+
+ /**
+ * This constructor is used by the method "generateParseException"
+ * in the generated parser. Calling this constructor generates
+ * a new object of this type with the fields "currentToken",
+ * "expectedTokenSequences", and "tokenImage" set. The boolean
+ * flag "specialConstructor" is also set to true to indicate that
+ * this constructor was used to create this object.
+ * This constructor calls its super class with the empty string
+ * to force the "toString" method of parent class "Throwable" to
+ * print the error message in the form:
+ * ParseException: <result of getMessage>
+ *
+ * @param currentTokenVal ?
+ * @param expectedTokenSequencesVal ?
+ * @param tokenImageVal ?
+ */
+ public ParseException(Token currentTokenVal,
+ int[][] expectedTokenSequencesVal,
+ String[] tokenImageVal
+ ) {
+ super("");
+ specialConstructor = true;
+ currentToken = currentTokenVal;
+ expectedTokenSequences = expectedTokenSequencesVal;
+ tokenImage = tokenImageVal;
+ }
+
+ /**
+ * The following constructors are for use by you for whatever
+ * purpose you can think of. Constructing the exception in this
+ * manner makes the exception behave in the normal way - i.e., as
+ * documented in the class "Throwable". The fields "errorToken",
+ * "expectedTokenSequences", and "tokenImage" do not contain
+ * relevant information. The JavaCC generated code does not use
+ * these constructors.
+ */
+
+ public ParseException() {
+ super();
+ specialConstructor = false;
+ }
+
+ public ParseException(String message) {
+ super(message);
+ specialConstructor = false;
+ }
+
+ public ParseException(String message, int line, int column) {
+ super(message);
+ specialConstructor = false;
+ this.line = line;
+ this.column = column;
+ }
+
+
+ /**
+ * This variable determines which constructor was used to create
+ * this object and thereby affects the semantics of the
+ * "getMessage" method (see below).
+ */
+ protected boolean specialConstructor;
+
+ /**
+ * This is the last token that has been consumed successfully. If
+ * this object has been created due to a parse error, the token
+ * followng this token will (therefore) be the first error token.
+ */
+ public Token currentToken;
+
+ /**
+ * Each entry in this array is an array of integers. Each array
+ * of integers represents a sequence of tokens (by their ordinal
+ * values) that is expected at this point of the parse.
+ */
+ public int[][] expectedTokenSequences;
+
+ /**
+ * This is a reference to the "tokenImage" array of the generated
+ * parser within which the parse error occurred. This array is
+ * defined in the generated ...Constants interface.
+ */
+ public String[] tokenImage;
+
+ /**
+ * This method has the standard behavior when this object has been
+ * created using the standard constructors. Otherwise, it uses
+ * "currentToken" and "expectedTokenSequences" to generate a parse
+ * error message and returns it. If this object has been created
+ * due to a parse error, and you do not catch it (it gets thrown
+ * from the parser), then this method is called during the printing
+ * of the final stack trace, and hence the correct error message
+ * gets displayed.
+ */
+ public String getMessage() {
+ if (!specialConstructor) {
+ return super.getMessage();
+ }
+ StringBuffer expected = new StringBuffer();
+ int maxSize = 0;
+ for (int[] expectedTokenSequence : expectedTokenSequences) {
+ if (maxSize < expectedTokenSequence.length) {
+ maxSize = expectedTokenSequence.length;
+ }
+ for (int anExpectedTokenSequence : expectedTokenSequence) {
+ expected.append(tokenImage[anExpectedTokenSequence]).append(" ");
+ }
+ if (expectedTokenSequence[expectedTokenSequence.length - 1] != 0) {
+ expected.append("...");
+ }
+ expected.append(eol).append(" ");
+ }
+ String retval = "Encountered \"";
+ Token tok = currentToken.next;
+ for (int i = 0; i < maxSize; i++) {
+ if (i != 0) retval += " ";
+ if (tok.kind == 0) {
+ retval += tokenImage[0];
+ break;
+ }
+ retval += add_escapes(tok.image);
+ tok = tok.next;
+ }
+ retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn;
+ retval += "." + eol;
+ if (expectedTokenSequences.length == 1) {
+ retval += "Was expecting:" + eol + " ";
+ } else {
+ retval += "Was expecting one of:" + eol + " ";
+ }
+ retval += expected.toString();
+ return retval;
+ }
+
+
+ public int getLine() {
+ return line;
+ }
+
+ public int getColumn() {
+ return column;
+ }
+
+ /** The end of line string for this machine. */
+ protected String eol = System.getProperty("line.separator", "\n");
+
+ /**
+ * Used to convert raw characters to their escaped version
+ * when these raw version cannot be used as part of an ASCII
+ * string literal.
+ *
+ * @param str text to treate
+ * @return the escaped version of text
+ */
+ protected String add_escapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i)) {
+ case 0:
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ }
+ }
+ return retval.toString();
+ }
+
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/ParseException.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/SimpleNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,135 @@
+/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
+
+package jaxx.compiler.parser.java;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+public class SimpleNode implements Node {
+ protected Node parent;
+ protected Node[] children;
+ protected int id;
+ protected JavaParser parser;
+ public Token firstToken;
+ public Token lastToken;
+ private ClassDescriptor javaType;
+
+
+ public SimpleNode(int i) {
+ id = i;
+ }
+
+ public SimpleNode(JavaParser p, int i) {
+ this(i);
+ parser = p;
+ }
+
+
+ public int getId() {
+ return id;
+ }
+
+ public void jjtOpen() {
+ }
+
+ public void jjtClose() {
+ }
+
+ public void jjtSetParent(Node n) {
+ parent = n;
+ }
+
+ public Node jjtGetParent() {
+ return parent;
+ }
+
+ public SimpleNode getParent() {
+ return (SimpleNode) parent;
+ }
+
+
+ public ClassDescriptor getJavaType() {
+ return javaType;
+ }
+
+
+ public void setJavaType(ClassDescriptor javaType) {
+ this.javaType = javaType;
+ }
+
+ public void jjtAddChild(Node n, int i) {
+ if (children == null) {
+ children = new Node[i + 1];
+ } else if (i >= children.length) {
+ Node c[] = new Node[i + 1];
+ System.arraycopy(children, 0, c, 0, children.length);
+ children = c;
+ }
+ children[i] = n;
+ }
+
+ public Node jjtGetChild(int i) {
+ return children[i];
+ }
+
+ public SimpleNode getChild(int i) {
+ return (SimpleNode) children[i];
+ }
+
+ public int jjtGetNumChildren() {
+ return (children == null) ? 0 : children.length;
+ }
+
+ /* You can override these two methods in subclasses of SimpleNode to
+customize the way the node appears when the tree is dumped. If
+your output uses more than one line you should override
+toString(String), otherwise overriding toString() is probably all
+you need to do. */
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getText() + "]";
+ }
+
+ public String toString(String prefix) {
+ return prefix + toString();
+ }
+
+ /* Override this method if you want to customize how the node dumps
+ out its children. */
+
+ public void dump(String prefix) {
+ System.out.println(toString(prefix));
+ if (children != null) {
+ for (Node aChildren : children) {
+ SimpleNode n = (SimpleNode) aChildren;
+ if (n != null) {
+ n.dump(prefix + " ");
+ }
+ }
+ }
+ }
+
+ private void appendSpecialTokens(StringBuffer s, Token st) {
+ if (st != null) {
+ appendSpecialTokens(s, st.specialToken);
+ s.append(st.image);
+ }
+ }
+
+
+ /** @return the text of the tokens comprising this node. */
+ public String getText() {
+ StringBuffer text = new StringBuffer();
+ Token t = firstToken;
+ while (t != null) {
+ appendSpecialTokens(text, t.specialToken);
+ text.append(t.image);
+ if (t == lastToken)
+ break;
+ t = t.next;
+ }
+
+ return text.toString();
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/SimpleNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/Token.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,79 @@
+/* Generated By:JavaCC: Do not edit this line. Token.java Version 3.0 */
+package jaxx.compiler.parser.java;
+
+/** Describes the input token stream. */
+
+public class Token {
+ /**
+ * An integer that describes the kind of this token. This numbering
+ * system is determined by JavaCCParser, and a table of these numbers is
+ * stored in the file ...Constants.java.
+ */
+ public int kind;
+
+ /**
+ * beginLine and beginColumn describe the position of the first character
+ * of this token; endLine and endColumn describe the position of the
+ * last character of this token.
+ */
+ public int beginLine, beginColumn, endLine, endColumn;
+
+ /** The string image of the token. */
+ public String image;
+
+ /**
+ * A reference to the next regular (non-special) token from the input
+ * stream. If this is the last token from the input stream, or if the
+ * token manager has not read tokens beyond this one, this field is
+ * set to null. This is true only if this token is also a regular
+ * token. Otherwise, see below for a description of the contents of
+ * this field.
+ */
+ public Token next;
+
+ /**
+ * This field is used to access special tokens that occur prior to this
+ * token, but after the immediately preceding regular (non-special) token.
+ * If there are no such special tokens, this field is set to null.
+ * When there are more than one such special token, this field refers
+ * to the last of these special tokens, which in turn refers to the next
+ * previous special token through its specialToken field, and so on
+ * until the first special token (whose specialToken field is null).
+ * The next fields of special tokens refer to other special tokens that
+ * immediately follow it (without an intervening regular token). If there
+ * is no such token, this field is null.
+ */
+ public Token specialToken;
+
+ /** Returns the image. */
+ public String toString() {
+ return image;
+ }
+
+ /**
+ * Returns a new Token object, by default. However, if you want, you
+ * can create and return subclass objects based on the value of ofKind.
+ * Simply add the cases to the switch for all those special cases.
+ * For example, if you have a subclass of Token called IDToken that
+ * you want to create if ofKind is ID, simlpy add something like :
+ * <p/>
+ * case MyParserConstants.ID : return new IDToken();
+ * <p/>
+ * to the following switch statement. Then you can cast matchedToken
+ * variable to the appropriate type and use it in your lexical actions.
+ */
+ public static final Token newToken(int ofKind) {
+ switch (ofKind) {
+ default:
+ return new Token();
+ case JavaParserConstants.RUNSIGNEDSHIFT:
+ case JavaParserConstants.RSIGNEDSHIFT:
+ case JavaParserConstants.GT:
+ return new GTToken();
+ }
+ }
+
+ public static class GTToken extends Token {
+ int realKind = JavaParserConstants.GT;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/Token.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/parser/TokenMgrError.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,126 @@
+/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 3.0 */
+package jaxx.compiler.parser.java;
+
+public class TokenMgrError extends Error {
+ /*
+ * Ordinals for various reasons why an Error of this type can be thrown.
+ */
+
+ /** Lexical error occured. */
+ static final int LEXICAL_ERROR = 0;
+
+ /** An attempt wass made to create a second instance of a static token manager. */
+ static final int STATIC_LEXER_ERROR = 1;
+
+ /** Tried to change to an invalid lexical state. */
+ static final int INVALID_LEXICAL_STATE = 2;
+
+ /** Detected (and bailed out of) an infinite loop in the token manager. */
+ static final int LOOP_DETECTED = 3;
+
+ /**
+ * Indicates the reason why the exception is thrown. It will have
+ * one of the above 4 values.
+ */
+ int errorCode;
+ private static final long serialVersionUID = -9131500865453532454L;
+
+ /**
+ * Replaces unprintable characters by their espaced (or unicode escaped)
+ * equivalents in the given string
+ *
+ * @param str text to treate
+ * @return the treated text
+ */
+ protected static String addEscapes(String str) {
+ StringBuffer retval = new StringBuffer();
+ char ch;
+ for (int i = 0; i < str.length(); i++) {
+ switch (str.charAt(i)) {
+ case 0:
+ continue;
+ case '\b':
+ retval.append("\\b");
+ continue;
+ case '\t':
+ retval.append("\\t");
+ continue;
+ case '\n':
+ retval.append("\\n");
+ continue;
+ case '\f':
+ retval.append("\\f");
+ continue;
+ case '\r':
+ retval.append("\\r");
+ continue;
+ case '\"':
+ retval.append("\\\"");
+ continue;
+ case '\'':
+ retval.append("\\\'");
+ continue;
+ case '\\':
+ retval.append("\\\\");
+ continue;
+ default:
+ if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
+ String s = "0000" + Integer.toString(ch, 16);
+ retval.append("\\u").append(s.substring(s.length() - 4, s.length()));
+ } else {
+ retval.append(ch);
+ }
+ }
+ }
+ return retval.toString();
+ }
+
+ /**
+ * @param EOFSeen : indicates if EOF caused the lexicl error
+ * @param lexState : lexical state in which this error occured
+ * @param errorLine : line number when the error occured
+ * @param errorColumn : column number when the error occured
+ * @param errorAfter : prefix that was seen before this error occured
+ * @param curChar : the offending character
+ * Note: You can customize the lexical error message by modifying this method.
+ * @return a detailed message for the Error when it is thrown by the
+ * token manager to indicate a lexical error.
+ */
+ protected static String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
+ return ("Lexical error at line " +
+ errorLine + ", column " +
+ errorColumn + ". Encountered: " +
+ (EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int) curChar + "), ") +
+ "after : \"" + addEscapes(errorAfter) + "\"");
+ }
+
+ /**
+ * You can also modify the body of this method to customize your error messages.
+ * For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
+ * of end-users concern, so you can return something like :
+ * <p/>
+ * "Internal Error : Please file a bug report .... "
+ * <p/>
+ * from this method for such cases in the release version of your parser.
+ */
+ @Override
+ public String getMessage() {
+ return super.getMessage();
+ }
+
+ /*
+ * Constructors of various flavors follow.
+ */
+
+ public TokenMgrError() {
+ }
+
+ public TokenMgrError(String message, int reason) {
+ super(message);
+ errorCode = reason;
+ }
+
+ public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
+ this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/parser/java/TokenMgrError.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/ClassDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,144 @@
+package jaxx.compiler.reflect;
+
+import jaxx.runtime.JAXXObjectDescriptor;
+
+import java.util.Arrays;
+
+/**
+ * Mirrors the class <code>java.lang.Class</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).
+ */
+public abstract class ClassDescriptor {
+
+ private String name;
+ private String packageName;
+ private String superclass;
+ private String[] interfaces;
+ private boolean isInterface;
+ private boolean isArray;
+ private String componentType;
+ private JAXXObjectDescriptor jaxxObjectDescriptor;
+ private ClassLoader classLoader;
+ private MethodDescriptor[] methodDescriptors;
+ private FieldDescriptor[] fieldDescriptors;
+
+ public abstract MethodDescriptor getDeclaredMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException;
+
+ public abstract FieldDescriptor getDeclaredFieldDescriptor(String name) throws NoSuchFieldException;
+
+ ClassDescriptor(String name, String packageName, String superclass, String[] interfaces, boolean isInterface,
+ boolean isArray, String componentType, JAXXObjectDescriptor jaxxObjectDescriptor,
+ ClassLoader classLoader, MethodDescriptor[] methodDescriptors, FieldDescriptor[] fieldDescriptors) {
+ this.name = name;
+ this.packageName = packageName;
+ this.superclass = superclass;
+ this.interfaces = interfaces;
+ this.isInterface = isInterface;
+ this.isArray = isArray;
+ this.componentType = componentType;
+ this.jaxxObjectDescriptor = jaxxObjectDescriptor;
+ this.classLoader = classLoader;
+ this.methodDescriptors = methodDescriptors;
+ this.fieldDescriptors = fieldDescriptors;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getPackageName() {
+ return packageName;
+ }
+
+ public ClassDescriptor getSuperclass() {
+ try {
+ return superclass != null ? ClassDescriptorLoader.getClassDescriptor(superclass, getClassLoader()) : null;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public ClassDescriptor[] getInterfaces() {
+ try {
+ ClassDescriptor[] result = new ClassDescriptor[interfaces.length];
+ for (int i = 0; i < result.length; i++) {
+ result[i] = ClassDescriptorLoader.getClassDescriptor(interfaces[i], getClassLoader());
+ }
+ return result;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public boolean isInterface() {
+ return isInterface;
+ }
+
+ public boolean isArray() {
+ return isArray;
+ }
+
+ public ClassDescriptor getComponentType() {
+ try {
+ return componentType != null ? ClassDescriptorLoader.getClassDescriptor(componentType, getClassLoader()) : null;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public MethodDescriptor[] getMethodDescriptors() {
+ return methodDescriptors;
+ }
+
+ public MethodDescriptor getMethodDescriptor(String name, ClassDescriptor... parameterTypes) throws NoSuchMethodException {
+ for (MethodDescriptor methodDescriptor : methodDescriptors) {
+ if (methodDescriptor.getName().equals(name) && methodDescriptor.getParameterTypes().length == parameterTypes.length && Arrays.equals(methodDescriptor.getParameterTypes(), parameterTypes)) {
+ return methodDescriptor;
+ }
+ }
+ throw new NoSuchMethodException("Could not find method " + name + "(" + Arrays.asList(parameterTypes) + ") in " + getName());
+ }
+
+ public FieldDescriptor[] getFieldDescriptors() {
+ return fieldDescriptors;
+ }
+
+ public FieldDescriptor getFieldDescriptor(String name) throws NoSuchFieldException {
+ for (FieldDescriptor fieldDescriptor : fieldDescriptors) {
+ if (fieldDescriptor.getName().equals(name)) {
+ return fieldDescriptor;
+ }
+ }
+ throw new NoSuchFieldException("Could not find field " + name + " in " + getName());
+ }
+
+ public JAXXObjectDescriptor getJAXXObjectDescriptor() {
+ return jaxxObjectDescriptor;
+ }
+
+ public boolean isAssignableFrom(ClassDescriptor descriptor) {
+ while (descriptor != null) {
+ if (descriptor == this) {
+ return true;
+ }
+ for (ClassDescriptor anInterface : descriptor.getInterfaces()) {
+ if (anInterface == this) {
+ return true;
+ }
+ }
+ descriptor = descriptor.getSuperclass();
+ }
+ return false;
+ }
+
+ @Override
+ public String toString() {
+ return "ClassDescriptor[" + getName() + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/ClassDescriptorLoader.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,426 @@
+package jaxx.compiler.reflect;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.SymbolTable;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXObjectDescriptor;
+
+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).
+ */
+public class ClassDescriptorLoader {
+
+ private static Map<String, ClassDescriptor> descriptors = new HashMap<String, ClassDescriptor>();
+
+ private ClassDescriptorLoader() {
+ }
+
+ public static synchronized ClassDescriptor getClassDescriptor(String className) throws ClassNotFoundException {
+ return getClassDescriptor(className, Thread.currentThread().getContextClassLoader());
+ //return getClassDescriptor(className, ClassDescriptorLoader.class.getClassLoader());
+ }
+
+ public static synchronized ClassDescriptor getClassDescriptor(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ ClassDescriptor result = descriptors.get(className);
+ if (result != null) {
+ return result;
+ }
+
+// if (result == null) {
+ if (JAXXCompilerLaunchor.isRegistred() && JAXXCompilerLaunchor.get().getSymbolTable(className) != null) {
+ result = createClassDescriptorFromSymbolTable(className, classLoader);
+ } else {
+ 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();
+ }
+
+ 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();
+ }
+
+ 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());
+ }
+ }
+
+ if (jaxxLastModified != -1 && JAXXCompilerLaunchor.isRegistred() && JAXXCompilerLaunchor.get().getSymbolTable(className) == 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 (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;
+ }
+
+ public static ClassDescriptor getClassDescriptor(Class<?> javaClass) {
+ try {
+ return getClassDescriptor(javaClass.getName(), javaClass.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public static Class<?> getPrimitiveBoxedClass(String className) throws ClassNotFoundException {
+ 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;
+ }
+
+ public static Class<?> getPrimitiveClass(String className) throws ClassNotFoundException {
+ 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 = null;
+ 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;
+ }
+
+ public static Class<?> getClass(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ 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) || jaxxClass == JAXXObject.class) {
+ return null;
+ }
+ try {
+ Method getJAXXObjectDescriptor = jaxxClass.getMethod("$getJAXXObjectDescriptor", new Class<?>[0]);
+ 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();
+ Reader reader = new InputStreamReader(in, "utf-8");
+ ClassDescriptor result = JavaFileParser.parseJavaFile(javaSource.toString(), reader, classLoader);
+ reader.close();
+ return result;
+ } catch (IOException e) {
+ throw new ClassNotFoundException(e.toString());
+ }
+ }
+
+ private static ClassDescriptor createClassDescriptorFromSymbolTable(String className, ClassLoader classLoader) throws ClassNotFoundException {
+ final JAXXCompiler compiler = JAXXCompilerLaunchor.get().getJAXXCompiler(className);
+ final SymbolTable symbolTable = JAXXCompilerLaunchor.get().getSymbolTable(className);
+ if (symbolTable == null) {
+ throw new CompilerException("Internal error: no symbol table was generated for class '" + className + "'");
+ }
+ 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();
+ }
+ }
+ 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;
+ Set<String> interfaces = new HashSet<String>();
+ 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();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/ClassDescriptorLoader.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/FieldDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,25 @@
+package jaxx.compiler.reflect;
+
+/**
+ * Mirrors the class <code>java.lang.ref.Field</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).
+ */
+public class FieldDescriptor extends MemberDescriptor {
+
+ private String type;
+
+ public FieldDescriptor(String name, int modifiers, String type, ClassLoader classLoader) {
+ super(name, modifiers, classLoader);
+ this.type = type;
+ }
+
+ public ClassDescriptor getType() {
+ try {
+ return ClassDescriptorLoader.getClassDescriptor(type, getClassLoader());
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/FieldDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/JavaFileParser.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,217 @@
+package jaxx.compiler.reflect;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.parser.java.JavaParser;
+import jaxx.compiler.parser.java.JavaParserTreeConstants;
+import jaxx.compiler.parser.java.ParseException;
+import jaxx.compiler.parser.java.SimpleNode;
+import jaxx.compiler.tags.TagManager;
+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.Iterator;
+import java.util.List;
+
+// TODO: need to unify this implementation with the parsing in ScriptManager
+public class JavaFileParser {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(JavaFileParser.class);
+ private JAXXCompiler compiler;
+ private String className;
+ private String packageName = null;
+ private String superclass = "java.lang.Object";
+ private List<MethodDescriptor> methods = new ArrayList<MethodDescriptor>();
+ private List<FieldDescriptor> fields = new ArrayList<FieldDescriptor>();
+
+ private JavaFileParser(ClassLoader classLoader) {
+ compiler = JAXXCompilerLaunchor.createDummyCompiler(classLoader);
+ }
+
+ public static ClassDescriptor parseJavaFile(String displayName, Reader src, ClassLoader classLoader) throws ClassNotFoundException {
+ // 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);
+ }
+
+ List<MethodDescriptor> publicMethods = parser.methods;
+ List<FieldDescriptor> publicFields = parser.fields;
+ //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();
+ }
+ }
+ ClassDescriptor superclassDescriptor = ClassDescriptorLoader.getClassDescriptor(parser.superclass, classLoader);
+ publicMethods.addAll(Arrays.asList(superclassDescriptor.getMethodDescriptors()));
+ publicFields.addAll(Arrays.asList(superclassDescriptor.getFieldDescriptors()));
+ //Set<String> interfaces = new HashSet<String>();
+ //ClassDescriptor[] superclassInterfaces = superclassDescriptor.getInterfaces();
+ //for (ClassDescriptor superclassInterface : superclassInterfaces) {
+ //interfaces.add(superclassInterface.getName());
+ //}
+ return new ClassDescriptor(parser.className, parser.packageName, parser.superclass, new String[0], 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 {
+ 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());
+ }
+ }
+
+ private void scanCompilationUnit(SimpleNode node) {
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode child = node.getChild(i);
+ int nodeType = child.getId();
+ if (nodeType == JavaParserTreeConstants.JJTPACKAGEDECLARATION) {
+ packageName = child.getChild(1).getText().trim();
+ compiler.addImport(packageName + ".*");
+ } else if (nodeType == 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);
+ }
+ compiler.addImport(text);
+ } else if (nodeType == JavaParserTreeConstants.JJTTYPEDECLARATION) {
+ scanCompilationUnit(child);
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEDECLARATION) {
+ scanClass(child);
+ }
+ }
+ }
+
+ // 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.JJTEXTENDSLIST) {
+ if (!isInterface) {
+ 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);
+ }
+ }
+ } else if (nodeType == JavaParserTreeConstants.JJTCLASSORINTERFACEBODY) {
+ scanClassNode(child);
+ }
+ }
+ }
+
+ // 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;
+ int equals = text.indexOf("=");
+ if (equals != -1) {
+ declaration = declaration.substring(0, equals);
+ }
+ declaration = declaration.trim();
+ String[] declarationTokens = declaration.split("\\s");
+ //boolean isFinal = Arrays.asList(declarationTokens).contains("final");
+ //boolean isStatic = Arrays.asList(declarationTokens).contains("static");
+ 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);
+ fields.add(new FieldDescriptor(name, Modifier.PUBLIC, type, compiler.getClassLoader())); // TODO: determine the actual modifiers
+ } else {
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode child = node.getChild(i);
+ scanClassNode(child);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/JavaFileParser.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/MemberDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,37 @@
+package jaxx.compiler.reflect;
+
+/**
+ * Mirrors the class <code>java.lang.ref.Member</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).
+ */
+public abstract class MemberDescriptor {
+
+ private String name;
+ private int modifiers;
+ private ClassLoader classLoader;
+
+ MemberDescriptor(String name, int modifiers, ClassLoader classLoader) {
+ this.name = name;
+ this.modifiers = modifiers;
+ this.classLoader = classLoader;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public int getModifiers() {
+ return modifiers;
+ }
+
+ protected ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getName() + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MemberDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/reflect/MethodDescriptor.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+package jaxx.compiler.reflect;
+
+import jaxx.compiler.JAXXCompiler;
+
+/**
+ * Mirrors the class <code>java.lang.ref.Method</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).
+ */
+public class MethodDescriptor extends MemberDescriptor {
+
+ private String returnType;
+ private String[] parameterTypes;
+
+ public MethodDescriptor(String name, int modifiers, String returnType, String[] parameterTypes, ClassLoader classLoader) {
+ super(name, modifiers, classLoader);
+ this.returnType = returnType;
+ this.parameterTypes = parameterTypes;
+ if (JAXXCompiler.STRICT_CHECKS && java.util.Arrays.asList(parameterTypes).contains(null)) {
+ throw new NullPointerException(name);
+ }
+ }
+
+ public ClassDescriptor getReturnType() {
+ try {
+ //TC 20090228 : fix bug when no return type defined (constructor method)
+ if (returnType == null) {
+ return null;
+ }
+ return ClassDescriptorLoader.getClassDescriptor(returnType);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("could not find return type " + returnType, e);
+ }
+ }
+
+ public ClassDescriptor[] getParameterTypes() {
+ ClassDescriptor[] result = new ClassDescriptor[parameterTypes.length];
+ try {
+ for (int i = 0; i < result.length; i++) {
+ if (parameterTypes[i] != null) {
+ result[i] = ClassDescriptorLoader.getClassDescriptor(parameterTypes[i], getClassLoader());
+ }
+ }
+ return result;
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("could not find the parameter types " + java.util.Arrays.toString(parameterTypes), e);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/reflect/MethodDescriptor.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/DefaultInitializer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,271 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.spi;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import javax.swing.JCheckBox;
+import javax.swing.JCheckBoxMenuItem;
+import javax.swing.JComboBox;
+import javax.swing.JDialog;
+import javax.swing.JEditorPane;
+import javax.swing.JFormattedTextField;
+import javax.swing.JFrame;
+import javax.swing.JInternalFrame;
+import javax.swing.JList;
+import javax.swing.JMenu;
+import javax.swing.JPasswordField;
+import javax.swing.JPopupMenu;
+import javax.swing.JProgressBar;
+import javax.swing.JRadioButton;
+import javax.swing.JRadioButtonMenuItem;
+import javax.swing.JScrollPane;
+import javax.swing.JSlider;
+import javax.swing.JSpinner;
+import javax.swing.JSplitPane;
+import javax.swing.JTabbedPane;
+import javax.swing.JTextArea;
+import javax.swing.JTextField;
+import javax.swing.JTextPane;
+import javax.swing.JToggleButton;
+import javax.swing.JToolBar;
+import javax.swing.JTree;
+import javax.swing.JWindow;
+import javax.swing.KeyStroke;
+import javax.swing.text.JTextComponent;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.beans.BeanInfoUtil;
+
+import jaxx.compiler.decorators.BoxedCompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.decorators.DefaultCompiledObjectDecorator;
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.tags.ScriptHandler;
+import jaxx.compiler.tags.StyleHandler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.TagManager;
+import jaxx.compiler.tags.swing.ApplicationHandler;
+import jaxx.compiler.tags.swing.CellHandler;
+import jaxx.compiler.tags.swing.ItemHandler;
+import jaxx.compiler.tags.swing.JAXXComboBoxHandler;
+import jaxx.compiler.tags.swing.JAXXListHandler;
+import jaxx.compiler.tags.swing.JAXXTabHandler;
+import jaxx.compiler.tags.swing.JAXXTreeHandler;
+import jaxx.compiler.tags.swing.JCheckBoxHandler;
+import jaxx.compiler.tags.swing.JComboBoxHandler;
+import jaxx.compiler.tags.swing.JInternalFrameHandler;
+import jaxx.compiler.tags.swing.JListHandler;
+import jaxx.compiler.tags.swing.JMenuHandler;
+import jaxx.compiler.tags.swing.JPasswordFieldHandler;
+import jaxx.compiler.tags.swing.JPopupMenuHandler;
+import jaxx.compiler.tags.swing.JProgressBarHandler;
+import jaxx.compiler.tags.swing.JRadioButtonHandler;
+import jaxx.compiler.tags.swing.JScrollPaneHandler;
+import jaxx.compiler.tags.swing.JSliderHandler;
+import jaxx.compiler.tags.swing.JSpinnerHandler;
+import jaxx.compiler.tags.swing.JSplitPaneHandler;
+import jaxx.compiler.tags.swing.JTabbedPaneHandler;
+import jaxx.compiler.tags.swing.JTextComponentHandler;
+import jaxx.compiler.tags.swing.JToolBarHandler;
+import jaxx.compiler.tags.swing.JTreeHandler;
+import jaxx.compiler.tags.swing.JWindowHandler;
+import jaxx.compiler.tags.swing.RowHandler;
+import jaxx.compiler.tags.swing.TabHandler;
+import jaxx.compiler.tags.swing.TableHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler;
+import jaxx.compiler.tags.validator.ExcludeFieldValidatorHandler;
+import jaxx.compiler.tags.validator.FieldValidatorHandler;
+
+import jaxx.compiler.types.ColorConverter;
+import jaxx.compiler.types.GridBagConstraintsConverter;
+import jaxx.compiler.types.InsetsConverter;
+import jaxx.compiler.types.KeyStrokeConverter;
+import jaxx.compiler.types.PrimitiveConverter;
+
+import jaxx.compiler.types.TypeConverter;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Application;
+import jaxx.runtime.swing.JAXXButtonGroup;
+import jaxx.runtime.swing.JAXXComboBox;
+import jaxx.runtime.swing.JAXXList;
+import jaxx.runtime.swing.JAXXTab;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.runtime.swing.Table;
+import jaxx.runtime.swing.editor.EnumEditor;
+import jaxx.runtime.swing.editor.LocaleEditor;
+import jaxx.runtime.validator.swing.SwingValidator;
+
+/**
+ * Initializes support provided from JAXX (java, swing and validation).
+ *
+ */
+public class DefaultInitializer implements Initializer {
+
+ @Override
+ public void initialize() {
+
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing");
+
+ registerDefaultNamespace("javax.swing.*",
+ JEditorPane.class,
+ JFormattedTextField.class,
+ JPasswordField.class,
+ JTextArea.class,
+ JTextField.class,
+ JTextPane.class);
+
+
+ //
+ // Register decorators
+ //
+
+ registerDecorator("default", DefaultCompiledObjectDecorator.class);
+ registerDecorator("boxed", BoxedCompiledObjectDecorator.class);
+ registerDecorator("help", HelpRootCompiledObjectDecorator.class);
+
+ //
+ // Register tags
+ //
+
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "script", new ScriptHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "style", new StyleHandler());
+
+ //TC-20091005 why the namespace was on awt ? ButtonGroup is from javax.swing
+ registerTag("javax.swing.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
+
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "tab", new TabHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "row", new RowHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "cell", new CellHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, "item", new ItemHandler());
+
+
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, BeanValidatorHandler.TAG, new BeanValidatorHandler(ClassDescriptorLoader.getClassDescriptor(SwingValidator.class)));
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, FieldValidatorHandler.TAG, new FieldValidatorHandler());
+ registerTag(JAXXCompiler.JAXX_NAMESPACE, ExcludeFieldValidatorHandler.TAG, new FieldValidatorHandler());
+
+
+ //
+ // Register beans
+ //
+
+ registerBean(Object.class, DefaultObjectHandler.class);
+ registerBean(Component.class, DefaultComponentHandler.class);
+
+ // check boxes
+ registerBean(JCheckBox.class, JCheckBoxHandler.class);
+ registerBean(JCheckBoxMenuItem.class, JCheckBoxHandler.class);
+
+ // combo boxes
+ registerBean(JComboBox.class, JComboBoxHandler.class);
+ registerBean(EnumEditor.class, JComboBoxHandler.class);
+ registerBean(LocaleEditor.class, JComboBoxHandler.class);
+ registerBean(JAXXComboBox.class, JAXXComboBoxHandler.class);
+
+ // radio boxes
+ registerBean(JRadioButton.class, JRadioButtonHandler.class);
+ registerBean(JRadioButtonMenuItem.class, JRadioButtonHandler.class);
+ registerBean(JToggleButton.class, JRadioButtonHandler.class);
+
+ // Lists
+ registerBean(JList.class, JListHandler.class);
+ registerBean(JAXXList.class, JAXXListHandler.class);
+
+ // Trees
+ registerBean(JTree.class, JTreeHandler.class);
+ registerBean(JAXXTree.class, JAXXTreeHandler.class);
+
+ // Windows
+ registerBean(JDialog.class, JWindowHandler.class);
+ registerBean(JFrame.class, JWindowHandler.class);
+ registerBean(JWindow.class, JWindowHandler.class);
+
+ registerBean(Application.class, ApplicationHandler.class);
+
+ registerBean(JInternalFrame.class, JInternalFrameHandler.class);
+ registerBean(JMenu.class, JMenuHandler.class);
+ registerBean(JPasswordField.class, JPasswordFieldHandler.class);
+ registerBean(JPopupMenu.class, JPopupMenuHandler.class);
+ registerBean(JProgressBar.class, JProgressBarHandler.class);
+ registerBean(JScrollPane.class, JScrollPaneHandler.class);
+ registerBean(JSlider.class, JSliderHandler.class);
+ registerBean(JSpinner.class, JSpinnerHandler.class);
+ registerBean(JSplitPane.class, JSplitPaneHandler.class);
+ registerBean(JTabbedPane.class, JTabbedPaneHandler.class);
+ registerBean(JTextComponent.class, JTextComponentHandler.class);
+ registerBean(JToolBar.class, JToolBarHandler.class);
+
+ registerBean(Table.class, TableHandler.class);
+ registerBean(JAXXTab.class, JAXXTabHandler.class);
+
+
+ registerBean(SwingValidator.class, BeanValidatorHandler.class);
+
+
+
+ //
+ // Register converters
+ //
+
+ PrimitiveConverter primitiveConverter = new PrimitiveConverter();
+ registerTypeConverter(boolean.class, primitiveConverter);
+ registerTypeConverter(Boolean.class, primitiveConverter);
+ registerTypeConverter(byte.class, primitiveConverter);
+ registerTypeConverter(Byte.class, primitiveConverter);
+ registerTypeConverter(short.class, primitiveConverter);
+ registerTypeConverter(Short.class, primitiveConverter);
+ registerTypeConverter(int.class, primitiveConverter);
+ registerTypeConverter(Integer.class, primitiveConverter);
+ registerTypeConverter(long.class, primitiveConverter);
+ registerTypeConverter(Long.class, primitiveConverter);
+ registerTypeConverter(float.class, primitiveConverter);
+ registerTypeConverter(Float.class, primitiveConverter);
+ registerTypeConverter(double.class, primitiveConverter);
+ registerTypeConverter(Double.class, primitiveConverter);
+ registerTypeConverter(char.class, primitiveConverter);
+ registerTypeConverter(Character.class, primitiveConverter);
+ registerTypeConverter(String.class, primitiveConverter);
+
+ registerTypeConverter(Color.class, new ColorConverter());
+ registerTypeConverter(GridBagConstraints.class, new GridBagConstraintsConverter());
+ registerTypeConverter(Insets.class, new InsetsConverter());
+ registerTypeConverter(KeyStroke.class, new KeyStrokeConverter());
+
+ }
+
+ protected void registerBean(Class<?> beanClass, Class<? extends TagHandler> handlerClass) {
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(beanClass), handlerClass);
+ }
+
+ protected void registerTag(String namespace, String tagName, TagHandler handler) {
+ TagManager.registerTag(namespace, tagName, handler);
+ }
+
+ protected void registerDecorator(String name, Class<? extends CompiledObjectDecorator> decoratorClass) {
+
+ CompiledObjectDecoratorManager.registerDecorator(name, decoratorClass);
+ }
+
+ protected void registerTypeConverter(Class<?> converterType, TypeConverter converter) {
+
+ TypeManager.registerTypeConverter(converterType, converter);
+ }
+
+ protected void registerDefaultNamespace(String namespace, Class<?>... beanClass) {
+
+ for (Class<?> c : beanClass) {
+ TagManager.registerDefaultNamespace(c.getSimpleName(), namespace);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/DefaultInitializer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/spi/Initializer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,17 @@
+package jaxx.compiler.spi;
+
+/**
+ * Performs SPI initialization, typically to register new tags, beans and converter.
+ * <p/>
+ * <b>Note:</b> To load such Initializer, we use the {@link java.util.ServiceLoader} mecanism.
+ *
+ * @see DefaultInitializer
+ */
+public interface Initializer {
+
+ /**
+ * Performs SPI initialization, typically to register new
+ * tags, beans and converter.
+ */
+ void initialize();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/spi/Initializer.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultComponentHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,322 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.event.ComponentListener;
+import java.awt.event.ContainerListener;
+import java.awt.event.FocusListener;
+import java.beans.IntrospectionException;
+import java.io.IOException;
+import java.lang.reflect.Field;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NamedNodeMap;
+
+public class DefaultComponentHandler extends DefaultObjectHandler {
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(DefaultComponentHandler.class);
+ private String containerDelegate;
+
+ public DefaultComponentHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Component.class);
+ }
+
+ @Override
+ protected void init() throws IntrospectionException {
+ if (jaxxBeanInfo == null) {
+ super.init();
+
+ containerDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
+ if (containerDelegate == null && ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass().getSuperclass())) {
+ containerDelegate = ((DefaultComponentHandler) TagManager.getTagHandler(getBeanClass().getSuperclass())).getContainerDelegate();
+ }
+ }
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("hasFocus", FocusListener.class);
+ addProxyEventInfo("isVisible", ComponentListener.class);
+ addProxyEventInfo("getBounds", ComponentListener.class);
+ addProxyEventInfo("getLocation", ComponentListener.class);
+ addProxyEventInfo("getLocationOnScreen", ComponentListener.class);
+ addProxyEventInfo("getSize", ComponentListener.class);
+ addProxyEventInfo("getX", ComponentListener.class);
+ addProxyEventInfo("getY", ComponentListener.class);
+ addProxyEventInfo("getWidth", ComponentListener.class);
+ addProxyEventInfo("getHeight", ComponentListener.class);
+ if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass())) {
+ addProxyEventInfo("getComponentCount", ContainerListener.class);
+ }
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "name", object.getId(), false, compiler);
+ openComponent(object, tag, compiler);
+ }
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileSecondPass(tag, compiler);
+ closeComponent(compiler.getOpenComponent(), tag, compiler);
+ }
+
+ protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ String constraints = tag.getAttribute("constraints");
+ if (constraints != null && constraints.length() > 0) {
+ compiler.openComponent(object, constraints);
+ } else {
+ compiler.openComponent(object);
+ }
+ }
+
+ protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ compiler.closeComponent(object);
+ }
+
+ @Override
+ public boolean isPropertyInherited(String property) throws UnsupportedAttributeException {
+ return property.equals("font") || property.startsWith("font-") || property.equals("foreground") || property.equals("enabled");
+ }
+
+ @Override
+ public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException {
+ if (propertyName.equals("x") || propertyName.equals("y") || propertyName.equals("width") || propertyName.equals("height") ||
+ "font-size".equals(propertyName)) {
+ return ClassDescriptorLoader.getClassDescriptor(Integer.class);
+ }
+ if (propertyName.equals("font-face") || propertyName.equals("font-style") || propertyName.equals("font-weight")) {
+ return ClassDescriptorLoader.getClassDescriptor(String.class);
+ }
+ return super.getPropertyType(object, propertyName, compiler);
+ }
+
+ @Override
+ public String getGetPropertyCode(String id, String name, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals("font-face")) {
+ return id + ".getFont().getFontName()";
+ }
+ if (name.equals("font-size")) {
+ return id + ".getFont().getSize()";
+ }
+ if (name.equals("font-weight")) {
+ return "(" + id + ".getFont().getStyle() & Font.BOLD) != 0 ? \"bold\" : \"normal\"";
+ }
+ if (name.equals("font-style")) {
+ return "(" + id + ".getFont().getStyle() & Font.ITALIC) != 0 ? \"italic\" : \"normal\"";
+ }
+ return super.getGetPropertyCode(id, name, compiler);
+ }
+
+ @Override
+ public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals("x")) {
+ return id + ".setLocation(" + valueCode + ", " + id + ".getY());";
+ }
+ if (name.equals("y")) {
+ return id + ".setLocation(" + id + ".getX(), " + valueCode + ");";
+ }
+ if (name.equals("width")) { // need to optimize case when both width and height are being assigned
+ return "jaxx.runtime.Util.setComponentWidth(" + id + "," + valueCode + ");\n";
+ }
+ if (name.equals("height")) {
+ return "jaxx.runtime.Util.setComponentHeight(" + id + "," + valueCode + ");\n";
+ }
+ if (name.equals("font-face")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(new Font(" + valueCode + ", " + id + ".getFont().getStyle(), " + id + ".getFont().getSize()));";
+ }
+ if (name.equals("font-size")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont((float) " + valueCode + "));";
+ }
+ if (name.equals("font-weight")) {
+ if (valueCode.equals("\"bold\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD));";
+ }
+ if (valueCode.equals("\"normal\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD));";
+ }
+ if (!valueCode.startsWith("\"")) {
+ return "if (" + id + ".getFont() != null) { if ((" + valueCode + ").equals(\"bold\")) " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.BOLD)); else " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.BOLD)); }";
+ }
+ compiler.reportError("font-weight must be either \"normal\" or \"bold\", found " + valueCode);
+ return "";
+ }
+ if (name.equals("font-style")) {
+ if (valueCode.equals("\"italic\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC));";
+ }
+ if (valueCode.equals("\"normal\"")) {
+ return "if (" + id + ".getFont() != null) " + id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC));";
+ }
+ if (!valueCode.startsWith("\"")) {
+ return "if (" + id + ".getFont() != null) { if ((" + valueCode + ").equals(\"italic\")) " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() | Font.ITALIC)); else " +
+ id + ".setFont(" + id + ".getFont().deriveFont(" + id + ".getFont().getStyle() & ~Font.ITALIC)); }";
+ }
+ compiler.reportError("font-style must be either \"normal\" or \"italic\", found " + valueCode);
+ return "";
+ }
+ if (ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass()) && name.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame)
+ String cDelegate = (String) getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("containerDelegate");
+ if (cDelegate != null) {
+ return id + '.' + cDelegate + "().setLayout(" + valueCode + ");";
+ }
+ }
+ // ajout du support i18n
+ if (I18nHelper.isI18nableAttribute(name, compiler)) {
+ valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler);
+ }
+
+ return super.getSetPropertyCode(id, name, valueCode, compiler);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+
+ if (propertyName.startsWith("_")) {
+ // client property
+ if (stringValue.startsWith("{")) {
+ stringValue = stringValue.substring(1, stringValue.length() - 1);
+ }
+ object.addClientProperty(propertyName.substring(1), stringValue);
+ //TC-20090327 rather not generating code here
+ //object.appendAdditionCode(object.getJavaCode() + ".putClientProperty(\"" + propertyName.substring(1) + "\", " + stringValue + ");");
+ return;
+ }
+ if ("icon".equals(propertyName)) {
+ if (!(stringValue.startsWith("{") || stringValue.endsWith("}"))) {
+ // this is a customized icon, add the icon creation code
+ if (compiler.getConfiguration().isUseUIManagerForIcon()) {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".getUIManagerIcon(\"" + stringValue + "\")}";
+ } else {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createImageIcon(\"" + stringValue + "\")}";
+ }
+ }
+ } else if ("actionIcon".equals(propertyName)) {
+ // customized actionIcon property
+ if (stringValue.startsWith("{") && stringValue.endsWith("}")) {
+ // there is a script to define the action icon, this is forbidden
+ compiler.reportError("the actionIcon does not support script, remove braces..., fix the file " + compiler.getOutputClassName());
+ return;
+ }
+ propertyName = "icon";
+ if (compiler.getConfiguration().isUseUIManagerForIcon()) {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".getUIManagerActionIcon(\"" + stringValue + "\")}";
+ } else {
+ stringValue = "{" + jaxx.runtime.Util.class.getName() + ".createActionIcon(\"" + stringValue + "\")}";
+ }
+ }
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+
+ @Override
+ protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) {
+ super.scanAttributesForDependencies(tag, compiler);
+ // check for clientProperty attributes
+ //FIXME make this works,... it seems jaxx compiler does not come here ?
+ //FIXME see the the firstPassHandler in JAXXCompiler ?
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0, max = children.getLength(); i < max; i++) {
+ Attr attr = (Attr) children.item(i);
+ String name = attr.getName();
+ if (!name.startsWith("_")) {
+ continue;
+ }
+ String value = attr.getValue();
+ if (value.startsWith("{")) {
+ compiler.reportWarning(tag, "an clientProperty attribute " + name.substring(1) + " does not required curly value but was : " + value, 0);
+ }
+ }
+
+ }
+
+ /**
+ * Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
+ * example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
+ * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively.
+ * <p/>
+ * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an
+ * int-valued property has a value which is not a valid number. By default, this method looks at the
+ * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>.
+ *
+ * @param key the name of the int-typed property
+ * @param value the non-numeric value that was specified for the property
+ * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid
+ * @throws NumberFormatException if the property is not an enumeration
+ */
+ @Override
+ protected int constantValue(String key, String value) {
+ if ((key.equals("mnemonic") || key.equals("displayedMnemonic"))) {
+ if (value.length() == 1) {
+ return value.charAt(0);
+ }
+ try {
+ Field vk = java.awt.event.KeyEvent.class.getField(value);
+ return (Integer) vk.get(null);
+ } catch (NoSuchFieldException e) {
+ throw new IllegalArgumentException("mnemonics must be either a single character or the name of a field in KeyEvent (found: '" + value + "')");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return super.constantValue(key, value);
+ }
+
+ /**
+ * Returns <code>true</code> if this component can contain other components. For children to be
+ * allowed, the component must be a subclass of <code>Container</code> and its <code>JAXXBeanInfo</code>
+ * must not have the value <code>false</code> for its <code>isContainer</code> value.
+ *
+ * @return <code>true</code> if children are allowed
+ */
+ public boolean isContainer() {
+ boolean container = ClassDescriptorLoader.getClassDescriptor(Container.class).isAssignableFrom(getBeanClass());
+ if (container) {
+ try {
+ init();
+ if (Boolean.FALSE.equals(getJAXXBeanInfo().getJAXXBeanDescriptor().getValue("isContainer"))) {
+ container = false;
+ }
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ return container;
+ }
+
+ public String getContainerDelegate() {
+ try {
+ init();
+ return containerDelegate;
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultComponentHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/DefaultObjectHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,1135 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JavaArgument;
+import jaxx.compiler.JavaMethod;
+import jaxx.compiler.StylesheetHelper;
+import jaxx.compiler.beans.JAXXBeanInfo;
+import jaxx.compiler.beans.JAXXEventSetDescriptor;
+import jaxx.compiler.beans.JAXXIntrospector;
+import jaxx.compiler.beans.JAXXPropertyDescriptor;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.FieldDescriptor;
+import jaxx.compiler.reflect.MethodDescriptor;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.ComponentDescriptor;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.JAXXObjectDescriptor;
+import jaxx.runtime.css.Stylesheet;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyChangeListener;
+import java.io.IOException;
+import java.lang.reflect.Modifier;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+/**
+ * Default handler for class tags. Class tags are tags which represent instances of Java classes,
+ * such as <code><JButton label='Close'/></code>. <code>DefaultObjectHandler</code>
+ * provides support for attributes and events which adhere to JavaBeans naming conventions as
+ * well as basic JAXX features like the <code>id</code> attribute and data binding by means of
+ * curly braces.
+ * <p/>
+ * Throughout this class, the word "member" refers to the name of a field or method (e.g.
+ * <code>"getDocument"</code>) and the word "property" refers to the JavaBeans-style simple
+ * name of a property (e.g. <code>"document"</code>).
+ */
+public class DefaultObjectHandler implements TagHandler {
+
+ /** The class that this handler provides support for. */
+ private ClassDescriptor beanClass;
+ /** The JAXXBeanInfo for the beanClass. */
+ protected JAXXBeanInfo jaxxBeanInfo;
+ /** Maps property names to their respective JAXXPropertyDescriptors. */
+ private Map<String, JAXXPropertyDescriptor> properties;
+ /** Maps event names to their respective JAXXEventSetDescriptors. */
+ private Map<String, JAXXEventSetDescriptor> events;
+ /** Maps property names to their respective ProxyEventInfos. */
+ private Map<String, ProxyEventInfo> eventInfos;
+ /** Maps XML tags to the CompiledObjects created from them. */
+ protected static Map<Element, CompiledObject> objectMap = new WeakHashMap<Element, CompiledObject>();
+
+ /**
+ * Encapsulates information about a "proxy event handler", which is an event handler that
+ * fires PropertyChangeEvents when it is triggered. ProxyEventInfos simplify the data binding
+ * system by allowing all dependencies to fire the same kind of event even if they would
+ * normally throw something else, like <code>DocumentEvent</code>.
+ */
+ private class ProxyEventInfo {
+
+ /** The name of the method or field being proxied, e.g. "getText". */
+ String memberName;
+ /** The "actual" event listener for the property in question, e.g. DocumentListener. */
+ ClassDescriptor listenerClass;
+ /**
+ * In cases where a different object (such as a model) is more directly responsible for
+ * managing the property, this is the name of the property where that object can be
+ * found, e.g. "document" (which is turned into a call to "getDocument()"). This property
+ * is also treated as a dependency of the data binding expression, and any updates to it
+ * (assuming it is bound) will cause the listener to be removed from the old value and
+ * attached to the new value, and the data binding to be processed.
+ */
+ String modelName;
+ /** The name of the method used to add the "native" event listener, e.g. "addDocumentListener". */
+ String addMethod;
+ /** The name of the method used to remove the "native" event listener, e.g. "removeDocumentListener". */
+ String removeMethod;
+ }
+
+ /**
+ * Creates a new <code>DefaultObjectHandler</code> which provides support for the specified class. The
+ * class is not actually introspected until the {@link #compileFirstPass} method is invoked.
+ *
+ * @param beanClass the class which this handler supports
+ */
+ public DefaultObjectHandler(ClassDescriptor beanClass) {
+ this.beanClass = beanClass;
+ }
+
+ /**
+ * Performs introspection on the beanClass and stores the results.
+ *
+ * @throws java.beans.IntrospectionException
+ * TODO
+ */
+ protected void init() throws IntrospectionException {
+ if (jaxxBeanInfo == null) {
+ // perform introspection & cache the results
+ jaxxBeanInfo = getJAXXBeanInfo(beanClass);
+
+ JAXXPropertyDescriptor[] propertiesArray = jaxxBeanInfo.getJAXXPropertyDescriptors();
+ properties = new HashMap<String, JAXXPropertyDescriptor>();
+ for (int i = propertiesArray.length - 1; i >= 0; i--) {
+ properties.put(propertiesArray[i].getName(), propertiesArray[i]);
+ }
+
+ JAXXEventSetDescriptor[] eventsArray = jaxxBeanInfo.getJAXXEventSetDescriptors();
+ events = new HashMap<String, JAXXEventSetDescriptor>();
+ for (int i = eventsArray.length - 1; i >= 0; i--) {
+ MethodDescriptor[] methods = eventsArray[i].getListenerMethods();
+ for (MethodDescriptor method : methods) {
+ events.put(method.getName(), eventsArray[i]);
+ }
+ }
+
+ configureProxyEventInfo();
+ }
+ }
+
+ /**
+ * Returns
+ *
+ * @return the class which this <code>DefaultObjectHandler</code> supports.
+ */
+ public ClassDescriptor getBeanClass() {
+ return beanClass;
+ }
+
+ /**
+ * @return the <code>JAXXBeanInfo</code> for the class which this <code>DefaultObjectHandler</code>
+ * supports.
+ */
+ public JAXXBeanInfo getJAXXBeanInfo() {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ return jaxxBeanInfo;
+ }
+
+ /**
+ * Returns the <code>JAXXBeanInfo</code> for the specified class.
+ *
+ * @param beanClass the bean class for which to retrieve <code>JAXXBeanInfo</code>
+ * @return the class' <code>JAXXBeanInfo</code>
+ * @throws java.beans.IntrospectionException
+ * ?
+ */
+ public static JAXXBeanInfo getJAXXBeanInfo(ClassDescriptor beanClass) throws IntrospectionException {
+ return JAXXIntrospector.getJAXXBeanInfo(beanClass);
+ }
+
+ /**
+ * Returns the type of the named property. This is the return type of the property's <code>get</code> method;
+ * for instance <code>JLabel</code>'s <code>text</code> property is a <code>String</code>.
+ *
+ * @param object the object being compiled
+ * @param propertyName the simple JavaBeans-style name of the property
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the property's type
+ * @throws CompilerException if the type cannot be determined
+ */
+ public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ JAXXPropertyDescriptor property = properties.get(propertyName);
+ if (property != null) {
+ return property.getPropertyType();
+ }
+ throw new UnsupportedAttributeException("property '" + propertyName + "' not found in " + object);
+ }
+
+ /**
+ * @param name ?
+ * @return <code>true</code> if the named member is <i>bound</i> (fires <code>PropertyChangeEvent</code>
+ * when modified). Members are either fields (represented by the simple name of the field) or <code>get/is</code>
+ * methods (represented by the simple name of the method, <b>not</b> the simplified JavaBeans-style name).
+ * Methods which are not actually bound in their native class, but for which proxy events have been
+ * configured (such as <code>JTextField.getText</code>, return <code>true</code>.
+ * @throws UnsupportedAttributeException
+ * ?
+ */
+ public boolean isMemberBound(String name) throws UnsupportedAttributeException {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ if (eventInfos != null && eventInfos.containsKey(name)) {
+ return true;
+ }
+
+ if (name.equals("getClass")) {
+ return false;
+ }
+
+ String propertyName = null;
+ if (name.startsWith("get")) {
+ propertyName = Introspector.decapitalize(name.substring("get".length()));
+ } else if (name.startsWith("is")) {
+ propertyName = Introspector.decapitalize(name.substring("is".length()));
+ }
+ JAXXPropertyDescriptor property = propertyName != null ? properties.get(propertyName) : null;
+ if (property != null) {
+ return property.isBound();
+ }
+ try {
+ FieldDescriptor field = getBeanClass().getFieldDescriptor(name);
+ return Modifier.isFinal(field.getModifiers()); // final fields might as well be considered bound -- they can't be modified anyway
+ } catch (NoSuchFieldException e) {
+ throw new UnsupportedAttributeException("cannot find property '" + name + "' of " + getBeanClass());
+ }
+ }
+
+ private static ClassDescriptor getEventClass(ClassDescriptor listenerClass) {
+ return listenerClass.getMethodDescriptors()[0].getParameterTypes()[0];
+ }
+
+ /**
+ * @param memberName name of the member
+ * @return an array of members on which the given property depends. For
+ * example, the JTextField.getText() member depends upon the getModel()
+ * member. Returns <code>null</code> if there are no dependencies.
+ */
+ public String[] getMemberDependencies(String memberName) {
+ ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null;
+ return eventInfo == null ? null : new String[]{eventInfo.modelName};
+ }
+
+ /**
+ * Returns a snippet of Java code which will cause a <code>PropertyChangeListener</code> to be notified
+ * when the member's value changes. The <code>PropertyChangeListener</code> is provided in the form
+ * of a Java code snippet that evaluates to a listener object.
+ * <p/>
+ * For ordinary bound JavaBeans properties, the Java code returned is a simple call to
+ * <code>addPropertyChangeListener</code>. Fields and methods which do not actually fire
+ * <code>PropertyChangeEvents</code> when they change necessitate more complex code.
+ *
+ * @param objectCode Java code which evaluates to the object to which to add the listener
+ * *@param dataBinding the name of the data binding this listener is a part of
+ * @param dataBinding databinding
+ * @param memberName the name of the field or method to listen to
+ * @param propertyChangeListenerCode Java code which evaluates to a <code>PropertyChangeListener</code>
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return Java code snippet which causes the listener to be added to the object
+ */
+ public String getAddMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) {
+ if ("getClass".equals(memberName)) {
+ return null;
+ }
+
+ ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null;
+ if (eventInfo != null) { // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents
+ StringBuffer result = new StringBuffer();
+ String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode);
+ boolean methodExists = compiler.hasMethod(methodName);
+ ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass);
+ if (!methodExists) {
+ compiler.addMethodToJavaFile(new JavaMethod(Modifier.PUBLIC, "void", methodName,
+ new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null,
+ propertyChangeListenerCode + ".propertyChange(null);"));
+ }
+ String code = objectCode + (eventInfo.modelName != null ? ".get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName) + "()" : "");
+ result.append("$bindingSources.put(\"").append(code).append("\", ").append(code).append(");").append(JAXXCompiler.getLineSeparator());
+ result.append(code).append('.').append(eventInfo.addMethod).append("((").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(") jaxx.runtime.Util.getEventListener(").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));\n");
+ if (eventInfo.modelName != null) {
+ result.append(getAddMemberListenerCode(objectCode, dataBinding, "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName),
+ "jaxx.runtime.Util.getDataBindingUpdateListener(this , \"" + dataBinding + "\")",
+ compiler));
+ }
+ return result.toString();
+ } else {
+ String propertyName = null;
+ if (memberName.startsWith("get")) {
+ propertyName = Introspector.decapitalize(memberName.substring("get".length()));
+ } else if (memberName.startsWith("is")) {
+ propertyName = Introspector.decapitalize(memberName.substring("is".length()));
+ } else {
+ try {
+ getBeanClass().getFieldDescriptor(memberName);
+ propertyName = memberName;
+ } catch (NoSuchFieldException e) {
+ // ignore ?
+ }
+ }
+ if (propertyName != null) {
+ try {
+ // check for property-specific addPropertyChangeListener method
+ getBeanClass().getMethodDescriptor("addPropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class),
+ ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class));
+ return objectCode + ".addPropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n";
+ } catch (NoSuchMethodException e) {
+ // no property-specific method, use general one
+ return objectCode + ".addPropertyChangeListener(" + propertyChangeListenerCode + ");\n";
+ }
+ }
+ return null;
+ }
+ }
+
+ public String getRemoveMemberListenerCode(String objectCode, String dataBinding, String memberName, String propertyChangeListenerCode, JAXXCompiler compiler) {
+ if ("getClass".equals(memberName)) {
+ return null;
+ }
+
+ ProxyEventInfo eventInfo = eventInfos != null ? eventInfos.get(memberName) : null;
+ if (eventInfo != null) { // a "proxied" event is one that doesn't fire PropertyChangeEvent, so we need to convert its native event type into PropertyChangeEvents
+ StringBuffer result = new StringBuffer();
+ String methodName = "$pr" + compiler.getUniqueId(propertyChangeListenerCode);
+ boolean methodExists = compiler.hasMethod(methodName);
+ if (!methodExists) {
+ ClassDescriptor eventClass = getEventClass(eventInfo.listenerClass);
+ compiler.addMethodToJavaFile(new JavaMethod(Modifier.PUBLIC, "void", methodName,
+ new JavaArgument[]{new JavaArgument(JAXXCompiler.getCanonicalName(eventClass), "event")}, null,
+ propertyChangeListenerCode + ".propertyChange(null);"));
+ }
+ try {
+ String modelMemberName = eventInfo.modelName != null ? "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName) : null;
+ String modelClassName = modelMemberName != null ? getBeanClass().getMethodDescriptor(modelMemberName).getReturnType().getName() : JAXXCompiler.getCanonicalName(getBeanClass());
+ String code = objectCode + (eventInfo.modelName != null ? "." + modelMemberName + "()" : "");
+ result.append("((").append(modelClassName).append(") $bindingSources.remove(\"").append(code).append("\")).").append(eventInfo.removeMethod).append("((").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(") jaxx.runtime.Util.getEventListener(").append(JAXXCompiler.getCanonicalName(eventInfo.listenerClass)).append(".class, ").append(compiler.getRootObject().getJavaCode()).append(", ").append(TypeManager.getJavaCode(methodName)).append("));\n");
+ if (eventInfo.modelName != null) {
+ result.append(getRemoveMemberListenerCode(objectCode, dataBinding, "get" + org.apache.commons.lang.StringUtils.capitalize(eventInfo.modelName),
+ "jaxx.runtime.Util.getDataBindingUpdateListener(this, \"" + dataBinding + "\")",
+ compiler));
+ }
+ return result.toString();
+ } catch (NoSuchMethodException e) {
+ throw new CompilerException("Internal error: " + e);
+ }
+ } else {
+ String propertyName = null;
+ if (memberName.startsWith("get")) {
+ propertyName = Introspector.decapitalize(memberName.substring("get".length()));
+ } else if (memberName.startsWith("is")) {
+ propertyName = Introspector.decapitalize(memberName.substring("is".length()));
+ } else {
+ try {
+ getBeanClass().getFieldDescriptor(memberName);
+ propertyName = memberName;
+ } catch (NoSuchFieldException e) {
+ // ignore ?
+ }
+ }
+ if (propertyName != null) {
+ try {
+ // check for property-specific removePropertyChangeListener method
+ getBeanClass().getMethodDescriptor("removePropertyChangeListener", ClassDescriptorLoader.getClassDescriptor(String.class),
+ ClassDescriptorLoader.getClassDescriptor(PropertyChangeListener.class));
+ return objectCode + ".removePropertyChangeListener(\"" + propertyName + "\", " + propertyChangeListenerCode + ");\n";
+ } catch (NoSuchMethodException e) {
+ // no property-specific method, use general one
+ return objectCode + ".removePropertyChangeListener(" + propertyChangeListenerCode + ");\n";
+ }
+ }
+ return null;
+ }
+ }
+
+ /**
+ * Configures the event handling for members which do not fire <code>PropertyChangeEvent</code> when
+ * modified. The default implementation does nothing. Subclasses should override this method to call
+ * <code>addProxyEventInfo</code> for each member which requires special handling.
+ */
+ protected void configureProxyEventInfo() {
+ }
+
+ /**
+ * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
+ * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
+ * not bound property <code>get</code> methods. The proxy event handler will attach the specified kind
+ * of listener to the class and fire a <code>PropertyChangeEvent</code> whenever the listener receives
+ * any kind of event.
+ * <p/>
+ * Even though this method can theoretically be applied to fields (in addition to methods), it would be an
+ * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would
+ * be difficult to have a listener that was always notified when a field value changed.
+ *
+ * @param memberName the name of the field or method being proxied
+ * @param listenerClass the type of listener which receives events when the field or method is updated
+ */
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass) {
+ addProxyEventInfo(memberName, listenerClass, null);
+ }
+
+ /**
+ * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
+ * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
+ * not bound property <code>get</code> methods. This variant attaches a listener to a property of the
+ * object (such as <code>model</code>) and not the object itself, which is useful when there is a model
+ * that is the "real" container of the information. The proxy event handler will attach the specified kind
+ * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire
+ * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event.
+ * <p/>
+ * If the property is itself bound (typically the case with models), any updates to the property's value will
+ * cause the listener to be removed from the old property value and reattached to the new property value,
+ * as well as cause a <code>PropertyChangeEvent</code> to be fired.
+ * <p/>
+ * Even though this method can theoretically be applied to fields (in addition to methods), it would be an
+ * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would
+ * be difficult to have a listener that was always notified when a field value changed.
+ *
+ * @param memberName the name of the field or method being proxied
+ * @param listenerClass the type of listener which receives events when the field or method is updated
+ * @param modelName the JavaBeans-style name of the model property
+ */
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass, String modelName) {
+ String listenerName = listenerClass.getName();
+ listenerName = listenerName.substring(listenerName.lastIndexOf(".") + 1);
+ addProxyEventInfo(memberName, listenerClass, modelName, "add" + listenerName, "remove" + listenerName);
+ }
+
+ // TODO: remove this temporary method, complete switchover to ClassDescriptors
+ public void addProxyEventInfo(String memberName, Class<?> listenerClass,
+ String modelName, String addMethod, String removeMethod) {
+ try {
+ addProxyEventInfo(memberName, ClassDescriptorLoader.getClassDescriptor(listenerClass.getName()), modelName, addMethod, removeMethod);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ /**
+ * Configures a proxy event handler which fires <code>PropertyChangeEvents</code> when a non-bound
+ * member is updated. This is necessary for all fields (which cannot be bound) and for methods that are
+ * not bound property <code>get</code> methods. This variant attaches a listener to a property of the
+ * object (such as <code>model</code>) and not the object itself, which is useful when there is a model
+ * that is the "real" container of the information. The proxy event handler will attach the specified kind
+ * of listener to the property's value (retrieved using the property's <code>get</code> method) and fire
+ * a <code>PropertyChangeEvent</code> whenever the listener receives any kind of event.
+ * <p/>
+ * If the property is itself bound (typically the case with models), any updates to the property's value will
+ * cause the listener to be removed from the old property value and reattached to the new property value,
+ * as well as cause a <code>PropertyChangeEvent</code> to be fired.
+ * <p/>
+ * This variant of <code>addProxyEventInfo</code> allows the names of the methods that add and remove
+ * the event listener to be specified, in cases where the names are not simply <code>add<listenerClassName></code>
+ * and <code>remove<listenerClassName></code>.
+ * <p/>
+ * Even though this method can theoretically be applied to fields (in addition to methods), it would be an
+ * unusual situation in which that would actually work -- as fields cannot fire events when modified, it would
+ * be difficult to have a listener that was always notified when a field value changed.
+ *
+ * @param memberName the name of the field or method being proxied
+ * @param listenerClass the type of listener which receives events when the field or method is updated
+ * @param modelName the JavaBeans-style name of the model property
+ * @param addMethod add method name
+ * @param removeMethod remove method name
+ */
+ public void addProxyEventInfo(String memberName, ClassDescriptor listenerClass,
+ String modelName, String addMethod, String removeMethod) {
+ ProxyEventInfo info = new ProxyEventInfo();
+ info.memberName = memberName;
+ info.listenerClass = listenerClass;
+ info.modelName = modelName;
+ info.addMethod = addMethod;
+ info.removeMethod = removeMethod;
+ if (eventInfos == null) {
+ eventInfos = new HashMap<String, ProxyEventInfo>();
+ }
+ eventInfos.put(memberName, info);
+ }
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ scanAttributesForDependencies(tag, compiler);
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new CompilerException(e);
+ }
+ CompiledObject object = objectMap.get(tag);
+ if (object == null) {
+ throw new IllegalStateException("unable to find CompiledObject associated with tag <" + tag.getTagName() + ">; should have been registered before second pass");
+ }
+ compiler.checkOverride(object);
+ String constructorParams = tag.getAttribute("constructorParams");
+ if (constructorParams != null && constructorParams.length() > 0) {
+ object.setConstructorParams(compiler.getScriptManager().trimScript(constructorParams));
+ }
+
+ setDefaults(object, tag, compiler);
+ setAttributes(object, tag, compiler);
+ if (object.getGenericTypesLength() > 0 && !(object == compiler.getRootObject() || object.isJavaBean())) {
+ // can ony be apply to root object or javaBean object
+ compiler.reportWarning("'genericType' attribute can only be found on root, or a javaBean object tag but was found on tag " + tag);
+ object.setGenericTypes(null);
+ return;
+ }
+ compileChildrenSecondPass(tag, compiler);
+ }
+
+ public void registerCompiledObject(Element tag, JAXXCompiler compiler) {
+ String id = tag.getAttribute("id");
+ if (id == null || id.length() == 0) {
+ id = compiler.getAutoId(getBeanClass());
+ }
+ CompiledObject object = createCompiledObject(id, compiler);
+ objectMap.put(tag, object);
+ String styleClass = tag.getAttribute("styleClass").trim();
+ if (styleClass.length() > 0) {
+ object.setStyleClass(styleClass);
+ }
+ compiler.registerCompiledObject(object);
+ }
+
+ /**
+ * Creates the <code>CompiledObject</code> which will represent the object created by this <code>TagHandler</code>.
+ *
+ * @param id the <code>CompiledObject's</code> ID.
+ * @param compiler compiler to use
+ * @return the <code>CompiledObject</code> to use
+ */
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) {
+ return new CompiledObject(id, getBeanClass(), compiler);
+ }
+
+ /**
+ * Initializes the default settings of the object, prior to setting its attribute values. The default
+ * implementation does nothing.
+ *
+ * @param object the object to initialize
+ * @param tag the tag being compiled
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ }
+
+ /**
+ * @param property property name to test
+ * @return <code>true</code> if the specified property should be inherited by child components when specified
+ * via CSS.
+ * @throws UnsupportedAttributeException
+ * ?
+ */
+ public boolean isPropertyInherited(String property) throws UnsupportedAttributeException {
+ return false;
+ }
+
+ /**
+ * @param name name of event
+ * @return <code>true</code> if the specified name has the form of an event handler attribute
+ * (e.g. "onActionPerformed").
+ */
+ public boolean isEventHandlerName(String name) {
+ return name.length() > 2 && name.startsWith("on") && Character.isUpperCase(name.charAt(2));
+ }
+
+ /**
+ * Scans all attributes for any dependency classes and adds them to the current compilation
+ * set. Called by <code>compileFirstPass()</code> (it is an error to add dependencies after
+ * pass 1 is complete).
+ *
+ * @param tag tag to scan
+ * @param compiler compiler to use
+ */
+ protected void scanAttributesForDependencies(Element tag, JAXXCompiler compiler) {
+ List<Attr> attributes = new ArrayList<Attr>();
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ attributes.add((Attr) children.item(i));
+ }
+ Collections.sort(attributes, getAttributeComparator());
+
+ for (Attr attribute : attributes) {
+ String name = attribute.getName();
+ String value = attribute.getValue();
+ if (name.equals("javaBean")) {
+ //compiler.preprocessScript(value);
+ continue;
+ }
+ if (name.equals("constraints") || isEventHandlerName(name)) {
+ compiler.preprocessScript(value); // adds dependencies as a side effect
+ } else if (name.equals("constructorParams")) {
+ for (String param : value.split("\\s*,\\s*")) {
+ compiler.preprocessScript(param);
+ }
+ } else if (value.startsWith("{") && value.endsWith("}")) {
+ compiler.preprocessScript(value.substring(1, value.length() - 1));
+ }
+ }
+ }
+
+ /**
+ * Processes the attributes of an XML tag. Four kinds of attributes are supported: simple property values (of any
+ * datatype supported by {@link #convertFromString}), data binding expressions (attributes containing curly-brace
+ * pairs), event listeners (attributes starting with 'on', such as 'onActionPerformed'), and JAXX-defined properties
+ * such as 'id'.
+ *
+ * @param object the object to be modified
+ * @param tag the tag from which to pull attributes
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ List<Attr> attributes = new ArrayList<Attr>();
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ attributes.add((Attr) children.item(i));
+ }
+ Collections.sort(attributes, getAttributeComparator());
+
+ for (Attr attribute : attributes) {
+ String name = attribute.getName();
+ String value = attribute.getValue().trim();
+ if (name.equals("id") || name.equals("constraints") || name.equals("constructorParams") || name.equals("styleClass") ||
+ name.startsWith("xmlns") || JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ // ignore, already handled
+ continue;
+ }
+ if (name.equals("javaBean")) {
+ object.setJavaBean(true);
+ if (!value.isEmpty()) {
+ object.setJavaBeanInitCode(value);
+ }
+ continue;
+ }
+ if (name.equals("implements")) {
+ if (object != compiler.getRootObject()) {
+ // can ony be apply to root object
+ compiler.reportError("'implements' attribute can only be found on root tag but was found on tag " + tag);
+ return;
+ }
+ String[] interfaces = value.split(",");
+ compiler.setExtraInterfaces(interfaces);
+ continue;
+ }
+
+ if (name.equals("abstract")) {
+ if (object != compiler.getRootObject()) {
+ // can ony be apply to root object
+ compiler.reportError("'abstract' attribute can only be found on root tag but was found on tag " + tag);
+ return;
+ }
+ compiler.setAbstractClass(true);
+ continue;
+ }
+
+ if (name.equals("genericType")) {
+ //TC-20090313 check after all atributes been processed
+ if (object == compiler.getRootObject()) {
+ compiler.setGenericType(value);
+ } else {
+ object.setGenericTypes(value.split(","));
+ }
+ continue;
+ }
+
+ if (name.equals("superGenericType")) {
+ if (object != compiler.getRootObject()) {
+ // can ony be apply to root object
+ compiler.reportError("'superGenericType' attribute can only be found on root tag but was found on tag " + tag);
+ return;
+ }
+ compiler.setSuperGenericType(value);
+ continue;
+ }
+
+ if (name.equals("decorator")) {
+ if (!value.isEmpty()) {
+ CompiledObjectDecorator decorator = CompiledObjectDecoratorManager.getDecorator(value);
+ object.setDecorator(decorator);
+ }
+ continue;
+ }
+
+ if (isEventHandlerName(name)) {
+ // event handler
+ if (!value.endsWith(";")) {
+ value += ";";
+ }
+ addEventHandler(object, Introspector.decapitalize(name.substring(2)), value, compiler);
+ continue;
+ }
+ // simple property
+ setAttribute(object, name, value, true, compiler);
+ }
+ }
+
+ /**
+ * Returns a <code>Comparator</code> which defines the ordering in which the tag's attributes should be processed. The
+ * default implementation sorts the attributes according to the order defined by the {@link #getAttributeOrdering} method.
+ *
+ * @return a <code>Comparator</code> defining the order of attribute processing
+ */
+ protected Comparator<Attr> getAttributeComparator() {
+ return new Comparator<Attr>() {
+
+ @Override
+ public int compare(Attr a, Attr b) {
+ int aOrder = getAttributeOrdering(a);
+ int bOrder = getAttributeOrdering(b);
+
+ return aOrder - bOrder;
+ }
+ };
+ }
+
+ /**
+ * Returns the priority with which a particular attribute should be processed. Lower numbers should be processed before
+ * higher numbers. This value is used by the {@link #getAttributeComparator} method to define the sort ordering.
+ *
+ * @param attr the attribute to treate
+ * @return the attribute's priority
+ */
+ protected int getAttributeOrdering(Attr attr) {
+ if (attr.getName().equals("displayedMnemonicIndex") || attr.getName().equals("displayedMnemonic") || attr.getName().equals("mnemonic")) {
+ return 1;
+ }
+ return 0;
+ }
+
+ public String getApplyPropertyOrDataBindingCode(CompiledObject object, String propertyName, String stringValue, JAXXCompiler compiler) {
+ ClassDescriptor type = getPropertyType(object, propertyName, compiler);
+ String binding = compiler.processDataBindings(stringValue, type);
+ if (binding != null) {
+ return "";
+ }
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Object value = convertFromString(propertyName, stringValue, typeClass);
+ return getSetPropertyCode(object.getJavaCode(), propertyName, TypeManager.getJavaCode(value), compiler);
+ } catch (NumberFormatException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (IllegalArgumentException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("could not find class " + type.getName());
+ }
+ return "";
+ }
+
+ /**
+ * Set a single property on an object. The value may be either a simple value or contain data binding expressions.
+ * Simple values are first converted to the property's type using {@link #convertFromString}.
+ *
+ * @param object the object on which to set the property
+ * @param propertyName the name of the property to set
+ * @param stringValue the raw string value of the property from the XML
+ * @param inline <code>true</code> if the value was directly specified as an inline class tag attribute, <code>false</code> otherwise (a default value, specified in CSS, etc.)
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+ try {
+ if (ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(object.getObjectClass())) {
+ // check for data binding & remove if found
+ JAXXObjectDescriptor jaxxObjectDescriptor = object.getObjectClass().getJAXXObjectDescriptor();
+ ComponentDescriptor root = jaxxObjectDescriptor.getComponentDescriptors()[0];
+ object.appendInitializationCode(object.getJavaCode() + ".removeDataBinding(" + TypeManager.getJavaCode(root.getId() + "." + propertyName) + ");" + JAXXCompiler.getLineSeparator());
+ }
+ object.addProperty(propertyName, stringValue);
+ ClassDescriptor type = getPropertyType(object, propertyName, compiler);
+ String binding = compiler.processDataBindings(stringValue, type);
+ if (binding != null) {
+ if (inline) {
+ compiler.addInlineStyle(object, propertyName, true);
+ }
+ ClassDescriptor propertyType = getPropertyType(object, propertyName, compiler);
+ if (propertyType != null &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Boolean.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Byte.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Short.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Integer.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Float.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Double.class) &&
+ propertyType != ClassDescriptorLoader.getClassDescriptor(Character.class)) {
+ //binding = "((" + propertyType.getName() + ") " + binding + ")";
+ }
+ if (propertyName.equals("layout")) { // handle containerDelegate (e.g. contentPane on JFrame)
+ // have to set layout early, before children are added
+ object.appendInitializationCode(getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler));
+ }
+ object.registerDataBinding(binding, propertyName, getSetPropertyCode(object.getJavaCode(), propertyName, binding, compiler), compiler);
+ } else { // no bindings, convert from string
+ if (inline) {
+ compiler.addInlineStyle(object, propertyName, false);
+ }
+ try {
+ Class<?> typeClass = type != null ? ClassDescriptorLoader.getClass(type.getName(), type.getClassLoader()) : null;
+ Object value = convertFromString(propertyName, stringValue, typeClass);
+ setProperty(object, propertyName, value, compiler);
+ } catch (NumberFormatException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (IllegalArgumentException e) {
+ compiler.reportError("could not convert literal string '" + stringValue + "' to type " + type.getName());
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("could not find class " + type.getName());
+ }
+ }
+ } catch (UnsupportedAttributeException e) {
+ compiler.reportError("class " + object.getObjectClass().getName() + " does not support attribute '" + propertyName + "'");
+ }
+ }
+
+ public void applyStylesheets(CompiledObject object, JAXXCompiler compiler) {
+ applyStylesheets(object, compiler, null);
+ }
+
+ private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides) {
+ applyStylesheets(object, compiler, overrides, true);
+ }
+
+ private void applyStylesheets(final CompiledObject object, JAXXCompiler compiler, Stylesheet overrides, boolean recurse) {
+ try {
+ Stylesheet stylesheet = compiler.getStylesheet();
+ ClassDescriptor objectClass = object.getObjectClass();
+ if (recurse && ClassDescriptorLoader.getClassDescriptor(JAXXObject.class).isAssignableFrom(objectClass)) {
+ JAXXObjectDescriptor jaxxObjectDescriptor = objectClass.getJAXXObjectDescriptor();
+ ComponentDescriptor[] descriptors = jaxxObjectDescriptor.getComponentDescriptors();
+ for (ComponentDescriptor descriptor : descriptors) {
+ ClassDescriptor classDescriptor = ClassDescriptorLoader.getClassDescriptor(descriptor.getJavaClassName());
+ boolean isRoot = classDescriptor != objectClass;
+ String id = isRoot ? object.getId() + ' ' + descriptor.getId() : "( " + object.getId() + " ) " + descriptor.getId();
+ CompiledObject child = new CompiledObject(id,
+ "((" + JAXXCompiler.getCanonicalName(classDescriptor) + ") " +
+ object.getJavaCode() + ".getObjectById(" + TypeManager.getJavaCode(descriptor.getId()) + "))",
+ classDescriptor,
+ compiler,
+ true);
+ ComponentDescriptor parentDescriptor = descriptor.getParent();
+ CompiledObject currentObject = child;
+ while (parentDescriptor != null) {
+ CompiledObject parent = new CompiledObject("internal", ClassDescriptorLoader.getClassDescriptor(parentDescriptor.getJavaClassName()), compiler);
+ currentObject.setParent(parent);
+ currentObject = parent;
+ parentDescriptor = parentDescriptor.getParent();
+ }
+ currentObject.setParent(object);
+ String styleClass = object.getStyleClass();
+ if (styleClass == null) {
+ styleClass = descriptor.getStyleClass();
+ }
+ child.setStyleClass(styleClass);
+ Stylesheet mergedStylesheet = overrides;
+ Stylesheet childOverrides = jaxxObjectDescriptor.getStylesheet();
+ if (childOverrides != null) {
+ if (mergedStylesheet == null) {
+ mergedStylesheet = childOverrides;
+ } else {
+ mergedStylesheet.add(childOverrides.getRules());
+ }
+ }
+ TagManager.getTagHandler(objectClass).applyStylesheets(child, compiler, mergedStylesheet, isRoot);
+ object.appendInitializationCode(child.getInitializationCode(compiler));
+ }
+ } else if (stylesheet != null) {
+ StylesheetHelper.applyTo(object, compiler, stylesheet, overrides);
+ }
+ } catch (ClassNotFoundException e) {
+ throw new CompilerException(e);
+ } catch (IllegalArgumentException e) {
+ compiler.reportError(e.getMessage());
+ }
+ }
+
+ /**
+ * Adds the necessary Java code to a <code>CompiledObject</code> to add an event listener at runtime.
+ *
+ * @param object the <code>CompiledObject</code> to which the event listener should be added
+ * @param name the name of the event listener, such as <code>"actionPerformed"</code>
+ * @param value the Java code snippet to execute when the event is fired
+ * @param compiler the current <code>JAXXCompiler</code>
+ */
+ public void addEventHandler(CompiledObject object, String name, String value, JAXXCompiler compiler) {
+ JAXXEventSetDescriptor JAXXEventSetDescriptor = events.get(name);
+ if (JAXXEventSetDescriptor != null) {
+ MethodDescriptor[] listenerMethods = JAXXEventSetDescriptor.getListenerMethods();
+ MethodDescriptor listenerMethod = null;
+ for (MethodDescriptor listenerMethod1 : listenerMethods) {
+ if (listenerMethod1.getName().equals(name)) {
+ listenerMethod = listenerMethod1;
+ break;
+ }
+ }
+ if (listenerMethod == null) {
+ throw new RuntimeException("expected to find method '" + name + "' in JAXXEventSetDescriptor.getListenerMethods()");
+ }
+ try {
+ value = compiler.preprocessScript(value);
+ object.addEventHandler(name, JAXXEventSetDescriptor.getAddListenerMethod(), listenerMethod, value, compiler);
+ } catch (CompilerException e) {
+ compiler.reportError("While parsing event handler for '" + name + "': " + e.getMessage());
+ }
+ } else {
+ compiler.reportError("could not find event '" + name + "' for object " + object);
+ }
+ }
+
+ /**
+ * Returns a snippet of Java code which will retrieve an object property at runtime. Typically the code is
+ * just a call to the property's <code>get</code> method, but it can be arbitrarily complex.
+ *
+ * @param javaCode Java code for the object whose property is being retrieved
+ * @param name the name of the property to retrieve
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the snippet
+ * @throws CompilerException if a compilation error occurs
+ */
+ public String getGetPropertyCode(String javaCode, String name, JAXXCompiler compiler) {
+ try {
+ init();
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+
+ JAXXPropertyDescriptor property = properties.get(name);
+ if (property != null) {
+ if (property.getReadMethodDescriptor() != null) {
+ return javaCode + '.' + property.getReadMethodDescriptor().getName() + "()";
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " has no read method");
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
+ }
+
+ /**
+ * Returns a snippet of Java code which will set an object property at runtime. Typically the code is
+ * just a call to the property's <code>set</code> method, but it can be arbitrarily complex.
+ *
+ * @param javaCode Java code for the object whose property is being set
+ * @param name the name of the property to set
+ * @param valueCode Java expression representing the value to set the property to
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the snippet
+ * @throws CompilerException if a compilation error occurs
+ */
+ public String getSetPropertyCode(String javaCode, String name, String valueCode, JAXXCompiler compiler) {
+ JAXXPropertyDescriptor property = properties.get(name);
+ if (property != null) {
+ if (property.getWriteMethodDescriptor() != null) {
+ return javaCode + '.' + property.getWriteMethodDescriptor().getName() + '(' + valueCode + ");";
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' of " + getBeanClass().getName() + " is read-only");
+ }
+ throw new UnsupportedAttributeException("property '" + name + "' could not be found in class " + getBeanClass().getName());
+ }
+
+ /**
+ * Appends Java code to a <code>CompiledObject</code> in order to implement a property assignment.
+ * <code>setProperty</code> is invoked in response to most XML attributes (those which are not more
+ * complicated cases, like data bindings or event handlers).
+ * <p/>
+ * By the time it reaches this method, the <code>value</code> has already been converted from its XML
+ * string representation to the appropriate destination type for the property (i.e. if
+ * <code>JLabel.foreground</code> is being set, <code>value</code> will be a <code>Color</code>).
+ *
+ * @param object the object being modified
+ * @param name the name of the property to set
+ * @param value the value to set the property to
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ */
+ public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) {
+ object.appendInitializationCode(getSetPropertyCode(object.getJavaCodeForProperty(name), name, TypeManager.getJavaCode(value), compiler));
+ }
+
+ /**
+ * Maps string values onto integers, so that int-valued enumeration properties can be specified by strings. For
+ * example, when passed a key of 'alignment', this method should normally map the values 'left', 'center', and
+ * 'right' onto SwingConstants.LEFT, SwingConstants.CENTER, and SwingConstants.RIGHT respectively.
+ * <p/>
+ * You do not normally need to call this method yourself; it is invoked by {@link #convertFromString} when an
+ * int-valued property has a value which is not a valid number. By default, this method looks at the
+ * <code>enumerationValues</code> value of the <code>JAXXPropertyDescriptor</code>.
+ *
+ * @param key the name of the int-typed property
+ * @param value the non-numeric value that was specified for the property
+ * @return the constant integer value
+ * @throws IllegalArgumentException if the property is an enumeration, but the value is not valid
+ * @throws NumberFormatException if the property is not an enumeration
+ */
+ protected int constantValue(String key, String value) {
+ JAXXBeanInfo JAXXBeanInfo = getJAXXBeanInfo();
+ JAXXPropertyDescriptor[] props = JAXXBeanInfo.getJAXXPropertyDescriptors();
+ String lowercaseValue = value.toLowerCase();
+ for (JAXXPropertyDescriptor property : props) {
+ if (property.getName().equals(key)) {
+ Object[] values = (Object[]) property.getValue("enumerationValues");
+ if (values != null) {
+ for (int j = 0; j < values.length - 2; j += 3) {
+ if (((String) values[j]).toLowerCase().equals(lowercaseValue)) {
+ return (Integer) values[j + 1];
+ }
+ }
+
+ StringBuffer message = new StringBuffer("value of '" + key + "' must be one of: [");
+ for (int j = 0; j < values.length - 2; j += 3) {
+ if (j != 0) {
+ message.append(", ");
+ }
+ message.append(((String) values[j]).toLowerCase());
+ }
+ message.append("] (found '").append(value).append("')");
+ throw new IllegalArgumentException(message.toString());
+ }
+ }
+ }
+ throw new NumberFormatException(value);
+ }
+
+ /**
+ * As {@link TypeManager#convertFromString(String, Class)}, except that it additionally supports constant names
+ * for <code>int</code>-valued types.
+ *
+ * @param key the name of the property whose value is being converted
+ * @param value the raw string value of the property as it appears in the XML
+ * @param type the datatype to convert the string into
+ * @return the converted object
+ * @see #constantValue
+ */
+ protected Object convertFromString(String key, String value, Class<?> type) {
+ if (type == null || type == Object.class) {
+ return value;
+ }
+
+ try {
+ return TypeManager.convertFromString(value, type);
+ } catch (NumberFormatException e) {
+ if (type == int.class || type == Integer.class) {
+ return constantValue(key, value);
+ }
+ throw e;
+ }
+ }
+
+ /**
+ * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
+ * for each child tag.
+ *
+ * @param tag the tag whose children to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ }
+ }
+ }
+
+ /**
+ * Compiles the child tags of the current tag. The default implementation invokes {@link #compileChildTagFirstPass}
+ * for each child tag.
+ *
+ * @param tag the tag whose children to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ /**
+ * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
+ * JAXXCompiler.compileFirstPass}.
+ *
+ * @param tag the child tag to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ /**
+ * Compiles a child of the current tag. The default implementation calls {@link JAXXCompiler#compileFirstPass
+ * JAXXCompiler.compileSecondPass}.
+ *
+ * @param tag the child tag to compile
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+
+ @Override
+ public String toString() {
+ return getClass().getName() + "[" + getBeanClass().getName() + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/DefaultObjectHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/ScriptHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringWriter;
+
+/**
+ * Handles the <code><script></code> tag.
+ *
+ * @author Ethan Nicholas
+ */
+public class ScriptHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ File scriptFile = null;
+ NamedNodeMap attributes = tag.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ String name = attribute.getName();
+ String attrValue = attribute.getValue();
+ if (name.equals("source")) {
+ scriptFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar));
+ StringWriter scriptBuffer = new StringWriter();
+ try {
+ FileReader in = new FileReader(scriptFile);
+ char[] readBuffer = new char[2048];
+ int c;
+ while ((c = in.read(readBuffer)) > 0) {
+ scriptBuffer.write(readBuffer, 0, c);
+ }
+ } catch (FileNotFoundException e) {
+ compiler.reportError("script file not found: " + scriptFile);
+ }
+ compiler.registerScript(scriptBuffer.toString(), scriptFile);
+ } else if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ StringBuffer script = new StringBuffer();
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ switch (child.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ compiler.reportError("<script> tag may not contain child elements: " + tag);
+ case Node.TEXT_NODE: // fall through
+ case Node.CDATA_SECTION_NODE:
+ script.append(((Text) child).getData());
+ }
+ }
+
+ String scriptString = script.toString().trim();
+ if (scriptString.length() > 0) {
+ if (scriptFile != null) {
+ compiler.reportError("<script> tag has both a source attribute and an inline script");
+ }
+ compiler.registerScript(script.toString());
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/ScriptHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/StyleHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.parser.css.CSSParser;
+import jaxx.compiler.parser.css.CSSParserConstants;
+import jaxx.compiler.parser.css.CSSParserTreeConstants;
+import jaxx.runtime.css.Rule;
+import jaxx.runtime.css.Selector;
+import jaxx.compiler.parser.css.SimpleNode;
+import jaxx.runtime.css.Stylesheet;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Handles the <code><style></code> tag.
+ *
+ * @author Ethan Nicholas
+ */
+public class StyleHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ boolean source = false;
+ NamedNodeMap attributes = tag.getAttributes();
+ for (int i = 0; i < attributes.getLength(); i++) {
+ Attr attribute = (Attr) attributes.item(i);
+ String name = attribute.getName();
+ String attrValue = attribute.getValue();
+ if (name.equals("source")) {
+ source = true;
+ File styleFile = new File(compiler.getBaseDir(), attrValue.replace('/', File.separatorChar));
+ StringWriter styleBuffer = new StringWriter();
+ try {
+ FileReader in = new FileReader(styleFile);
+ char[] readBuffer = new char[2048];
+ int c;
+ while ((c = in.read(readBuffer)) > 0) {
+ styleBuffer.write(readBuffer, 0, c);
+ }
+ } catch (FileNotFoundException e) {
+ compiler.reportError("stylesheet file not found: " + styleFile);
+ }
+ compiler.getSourceFiles().push(styleFile);
+ compiler.registerStylesheet(processStylesheet(styleBuffer.toString()));
+ compiler.getSourceFiles().pop();
+ } else if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ StringBuffer style = new StringBuffer();
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ switch (child.getNodeType()) {
+ case Node.ELEMENT_NODE:
+ compiler.reportError("<style> tag may not contain child elements: " + tag);
+ case Node.TEXT_NODE: // fall through
+ case Node.CDATA_SECTION_NODE:
+ style.append(((Text) child).getData());
+ }
+ }
+
+ String styleString = style.toString().trim();
+ if (styleString.length() > 0) {
+ if (source) {
+ compiler.reportError("<style> tag has both a source attribute and an inline stylesheet");
+ }
+ compiler.registerStylesheet(processStylesheet(style.toString()));
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ }
+
+ protected Selector processSelector(SimpleNode selector) {
+ if (selector.getId() != CSSParserTreeConstants.JJTSELECTOR) {
+ throw new IllegalArgumentException("argument node is not a Selector");
+ }
+ String javaClassName = null;
+ String styleClass = null;
+ String pseudoClass = null;
+ String id = null;
+
+ for (int i = 0; i < selector.jjtGetNumChildren(); i++) {
+ SimpleNode child = selector.getChild(i);
+ switch (child.getId()) {
+ case CSSParserTreeConstants.JJTJAVACLASS:
+ if (!child.getText().trim().equals("*")) {
+ javaClassName = child.getText();
+ }
+ break;
+ case CSSParserTreeConstants.JJTCLASS:
+ styleClass = child.getText().substring(1);
+ break;
+ case CSSParserTreeConstants.JJTPSEUDOCLASS:
+ pseudoClass = child.getText().substring(1);
+ break;
+ case CSSParserTreeConstants.JJTID:
+ id = child.getText().substring(1);
+ break;
+
+ default:
+ throw new IllegalStateException("unexpected child of Selector node, type=" + child.getId());
+ }
+ }
+
+ return new Selector(javaClassName, styleClass, pseudoClass, id);
+ }
+
+ protected Rule processRule(SimpleNode ruleNode) {
+ if (ruleNode.getId() != CSSParserTreeConstants.JJTRULE) {
+ throw new IllegalArgumentException("argument node is not a Rule");
+ }
+ SimpleNode selectorsNode = ruleNode.getChild(0);
+ assert selectorsNode.getId() == CSSParserTreeConstants.JJTSELECTORS : "expected node to be of type Selectors";
+
+ List<Selector> selectors = new ArrayList<Selector>();
+ for (int i = 0; i < selectorsNode.jjtGetNumChildren(); i++) {
+ SimpleNode selectorNode = selectorsNode.getChild(i);
+ selectors.add(processSelector(selectorNode));
+ }
+
+ Map<String, String> properties = new HashMap<String, String>();
+ for (int i = 1; i < ruleNode.jjtGetNumChildren(); i++) {
+ SimpleNode declarationNode = ruleNode.getChild(i);
+ if (declarationNode.getId() == CSSParserTreeConstants.JJTDECLARATION) {
+ String key = declarationNode.getChild(0).getText();
+ SimpleNode valueNode = declarationNode.getChild(1);
+ String value = valueNode.getText();
+ if (valueNode.firstToken.kind == CSSParserConstants.STRING) {
+ value = value.substring(1, value.length() - 1);
+ }
+ properties.put(key, value);
+ }
+ }
+ Rule rule;
+ rule = new Rule(selectors.toArray(new Selector[selectors.size()]), properties);
+ return rule;
+ }
+
+ protected Stylesheet processStylesheet(String stylesheetText) throws CompilerException {
+ CSSParser p = new CSSParser(new StringReader(stylesheetText));
+ SimpleNode node;
+ try {
+ node = p.Stylesheet();
+ } catch (Error e) {
+ throw new CompilerException(e);
+ }
+ List<Rule> rules = new ArrayList<Rule>();
+ for (int i = 0; i < node.jjtGetNumChildren(); i++) {
+ SimpleNode ruleNode = node.getChild(i);
+ Rule rule = processRule(ruleNode);
+ rules.add(rule);
+ }
+ Stylesheet stylesheet;
+ stylesheet = new Stylesheet(rules.toArray(new Rule[rules.size()]));
+ return stylesheet;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/StyleHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+/**
+ * Implementations of <code>TagHandler</code> produce Java source code from XML tags.
+ * <code>TagHandlers</code> are mapped to particular XML tags (such as <JFrame>) in {@link JAXXCompiler}.
+ * There is only one <code>TagHandler</code> for any given XML tag, and therefore implementations must be
+ * stateless.
+ *
+ * @author Ethan Nicholas
+ */
+public interface TagHandler {
+
+ /**
+ * Performs the first pass of compilation on an XML tag from a JAXX source file.
+ * <code>TagHandler</code> implementations affect the generated <code>.java</code>
+ * file by calling methods in the <code>JAXXCompiler</code>.
+ *
+ * @param tag the XML tag to compile
+ * @param compiler the active JAXXCompiler
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException;
+
+ /**
+ * Performs the second pass of compilation on an XML tag from a JAXX source file.
+ * <code>TagHandler</code> implementations affect the generated <code>.java</code>
+ * file by calling methods in the <code>JAXXCompiler</code>.
+ *
+ * @param tag the XML tag to compile
+ * @param compiler the active JAXXCompiler
+ * @throws CompilerException if a compilation error occurs
+ * @throws IOException if an I/O error occurs
+ */
+ void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException;
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/TagManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,461 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags;
+
+import jaxx.compiler.*;
+import jaxx.compiler.decorators.CompiledObjectDecoratorManager;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.io.IOException;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Set;
+
+/** Manages TagHandlers, including automatically compiling .jaxx files corresponding to class tags. */
+public class TagManager {
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(TagManager.class);
+ /**
+ * Namespace for JAXX's non-class tags, such as <script;>. The namespace normally does not
+ * need to be specified but can be used to resolve ambiguities.
+ */
+ public static final String JAXX_NAMESPACE = "http://www.jaxxframework.org/";
+ /** Maps simple tag names to their default namespaces (package names). */
+ private static Map<String, String> defaultNamespaces = new HashMap<String, String>();
+ /** Maps qualified tag names to the TagHandlers responsible for processing them. */
+ private static Map<QName, TagHandler> registeredTags = new HashMap<QName, TagHandler>();
+ /** Keeps track of whether or not named classes exist. */
+ private static Map<String, Boolean> classExistenceCache = new HashMap<String, Boolean>();
+ /**
+ * Maps bean classes to their TagHandler classes. The mapping is to TagHandler classes, rather than to
+ * TagHandler instances, because subclasses of the bean class should be handled by the same TagHandler
+ * (assuming no more specific mappings exist), which requires creating a new instance of the TagHandler.
+ */
+ private static ClassMap<Class<? extends TagHandler>> registeredBeans = new ClassMap<Class<? extends TagHandler>>();
+
+ // still targeting 1.4, so I can't use javax.xml.namespace.QName
+ private static class QName {
+
+ private String namespaceURI;
+ private String localPart;
+
+ public QName(String namespaceURI, String localPart) {
+ if (localPart == null) {
+ throw new NullPointerException();
+ }
+ this.namespaceURI = namespaceURI;
+ this.localPart = localPart;
+ }
+
+ public String getNamespaceURI() {
+ return namespaceURI;
+ }
+
+ public String getLocalPart() {
+ return localPart;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (o == null || !(o instanceof QName)) {
+ return false;
+ }
+ QName qname = (QName) o;
+ return qname.getNamespaceURI().equals(getNamespaceURI()) && qname.getLocalPart().equals(getLocalPart());
+ }
+
+ @Override
+ public int hashCode() {
+ return (namespaceURI != null ? namespaceURI.hashCode() : 0) ^ getLocalPart().hashCode();
+ }
+ }
+
+ private TagManager() { /* not instantiable */ }
+
+ public static void reset(boolean verbose) throws IOException, ClassNotFoundException, InstantiationException, IllegalAccessException {
+ registeredBeans.clear();
+ registeredTags.clear();
+ defaultNamespaces.clear();
+ CompiledObjectDecoratorManager.reset();
+ JAXXCompilerLaunchor.loadLibraries(verbose);
+ }
+
+ /**
+ * Maps a class tag to a specific <code>TagHandler</code>. When a tag representing the bean class is
+ * encountered (either the class' simple name, if it is unambiguous, or its fully-qualified name), the specified
+ * <code>TagHandler</code> will be invoked to compile it.
+ *
+ * @param <T>
+ * @param beanClass the class to associate with a <code>TagHandler</code>
+ * @param handler the <code>TagHandler</code> class, which must descend from <code>DefaultObjectHandler</code>
+ * @throws IllegalArgumentException if the handler class does not descend from <code>DefaultObjectHandler</code>
+ */
+ public static <T extends TagHandler> void registerBean(ClassDescriptor beanClass, Class<T> handler) {
+ if (!DefaultObjectHandler.class.isAssignableFrom(handler)) {
+ throw new IllegalArgumentException("handler class must be a subclass of DefaultObjectHandler");
+ }
+ registeredBeans.put(beanClass, handler);
+ if (log.isDebugEnabled()) {
+ log.debug(beanClass + " : " + handler);
+ }
+ String name = beanClass.getName();
+ int dotPos = name.lastIndexOf(".");
+ String namespace = name.substring(0, dotPos + 1) + "*";
+ name = name.substring(dotPos + 1);
+ registerDefaultNamespace(name, namespace);
+ }
+
+ /**
+ * Sets the default namespace for a tag. When the tag is encountered with no namespace specified,
+ * the specified namespace will be assumed. Mapping the same tag to two or more default namespaces
+ * removes the mapping and marks the entry as being ambiguous (by putting a <code>null</code>
+ * value into the map); this causes an error to be thrown if the tag is used without a namespace being
+ * specified.
+ * <p/>
+ * Java package names on tags are automatically converted into namespaces (e.g. <javax.swing.JButton/>
+ * and <JButton xmlns="javax.swing.*"/> are equivalent), so tags with package names are considered
+ * to have namespaces specified.
+ *
+ * @param tag tag name
+ * @param namespace namespace
+ */
+ public static void registerDefaultNamespace(String tag, String namespace) {
+ if (defaultNamespaces.containsKey(tag) && !defaultNamespaces.get(tag).equals(namespace)) {
+ defaultNamespaces.put(tag, null); // tag name is now ambiguous
+ } else {
+ defaultNamespaces.put(tag, namespace);
+ }
+ }
+
+ /**
+ * Registers a <code>TagHandler</code> for a tag. When a tag with the given name and namespace
+ * is encountered, the <code>TagHandler's compileFirstPass</code> and <code>compileSecondPass</code>
+ * methods will be invoked to handle it.
+ * <p/>
+ * It is not an error to register an already-registered tag and namespace combination. The new mapping
+ * will replace the old mapping.
+ *
+ * @param <T>
+ * @param namespace the tag's namespace
+ * @param tag the simple name of the tag
+ * @param handler the <code>TagHandler</code> which should process the tag
+ */
+ public static <T extends TagHandler> void registerTag(String namespace, String tag, T handler) {
+ if (namespace == null) {
+ namespace = "*";
+ }
+ //System.out.println("registerTag "+namespace+" : "+tag+" : "+handler);
+ if (log.isDebugEnabled()) {
+ log.debug(tag + " : " + handler);
+ }
+ registeredTags.put(new QName(namespace, tag), handler);
+ registerDefaultNamespace(tag, namespace);
+ }
+
+ /**
+ * Returns the <code>TagHandler</code> that should be used to process the specified tag.
+ * If the tag represents the class name of an uncompiled <code>.jaxx</code> file, the
+ * <code>.jaxx</code> is first compiled.
+ *
+ * @param namespace the tag's namespace (may be <code>null</code>)
+ * @param tag the tag's simple name
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the <code>TagHandler</code> for the tag
+ * @throws CompilerException ?
+ */
+ public static TagHandler getTagHandler(String namespace, String tag, JAXXCompiler compiler) throws CompilerException {
+ return getTagHandler(namespace, tag, false, compiler);
+ }
+
+ private static String getNamespace(ClassDescriptor beanClass) {
+ String packageName = beanClass.getPackageName();
+ return packageName != null ? packageName + ".*" : "*";
+
+ }
+
+ private static String getSimpleName(ClassDescriptor beanClass) {
+ String packageName = beanClass.getPackageName();
+ if (packageName != null) {
+ assert beanClass.getName().startsWith(packageName);
+ return beanClass.getName().substring(packageName.length() + 1);
+ }
+ return beanClass.getName();
+ }
+
+ /**
+ * @param beanClass the tag class
+ * @return the <code>TagHandler</code> that should be used to process the specified class.
+ * Only <code>TagHandlers</code> previously registered with <code>registerBean</code>
+ * are considered.
+ * @throws CompilerException ?
+ */
+ public static DefaultObjectHandler getTagHandler(ClassDescriptor beanClass) throws CompilerException {
+ try {
+ if (beanClass == null) {
+ throw new NullPointerException();
+ }
+ String namespace = getNamespace(beanClass);
+ String tag = getSimpleName(beanClass);
+ DefaultObjectHandler handler = (DefaultObjectHandler) registeredTags.get(new QName(namespace, tag));
+ if (handler == null) {
+ Class<? extends TagHandler> handlerClass = registeredBeans.get(beanClass);
+ if (handlerClass == null) {
+ throw new CompilerException("unable to find handler for " + beanClass);
+ }
+ Constructor<? extends TagHandler> constructor = handlerClass.getConstructor(ClassDescriptor.class);
+ handler = (DefaultObjectHandler) constructor.newInstance(beanClass);
+ registerTag(namespace, tag, handler);
+ }
+ return handler;
+ } catch (InstantiationException e) {
+ throw new RuntimeException(e);
+ } catch (NoSuchMethodException e) {
+ throw new RuntimeException(e);
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ } catch (InvocationTargetException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private static boolean classExists(String className, JAXXCompiler compiler) {
+ if (classExistenceCache.containsKey(className)) {
+ return classExistenceCache.get(className);
+ }
+
+ boolean found = false;
+ try {
+ Class.forName(className, true, compiler.getClassLoader());
+ found = true;
+ } catch (ClassNotFoundException e) {
+ // ignore ?
+ } catch (NoClassDefFoundError e) { // we get this instead of ClassNotFoundException on case-insensitive file systems when
+ // looking up a class with the wrong case
+ }
+
+ if (!found) { // couldn't find .class, check for .java
+ URL javaURL = compiler.getClassLoader().getResource(className.replace('.', '/') + ".java");
+ found = javaURL != null;
+ }
+
+ if (!found) { // couldn't find .java, check for .jaxx
+ URL jaxxURL = compiler.getClassLoader().getResource(className.replace('.', '/') + ".jaxx");
+ found = jaxxURL != null;
+ }
+
+ classExistenceCache.put(className, found);
+
+ return found;
+ }
+
+ private static String determinePackage(String simpleClassName, String defaultPackage, JAXXCompiler compiler) {
+ String namespace = null;
+ Set<String> classes = compiler.getImportedClasses();
+ for (String className : classes) { // search class imports (e.g. import java.util.Date;)
+ if (className.equals(simpleClassName) || className.endsWith("." + simpleClassName)) {
+ namespace = className.substring(0, className.lastIndexOf(".") + 1) + "*";
+ }
+ }
+ if (namespace == null) { // search package imports (e.g. import java.util.*;)
+ Set<String> searchList = compiler.getImportedPackages();
+ if (defaultPackage != null) {
+ if (!defaultPackage.endsWith("*")) {
+ throw new IllegalArgumentException("defaultPackage must end in '*', found '" + defaultPackage + "'");
+ }
+ if (classExists(defaultPackage.substring(0, defaultPackage.length() - 1) + simpleClassName, compiler)) {
+ return defaultPackage;
+ }
+ }
+ for (String currentPackage : searchList) {
+ String className = currentPackage + simpleClassName;
+ if (classExists(className, compiler)) {
+ if (namespace != null) { // we've already found the same name in another package
+ compiler.reportError("symbol '" + simpleClassName + "' is ambiguous, found matching classes " + namespace.substring(0, namespace.length() - 1) + simpleClassName + " and " + currentPackage + simpleClassName + ". Use fully-qualified name to disambiguate.");
+ return null;
+ }
+ namespace = currentPackage + "*";
+ }
+ }
+ }
+
+ return namespace;
+ }
+
+ /**
+ * Returns the <code>TagHandler</code> that should be used to process the specified tag.
+ * <p/>
+ * The <code>namespacePrefix</code> parameter is used only for error checking, as it is an
+ * error to specify conflicting package names using both a fully-qualified tag name and a
+ * namespace prefix, but it is not an error to specify conflicting package names using a
+ * fully-qualified tag name and a <i>default</i> namespace (i.e. <awt:javax.swing.JButton xmlns:awt='java.awt.*'/>
+ * is an error, whereas <javax.swing.JButton xmlns='java.awt.*'/> is not).
+ *
+ * @param namespace the tag's namespace (may be <code>null</code>)
+ * @param tag the tag's simple name (which can include fully-qualified Java class names)
+ * @param namespacePrefix <code>true</code> if the namespace was specified by means of a namespace prefix (as opposed to a default namespace)
+ * @param compiler the current <code>JAXXCompiler</code>
+ * @return the <code>TagHandler</code> for the tag
+ * @throws CompilerException ?
+ */
+ public static TagHandler getTagHandler(String namespace, String tag, boolean namespacePrefix, JAXXCompiler compiler) throws CompilerException {
+ if (tag == null) {
+ throw new NullPointerException();
+ }
+ if (namespace == null && defaultNamespaces.containsKey(tag)) {
+ namespace = defaultNamespaces.get(tag);
+ if (namespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity
+ compiler.reportError("tag '" + tag + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate");
+ return null;
+ }
+ }
+
+ TagHandler handler = registeredTags.get(new QName(namespace, tag));
+ if (handler == null) {
+ if (namespace == null || namespace.endsWith("*")) {
+ String className;
+ if (namespace != null) {
+ className = resolveClassName(namespace.substring(0, namespace.length() - 1) + tag, compiler);
+ if (className == null) {
+ className = resolveClassName(tag, compiler);
+ if (namespacePrefix && !className.startsWith(namespace.substring(0, namespace.length() - 1))) {
+ className = null; // namespace was specified, but we found it in a different package - ignore
+ }
+ }
+ } else {
+ className = resolveClassName(tag, compiler);
+ }
+ if (className != null) {
+ int dotPos = className.lastIndexOf(".");
+ namespace = className.substring(0, dotPos + 1) + "*";
+ tag = className.substring(dotPos + 1);
+ handler = registeredTags.get(new QName(namespace, tag));
+ if (handler == null) {
+ try {
+ handler = getTagHandler(ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader()));
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ }
+ }
+ }
+ }
+ }
+ return handler;
+ }
+
+ /**
+ * Resolves a simple class name (like <code>Object</code> or <code>String</code>) to its fully-qualified name. Inner
+ * classes should be represented as they would appear in Java source code (e.g. JPopupMenu.Separator). Fully-qualified names,
+ * such as <code>java.lang.Object</code> are legal and will be returned unmodified (and in fact it is generally impossible to
+ * even know whether a given reference is fully qualified until it has been resolved). Returns <code>null</code> if no matching
+ * class could be found.
+ *
+ * @param name name to resolve
+ * @param compiler compile to use
+ * @return the resolved fqn class name
+ */
+ public static String resolveClassName(String name, JAXXCompiler compiler) {
+ if (name.endsWith("[]")) {
+ return resolveClassName(name.substring(0, name.length() - 2), compiler) + "[]";
+ }
+ if (name.indexOf("<") != -1) {
+ name = name.substring(0, name.indexOf("<")); // strip off generic types
+ }
+
+ name = name.intern();
+ if (name.equals("boolean") || name.equals("byte") || name.equals("short") || name.equals("int") ||
+ name.equals("long") || name.equals("float") || name.equals("double") || name.equals("char")) {
+ return name;
+ }
+
+ String result = null;
+ String originalName = name;
+ String defaultNamespace = null;
+ if (defaultNamespaces.containsKey(name)) {
+ defaultNamespace = defaultNamespaces.get(name);
+ if (defaultNamespace == null) { // defaultNamespaces map contains a null value, which is put there to indicate ambiguity
+ compiler.reportError("class '" + name + "' is ambiguous; specify fully-qualified name (package and class) to disambiguate");
+ return null;
+ }
+ }
+ if (defaultNamespace != null && defaultNamespace.endsWith("*")) {
+ result = defaultNamespace.substring(0, defaultNamespace.length() - 1) + name;
+ }
+
+ if (result == null) {
+ // Inner class names (like JPopupMenu.Separator) present a special challenge. The name before the dot might be
+ // a package name, or it might be a class name. If it's a class name, it might be fully qualified, or it might
+ // not. And it's also not actually the correct name of the class, as far as the JVM is concerned -- the correct
+ // name uses a dollar sign instead of a dot (javax.swing.JPopupMenu$Separator). And there could be more than
+ // one inner class -- it's possible to have com.mycompany.Outer$Inner$Innerer$Innerest.
+ //
+ // The basic strategy is to start by treating the part before the last dot as a package name, as that is by far
+ // the most likely case. If we don't find the class there, change the last dot to a dollar sign and try again.
+ // Suppose we have the tag <com.mycompany.Outer.Inner.Innerer.Innerest/>, matching the class above. Resolution
+ // proceeds like this:
+ // com.mycompany.Outer.Inner.Innerer.* : Innerest
+ // com.mycompany.Outer.Inner.* : Innerer$Innerest
+ // com.mycompany.Outer.* : Inner$Innerer$Innerest
+ // com.mycompany.* : Outer$Inner$Innerer$Innerest
+ // And at this point we have a match with the class Outer$Inner$Innerer$Innerest in package com.mycompany.
+ int dotPos = originalName.lastIndexOf('.');
+ for (;;) {
+ String namespace = dotPos != -1 ? originalName.substring(0, dotPos) + ".*" : "*";
+ name = originalName.substring(dotPos + 1).replace('.', '$');
+ String packageName = determinePackage(name, namespace, compiler);
+ if (packageName != null) {
+ assert packageName.endsWith("*");
+ if (packageName.equals(namespace) || namespace.equals("*")) {
+ // check for an alias (like javax.swing.JComboBox actually being jaxx.runtime.swing.JAXXComboBox)
+ TagHandler handler = registeredTags.get(new QName(namespace, name));
+ if (handler != null) { // determine alias by looking at handler
+ ClassDescriptor alias = ((DefaultObjectHandler) handler).getBeanClass();
+ // make sure the same handler is used for both the aliased and non-aliased names, in order to avoid "no CompiledObject has been registered" error
+ // the line below doesn't bother to handle the case where the aliased class name doesn't have a package, since it's a pretty safe assumption that
+ // that will never happen
+ assert alias.getPackageName() != null && alias.getPackageName().length() > 0 : "aliasing with no package name has not been implemented";
+ registeredTags.put(new QName(alias.getPackageName() + ".*", alias.getName().substring(alias.getPackageName().length() + 1)), handler);
+ result = alias.getName();
+ break;
+ } else { // no alias
+ result = packageName.substring(0, packageName.length() - 1) + name;
+ break;
+ }
+ }
+ // else we found a class by the same name, but in the wrong package
+ }
+
+ if (dotPos <= 0) {
+ break;
+ }
+ dotPos = originalName.lastIndexOf('.', dotPos - 1);
+ }
+ }
+
+ if (result != null && !result.equals(originalName)) {
+ result = resolveClassName(result, compiler); // check for aliases against the new name as well
+ }
+
+ return result;
+ }
+
+ public static ClassDescriptor resolveClass(String className, JAXXCompiler compiler) {
+ try {
+ className = resolveClassName(className, compiler);
+ if (className == null) {
+ return null;
+ }
+ return ClassDescriptorLoader.getClassDescriptor(className, compiler.getClassLoader());
+ } catch (ClassNotFoundException e) {
+ return null;
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/TagManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ApplicationHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ApplicationHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Application;
+import jaxx.compiler.types.TypeManager;
+import org.w3c.dom.Element;
+
+import javax.swing.WindowConstants;
+
+public class ApplicationHandler extends JWindowHandler {
+
+ public ApplicationHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Application.class);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException {
+ if (propertyName.equals("lookAndFeel") && stringValue != null && !stringValue.trim().startsWith("{")) {
+ compiler.appendBodyCode("{ " + object.getJavaCode() + ".setLookAndFeel(" + TypeManager.getJavaCode(stringValue) + "); }" + JAXXCompiler.getLineSeparator());
+ } else {
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.EXIT_ON_CLOSE), false, compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/CellHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CellHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,150 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.types.TypeManager;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.io.IOException;
+
+public class CellHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ Node parent = tag.getParentNode();
+ if (parent.getNodeType() != Node.ELEMENT_NODE || !parent.getLocalName().equals("row")) {
+ compiler.reportError("cell tag may only appear within row tag");
+ return;
+ }
+
+ TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent();
+ table.newCell();
+ GridBagConstraints c = table.getCellConstraints();
+ setAttributes(c, tag);
+ compileChildrenSecondPass(tag, compiler);
+ }
+
+ public static void setAttribute(GridBagConstraints c, String name, String value) throws CompilerException {
+ value = value.trim();
+ if (name.equals("insets")) {
+ c.insets = (Insets) TypeManager.convertFromString(value, Insets.class);
+ } else if (name.equals("weightx")) {
+ c.weightx = Double.parseDouble(value);
+ } else if (name.equals("weighty")) {
+ c.weighty = Double.parseDouble(value);
+ } else if (name.equals("columns")) {
+ c.gridwidth = Integer.parseInt(value);
+ } else if (name.equals("rows")) {
+ c.gridheight = Integer.parseInt(value);
+ } else if (name.equals("fill")) {
+ if (value.equals("none")) {
+ c.fill = GridBagConstraints.NONE;
+ } else if (value.equals("horizontal")) {
+ c.fill = GridBagConstraints.HORIZONTAL;
+ } else if (value.equals("vertical")) {
+ c.fill = GridBagConstraints.VERTICAL;
+ } else if (value.equals("both")) {
+ c.fill = GridBagConstraints.BOTH;
+ } else {
+ throw new IllegalArgumentException("invalid value for fill attribute: '" + value + "'");
+ }
+ } else if (name.equals("anchor")) {
+ //todo use a converter
+ if (value.equals("north")) {
+ c.anchor = GridBagConstraints.NORTH;
+ } else if (value.equals("northeast")) {
+ c.anchor = GridBagConstraints.NORTHEAST;
+ } else if (value.equals("east")) {
+ c.anchor = GridBagConstraints.EAST;
+ } else if (value.equals("southeast")) {
+ c.anchor = GridBagConstraints.SOUTHEAST;
+ } else if (value.equals("south")) {
+ c.anchor = GridBagConstraints.SOUTH;
+ } else if (value.equals("southwest")) {
+ c.anchor = GridBagConstraints.SOUTHWEST;
+ } else if (value.equals("west")) {
+ c.anchor = GridBagConstraints.WEST;
+ } else if (value.equals("northwest")) {
+ c.anchor = GridBagConstraints.NORTHWEST;
+ } else if (value.equals("center")) {
+ c.anchor = GridBagConstraints.CENTER;
+ } else {
+ throw new IllegalArgumentException("invalid value for anchor attribute: '" + value + "'");
+ }
+ } else {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ public static void setAttributes(GridBagConstraints c, Element tag) throws CompilerException {
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Attr attribute = (Attr) children.item(i);
+ String name = attribute.getName();
+ String value = attribute.getValue();
+ if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ setAttribute(c, name, value);
+ }
+ }
+ }
+
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/CompiledItemContainer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/CompiledItemContainer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.runtime.swing.Item;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Stack;
+
+/** Compiled representation of a class that contains Items arranged in a list or tree structure (JComboBox, JList, JTree). */
+class CompiledItemContainer extends CompiledObject {
+
+ private List<Item> items = new ArrayList<Item>();
+ private Stack<Item> openNodes = new Stack<Item>();
+
+ public CompiledItemContainer(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ }
+
+ public void openItem(Item item) {
+ if (openNodes.isEmpty()) {
+ items.add(item);
+ } else {
+ Item openNode = openNodes.peek();
+ openNode.addChild(item);
+ }
+ openNodes.add(item);
+ }
+
+ public void closeItem(Item item) {
+ if (openNodes.pop() != item) {
+ throw new IllegalArgumentException(item + " was not at the top of the item stack");
+ }
+ }
+
+ public List<Item> getItems() {
+ return items;
+ }
+
+ public void setItems(List<Item> items) {
+ this.items = items;
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/ItemHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/ItemHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,147 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Item;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.io.IOException;
+import java.util.List;
+
+public class ItemHandler implements TagHandler {
+
+ private String DATA_BINDING = "<data binding has not been processed yet>";
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ String id = tag.getAttribute("id");
+ if (id == null || id.length() == 0) {
+ id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(Item.class));
+ }
+ String label = null;
+ String value = null;
+ boolean selected = false;
+ NamedNodeMap children = tag.getAttributes();
+
+ for (int i = 0; i < children.getLength(); i++) {
+ Attr attribute = (Attr) children.item(i);
+ String name = attribute.getName();
+ String attrValue = attribute.getValue();
+ if (name.equals("id")) {
+ // already handled
+ continue;
+ }
+ if (name.equals(Item.LABEL_PROPERTY)) {
+ String labelBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(String.class));
+ if (labelBinding != null) {
+ compiler.registerDataBinding(labelBinding, id + ".label", id + ".setLabel(" + labelBinding + ");");
+ } else {
+ label = attrValue;
+ }
+ continue;
+ }
+ if (name.equals(Item.VALUE_PROPERTY)) {
+ String valueBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Object.class));
+ if (valueBinding != null) {
+ value = DATA_BINDING;
+ compiler.registerDataBinding(valueBinding, id + ".value", id + ".setValue(" + valueBinding + ");");
+ } else {
+ value = attrValue;
+ }
+ continue;
+ }
+ if (name.equals(Item.SELECTED_PROPERTY)) {
+ String selectedBinding = compiler.processDataBindings(attrValue, ClassDescriptorLoader.getClassDescriptor(Boolean.class));
+ if (selectedBinding != null) {
+ compiler.registerDataBinding(selectedBinding, id + ".selected", id + ".setSelected(" + selectedBinding + ");");
+ } else {
+ selected = (Boolean) TypeManager.convertFromString(attrValue, Boolean.class);
+ }
+ continue;
+ }
+
+ if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ throw new UnsupportedAttributeException(name);
+ }
+ }
+
+ Item item = new Item(id, label, value, selected);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ if (value == null) {
+ compiler.reportError("<item> tag is missing required 'value' attribute");
+ } else {
+ if (!value.equals(DATA_BINDING)) {
+ List<Item> items = list.getItems();
+ for (Item item1 : items) {
+ if (item1.getValue().equals(value)) {
+ compiler.reportError("This container already has an <item> tag with the value '" + value + "'");
+ break;
+ }
+ }
+ }
+ list.openItem(item);
+ compileChildrenSecondPass(tag, compiler);
+ list.closeItem(item);
+ }
+ }
+
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXComboBoxHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.JAXXComboBox;
+import jaxx.runtime.swing.Item;
+import org.w3c.dom.Element;
+
+import java.awt.event.ItemListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXComboBoxHandler extends DefaultComponentHandler {
+
+ public JAXXComboBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXComboBox.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class);
+ addProxyEventInfo("getSelectedItem", ItemListener.class);
+ }
+
+ @Override
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXComboBoxHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,65 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.JAXXList;
+import jaxx.runtime.swing.Item;
+import org.w3c.dom.Element;
+
+import javax.swing.event.ListSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXListHandler extends DefaultComponentHandler {
+
+ public JAXXListHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ //TODO Add the correct generic type
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXListHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTabHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTabHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,11 @@
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+
+/** @author chemit */
+public class JAXXTabHandler extends TableHandler {
+
+ public JAXXTabHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import org.w3c.dom.Element;
+
+import javax.swing.event.TreeSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXTreeHandler extends DefaultComponentHandler {
+
+ public JAXXTreeHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException {
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ tree.appendAdditionCode(addMethod + "(" + id + ");");
+ createItems(tree, item.getChildren(), id + ".addChild", compiler);
+ }
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = tree.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = tree.getId() + "$items";
+ tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ createItems(tree, items, listName + ".add", compiler);
+ tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JAXXTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JCheckBoxHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JCheckBoxHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.AbstractButton;
+import javax.swing.event.ChangeListener;
+
+public class JCheckBoxHandler extends DefaultComponentHandler {
+
+ public JCheckBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("isSelected", ChangeListener.class, "model");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JComboBoxHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,44 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import java.awt.event.ItemListener;
+import javax.swing.JComboBox;
+
+public class JComboBoxHandler extends DefaultComponentHandler {
+
+ public JComboBoxHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JComboBox.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ItemListener.class);
+ addProxyEventInfo("getSelectedItem", ItemListener.class);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JComboBox does not accept childs");
+ throw new CompilerException("JComboBox does not accept childs");
+ }
+ }
+}
+
+
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JInternalFrameHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JInternalFrameHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JInternalFrame;
+import javax.swing.JMenuBar;
+import javax.swing.WindowConstants;
+
+public class JInternalFrameHandler extends DefaultComponentHandler {
+
+ public JInternalFrameHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JInternalFrame.class);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) {
+ appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");");
+ } else {
+ super.addChild(child, constraints, compiler);
+ }
+ }
+ };
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "visible", "true", false, compiler);
+ setAttribute(object, "closable", "true", false, compiler);
+ setAttribute(object, "defaultCloseOperation", String.valueOf(WindowConstants.DISPOSE_ON_CLOSE), false, compiler);
+ }
+
+ @Override
+ public void setAttributes(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setAttributes(object, tag, compiler);
+ compiler.appendInitializerCode(object.getId() + ".pack();\n");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JListHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,42 @@
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+
+import java.io.IOException;
+import javax.swing.event.ListSelectionListener;
+import javax.swing.JList;
+
+public class JListHandler extends DefaultComponentHandler {
+
+ public JListHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JList.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JList does not accept childs");
+ throw new CompilerException("JList does not accept childs");
+ }
+ }
+}
+
+
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JMenuHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JMenuHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JMenu;
+import javax.swing.event.MenuListener;
+
+public class JMenuHandler extends DefaultComponentHandler {
+
+ public JMenuHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JMenu.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("isSelected", MenuListener.class);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JPasswordFieldHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPasswordFieldHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+
+import javax.swing.JPasswordField;
+import javax.swing.event.DocumentListener;
+
+public class JPasswordFieldHandler extends JTextComponentHandler {
+
+ public JPasswordFieldHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPasswordField.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getPassword", DocumentListener.class, "document");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JPopupMenuHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JPopupMenuHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JPopupMenu;
+
+public class JPopupMenuHandler extends DefaultComponentHandler {
+
+ public JPopupMenuHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JPopupMenu.class);
+ }
+
+ @Override
+ public boolean isContainer() {
+ return true;
+ }
+
+ @Override
+ protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ compiler.openInvisibleComponent(object);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JProgressBarHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JProgressBarHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JProgressBar;
+import javax.swing.event.ChangeListener;
+
+public class JProgressBarHandler extends DefaultComponentHandler {
+
+ public JProgressBarHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JProgressBar.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "change");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JRadioButtonHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JRadioButtonHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,81 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.JAXXButtonGroup;
+
+import javax.swing.AbstractButton;
+import javax.swing.event.ChangeListener;
+
+public class JRadioButtonHandler extends DefaultComponentHandler {
+
+ private static final String VALUE_PROPERTY = JAXXButtonGroup.VALUE_CLIENT_PROPERTY.substring(1);
+ private static final String BUTTON_GROUP_PROPERTY = JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY.substring(1);
+
+ public JRadioButtonHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, AbstractButton.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("isSelected", ChangeListener.class, "model");
+ }
+
+ @Override
+ public ClassDescriptor getPropertyType(CompiledObject object, String name, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals(BUTTON_GROUP_PROPERTY)) {
+ return null; // accepts either a String or a ButtonGroup
+ } else if (name.equals(VALUE_PROPERTY)) {
+ return ClassDescriptorLoader.getClassDescriptor(Object.class);
+ } else {
+ return super.getPropertyType(object, name, compiler);
+ }
+ }
+
+ @Override
+ public boolean isMemberBound(String name) throws UnsupportedAttributeException {
+ return !(name.equals(BUTTON_GROUP_PROPERTY) || name.equals(VALUE_PROPERTY)) && super.isMemberBound(name);
+ }
+
+ // handle buttonGroup assignment in addition block rather than initialization block
+ @Override
+ public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) {
+ if (name.equals(BUTTON_GROUP_PROPERTY)) {
+ object.appendAdditionCode(getSetPropertyCode(object.getJavaCode(), name, TypeManager.getJavaCode(value), compiler));
+ } else {
+ super.setProperty(object, name, value, compiler);
+ }
+ }
+
+ @Override
+ public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals(BUTTON_GROUP_PROPERTY)) {
+ if (valueCode.startsWith("\"") && valueCode.endsWith("\"")) {
+ valueCode = valueCode.substring(1, valueCode.length() - 1);
+ CompiledObject buttonGroup = compiler.getCompiledObject(valueCode);
+ if (buttonGroup == null) {
+ buttonGroup = new CompiledObject(valueCode, ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class), compiler);
+ compiler.registerCompiledObject(buttonGroup);
+ }
+ }
+ return "{ javax.swing.ButtonGroup $buttonGroup = " + valueCode + "; " + id + ".putClientProperty(\"$buttonGroup\", $buttonGroup); $buttonGroup.add(" + id + "); }\n";
+ } else if (name.equals(VALUE_PROPERTY)) {
+ return "{ " + id + ".putClientProperty(\"" + JAXXButtonGroup.VALUE_CLIENT_PROPERTY + "\", " + valueCode + "); Object $buttonGroup = " + id + ".getClientProperty(\"" + JAXXButtonGroup.BUTTON8GROUP_CLIENT_PROPERTY + "\");" +
+ " if ($buttonGroup instanceof jaxx.runtime.swing.JAXXButtonGroup) { ((jaxx.runtime.swing.JAXXButtonGroup) $buttonGroup).updateSelectedValue(); } }\n";
+ } else {
+ return super.getSetPropertyCode(id, name, valueCode, compiler);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JScrollPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JScrollPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JScrollPane;
+
+public class JScrollPaneHandler extends DefaultComponentHandler {
+
+ public JScrollPaneHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JScrollPane.class);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ boolean hasChild;
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("JScrollPane does not accept constraints");
+ }
+ if (hasChild) {
+ compiler.reportError("JScrollPane may only have one child");
+ }
+ super.addChild(child, constraints, compiler);
+ hasChild = true;
+ }
+ };
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSliderHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSliderHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,48 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+import javax.swing.JSlider;
+import javax.swing.event.ChangeListener;
+
+public class JSliderHandler extends DefaultComponentHandler {
+
+ public JSliderHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ if (!ClassDescriptorLoader.getClassDescriptor(JSlider.class).isAssignableFrom(beanClass)) {
+ throw new IllegalArgumentException(getClass().getName() + " does not support the class " + beanClass.getName());
+ }
+ }
+
+ @Override
+ protected int getAttributeOrdering(Attr attr) {
+ if (attr.getName().equals("value")) {
+ return 1;
+ } else {
+ return super.getAttributeOrdering(attr);
+ }
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ setAttribute(object, "value", "0", false, compiler);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "model");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSpinnerHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSpinnerHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,94 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JSpinner;
+import javax.swing.event.ChangeListener;
+
+public class JSpinnerHandler extends DefaultComponentHandler {
+
+ public static String MINIMUM_PROPERTY = "minimum";
+ public static String MAXIMUM_PROPERTY = "maximum";
+ public static String VALUE_PROPERTY = "value";
+
+ public JSpinnerHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSpinner.class);
+ }
+
+ public static class CompiledSpinner extends CompiledObject {
+
+ Integer minimum = null;
+ Integer maximum = null;
+ Integer value = null;
+
+ public CompiledSpinner(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ }
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledSpinner(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getValue", ChangeListener.class, "model");
+ }
+
+ @Override
+ public ClassDescriptor getPropertyType(CompiledObject object, String propertyName, JAXXCompiler compiler) throws CompilerException {
+ if (propertyName.equals(MINIMUM_PROPERTY) || propertyName.equals(MAXIMUM_PROPERTY) ||
+ propertyName.equals(VALUE_PROPERTY)) {
+ return ClassDescriptorLoader.getClassDescriptor(Integer.class);
+ }
+ return super.getPropertyType(object, propertyName, compiler);
+ }
+
+ @Override
+ public void setProperty(CompiledObject object, String name, Object value, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals(MINIMUM_PROPERTY)) {
+ ((CompiledSpinner) object).minimum = (Integer) value;
+ } else if (name.equals(MAXIMUM_PROPERTY)) {
+ ((CompiledSpinner) object).maximum = (Integer) value;
+ } else if (name.equals(VALUE_PROPERTY)) {
+ ((CompiledSpinner) object).value = (Integer) value;
+ } else {
+ super.setProperty(object, name, value, compiler);
+ }
+ }
+
+ @Override
+ protected void closeComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ CompiledSpinner spinner = (CompiledSpinner) object;
+ if (spinner.minimum != null || spinner.maximum != null || spinner.value != null) {
+ if (spinner.getConstructorParams() != null) {
+ compiler.reportError("constructorParams and minimum/maximum may not both be specified for the same JSpinner");
+ }
+ if (spinner.minimum == null) {
+ spinner.minimum = Math.min(0, spinner.maximum != null ? spinner.maximum.intValue() : 0);
+ }
+ if (spinner.maximum == null) {
+ spinner.maximum = Math.max(100, spinner.minimum.intValue());
+ }
+ if (spinner.value == null) {
+ spinner.value = spinner.minimum;
+ }
+ spinner.setConstructorParams("new SpinnerNumberModel(" + spinner.value + ", " + spinner.minimum + ", " + spinner.maximum + ", 1)");
+ }
+
+ super.closeComponent(object, tag, compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JSplitPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JSplitPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,71 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JSplitPane;
+import java.awt.Component;
+
+public class JSplitPaneHandler extends DefaultComponentHandler {
+
+ public JSplitPaneHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JSplitPane.class);
+ }
+
+ protected Component createRawComponent(Element tag) {
+ return new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
+ }
+
+ /**
+ * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. The
+ * values required by the JAXXBeanInfo are the unwieldy <code>vertical_split</code> and <code>horizontal_split</code>
+ * (which are also recognized).
+ */
+ @Override
+ protected int constantValue(String key, String value) {
+ if (key.equals("orientation")) {
+ value = value.trim().toLowerCase();
+ if (value.equals("horizontal") || value.equals("horizontal_split")) {
+ return JSplitPane.HORIZONTAL_SPLIT;
+ }
+ if (value.equals("vertical") || value.equals("vertical_split")) {
+ return JSplitPane.VERTICAL_SPLIT;
+ }
+ throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'");
+ }
+ return super.constantValue(key, value);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ private int count;
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("JSplitPane does not accept constraints");
+ }
+ if (count == 0) {
+ super.addChild(child, "JSplitPane.LEFT", compiler);
+ } else if (count == 1) {
+ super.addChild(child, "JSplitPane.RIGHT", compiler);
+ } else {
+ compiler.reportError("JSplitPane is limited to two children");
+ }
+ count++;
+ }
+ };
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTabbedPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTabbedPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,136 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.TabInfo;
+
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+import javax.swing.event.ChangeListener;
+import java.awt.Color;
+import java.awt.event.ContainerListener;
+
+public class JTabbedPaneHandler extends DefaultComponentHandler {
+
+ public JTabbedPaneHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTabbedPane.class);
+ }
+
+ public static class CompiledTabbedPane extends CompiledObject {
+
+ private static final TabInfo USED = new TabInfo("ALREADY USED");
+ int tabCount;
+ TabInfo tabInfo;
+
+ public CompiledTabbedPane(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ }
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("JTabbedPane tabs may not have constraints");
+ }
+
+ super.addChild(child, constraints, compiler);
+
+ if (tabInfo == null) {
+ compiler.reportError("JTabbedPaneHandler may only have 'tab' tags as children (found " + child.getObjectClass() + ")");
+ return;
+ } else if (tabInfo == USED) {
+ compiler.reportError("<tab> tags may only have one child component");
+ return;
+ }
+
+ int tabIndex = ++tabCount - 1;
+ appendAdditionCode(tabInfo.getId() + ".addPropertyChangeListener(new jaxx.runtime.swing.TabInfoPropertyChangeListener(" + getId() + ", " + tabIndex + "));");
+
+ String title = tabInfo.getTitle();
+ if (title != null) {
+ if (I18nHelper.isI18nAttribute("title")) {
+ if (!title.startsWith("_(\"")) {
+ // we did not have the invocation code, add it
+ title = I18nHelper.addI18nInvocation(getId(), "title", TypeManager.getJavaCode(title), compiler);
+ }
+ } else {
+ title = TypeManager.getJavaCode(title);
+ }
+ appendAdditionCode(getId() + ".setTitleAt(" + tabIndex + ", " + title + ");");
+ }
+
+ String toolTipText = tabInfo.getToolTipText();
+ if (toolTipText != null) {
+ if (I18nHelper.isI18nAttribute("toolTipText")) {
+ if (!toolTipText.startsWith("_(\"")) {
+ // we did not have the invocation code, add it
+ toolTipText = I18nHelper.addI18nInvocation(getId(), "toolTipText", TypeManager.getJavaCode(toolTipText), compiler);
+ }
+ } else {
+ toolTipText = TypeManager.getJavaCode(toolTipText);
+ }
+ appendAdditionCode(getId() + ".setToolTipTextAt(" + tabIndex + ", " + toolTipText + ");");
+ }
+
+ boolean enabled = tabInfo.isEnabled();
+ if (!enabled) {
+ appendAdditionCode(getId() + ".setEnabledAt(" + tabIndex + ", false);");
+ }
+
+ Color foreground = tabInfo.getForeground();
+ if (foreground != null) {
+ appendAdditionCode(getId() + ".setForegroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(foreground) + ");");
+ }
+
+ Color background = tabInfo.getBackground();
+ if (background != null) {
+ appendAdditionCode(getId() + ".setBackgroundAt(" + tabIndex + ", " + TypeManager.getJavaCode(background) + ");");
+ }
+
+ int mnemonic = tabInfo.getMnemonic();
+ if (mnemonic != -1) {
+ appendAdditionCode(getId() + ".setMnemonicAt(" + tabIndex + ", " + mnemonic + ");");
+ }
+
+ int displayedMnemonicIndex = tabInfo.getDisplayedMnemonicIndex();
+ if (displayedMnemonicIndex != -1) {
+ appendAdditionCode(getId() + ".setDisplayedMnemonicIndexAt(" + tabIndex + ", " + displayedMnemonicIndex + ");");
+ }
+
+ Icon icon = tabInfo.getIcon();
+ if (icon != null) {
+ appendAdditionCode(getId() + ".setIconAt(" + tabIndex + ", " + icon + ");");
+ }
+
+ Icon disabledIcon = tabInfo.getDisabledIcon();
+ if (disabledIcon != null) {
+ appendAdditionCode(getId() + ".setDisabledIconAt(" + tabIndex + ", " + disabledIcon + ");");
+ }
+
+ tabInfo = USED;
+ }
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledTabbedPane(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ChangeListener.class);
+ addProxyEventInfo("getSelectedComponent", ChangeListener.class);
+ addProxyEventInfo("getTabCount", ContainerListener.class);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTextComponentHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTextComponentHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.runtime.SwingUtil;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+
+import javax.swing.JTextArea;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.JTextComponent;
+
+public class JTextComponentHandler extends DefaultComponentHandler {
+
+ private static final int DEFAULT_COLUMNS = 15;
+
+ public JTextComponentHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTextComponent.class);
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ super.setDefaults(object, tag, compiler);
+ try {
+ object.getObjectClass().getMethodDescriptor("setColumns", ClassDescriptorLoader.getClassDescriptor(int.class));
+ setAttribute(object, "columns", String.valueOf(DEFAULT_COLUMNS), false, compiler);
+ } catch (NoSuchMethodException e) {
+ // ignore ?
+ }
+
+ if (ClassDescriptorLoader.getClassDescriptor(JTextArea.class).isAssignableFrom(object.getObjectClass())) {
+ setAttribute(object, "lineWrap", "true", false, compiler);
+ setAttribute(object, "wrapStyleWord", "true", false, compiler);
+ }
+ }
+
+ @Override
+ public String getSetPropertyCode(String id, String name, String valueCode, JAXXCompiler compiler) throws CompilerException {
+ if (name.equals("text")) {
+ return SwingUtil.class.getName() + ".setText(" + id + ", " + valueCode + ");\n";
+ //return "jaxx.runtime.swing.Utils.setText(" + id + ", " + valueCode + ");\n";
+ }
+ return super.getSetPropertyCode(id, name, valueCode, compiler);
+ }
+
+ @Override
+ protected int getAttributeOrdering(Attr attr) {
+ // delay text in case other attributes affect how it's processed, as is the case
+ // with JEditorPane's contentType
+ if (attr.getName().equals("text")) {
+ return 1;
+ }
+ return super.getAttributeOrdering(attr);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getText", DocumentListener.class, "document");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JToolBarHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JToolBarHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+
+import javax.swing.JToolBar;
+
+public class JToolBarHandler extends DefaultComponentHandler {
+
+ public JToolBarHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JToolBar.class);
+ }
+
+ /**
+ * Add support for <code>orientation="vertical"</code> and <code>orientation="horizontal"</code>. These values should
+ * have been supported without any special effort on my part, but JToolBar's BeanInfo doesn't contain the enum attribute
+ * for the orientation property.
+ */
+ @Override
+ protected int constantValue(String key, String value) {
+ if (key.equals("orientation")) {
+ value = value.trim().toLowerCase();
+ if (value.equals("horizontal")) {
+ return JToolBar.HORIZONTAL;
+ }
+ if (value.equals("vertical")) {
+ return JToolBar.VERTICAL;
+ }
+ throw new IllegalArgumentException("orientation must be 'horizontal' or 'vertical', found '" + value + "'");
+ }
+ return super.constantValue(key, value);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java (from rev 1561, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JTreeHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,43 @@
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.event.TreeSelectionListener;
+import java.io.IOException;
+import javax.swing.JTree;
+import org.w3c.dom.NodeList;
+
+public class JTreeHandler extends DefaultComponentHandler {
+
+ public JTreeHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTree.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JTree does not accept childs");
+ throw new CompilerException("JTree does not accept childs");
+ }
+ }
+}
+
+
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JWindowHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/JWindowHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import org.w3c.dom.Element;
+
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JMenuBar;
+import javax.swing.JWindow;
+import java.io.IOException;
+import java.util.Map;
+
+public class JWindowHandler extends DefaultComponentHandler {
+
+ public JWindowHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JWindow.class, JFrame.class, JDialog.class);
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledObject(id, getBeanClass(), compiler) {
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (ClassDescriptorLoader.getClassDescriptor(JMenuBar.class).isAssignableFrom(child.getObjectClass())) {
+ appendAdditionCode(getId() + ".setJMenuBar(" + child.getId() + ");");
+ } else {
+ super.addChild(child, constraints, compiler);
+ }
+ }
+ };
+ }
+
+ @Override
+ protected void openComponent(CompiledObject object, Element tag, JAXXCompiler compiler) throws CompilerException {
+ if (compiler.getOpenComponent() != null) {
+ compiler.openInvisibleComponent(object);
+ } else {
+ super.openComponent(object, tag, compiler);
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileSecondPass(tag, compiler);
+ CompiledObject object = objectMap.get(tag);
+ Map<?, ?> properties = object.getProperties();
+ if (!properties.containsKey("width") && !properties.containsKey("height")) {
+ compiler.appendLateInitializer(object.getId() + ".pack();\n");
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/RowHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/RowHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,88 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.runtime.swing.Table;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import java.awt.GridBagConstraints;
+import java.io.IOException;
+
+public class RowHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (!ClassDescriptorLoader.getClassDescriptor(Table.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError("row tag may only appear within Table tag");
+ return;
+ }
+
+ TableHandler.CompiledTable table = (TableHandler.CompiledTable) compiler.getOpenComponent();
+ table.newRow();
+ GridBagConstraints c = table.getRowConstraints();
+ CellHandler.setAttributes(c, tag);
+ compileChildrenSecondPass(tag, compiler);
+ }
+
+ public void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ if (!child.getLocalName().equals("cell")) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children");
+ }
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ if (!child.getLocalName().equals("cell")) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may only contain cell tags as children");
+ }
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TabHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TabHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,170 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.I18nHelper;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.TabInfo;
+import org.w3c.dom.Attr;
+import org.w3c.dom.Element;
+import org.w3c.dom.NamedNodeMap;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+
+import javax.swing.Icon;
+import javax.swing.JTabbedPane;
+import java.awt.Color;
+import java.io.IOException;
+
+public class TabHandler implements TagHandler {
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compileChildrenFirstPass(tag, compiler);
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (!ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError("tab tag may only appear within JTabbedPane tag");
+ return;
+ }
+
+ JTabbedPaneHandler.CompiledTabbedPane tabs = (JTabbedPaneHandler.CompiledTabbedPane) compiler.getOpenComponent();
+
+ String id = tag.getAttribute("id");
+ if (id == null || id.length() == 0) {
+ id = compiler.getAutoId(ClassDescriptorLoader.getClassDescriptor(TabInfo.class));
+ }
+ TabInfo tabInfo = new TabInfo(id);
+ CompiledObject compiledTabInfo = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(TabInfo.class), compiler);
+ compiler.registerCompiledObject(compiledTabInfo);
+ //id = tabInfo.getId();
+ tabs.tabInfo = tabInfo;
+ setAttributes(compiledTabInfo, tabs, tag, compiler);
+ compileChildrenSecondPass(tag, compiler);
+ tabs.tabInfo = null;
+ }
+
+ public static void setAttribute(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, String name, String value, JAXXCompiler compiler) throws CompilerException {
+ value = value.trim();
+ TabInfo tabInfo = tabs.tabInfo;
+ String id = tabInfo.getId();
+ String binding = compiler.processDataBindings(value, ClassDescriptorLoader.getClassDescriptor(Object.class));
+ if (binding != null) {
+ compiler.registerDataBinding(binding, id + "." + name, id + ".set" + org.apache.commons.lang.StringUtils.capitalize(name) + "(" + binding + ");");
+ return;
+ }
+
+ String valueCode = TypeManager.getJavaCode(value);
+
+ // add i18n support
+ if (I18nHelper.isI18nableAttribute(name, compiler)) {
+ value = valueCode = I18nHelper.addI18nInvocation(id, name, valueCode, compiler);
+ }
+
+ if (name.equals("title")) {
+ tabInfo.setTitle(value);
+ compiledTabInfo.appendInitializationCode(id + ".setTitle(" + valueCode + ");");
+ //compiledTabInfo.appendInitializationCode(id + ".setTitle(" + TypeManager.getJavaCode(value) + ");");
+ } else if (name.equals("toolTipText")) {
+ tabInfo.setToolTipText(value);
+ compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + valueCode + ");");
+ //compiledTabInfo.appendInitializationCode(id + ".setToolTipText(" + TypeManager.getJavaCode(value) + ");");
+ } else if (name.equals("icon")) {
+ Icon icon = (Icon) TypeManager.convertFromString(value, Icon.class);
+ tabInfo.setIcon(icon);
+ compiledTabInfo.appendInitializationCode(id + ".setIcon(" + TypeManager.getJavaCode(icon) + ");");
+ } else if (name.equals("enabled")) {
+ boolean enabled = (Boolean) TypeManager.convertFromString(value, Boolean.class);
+ tabInfo.setEnabled(enabled);
+ compiledTabInfo.appendInitializationCode(id + ".setEnabled(" + enabled + ");");
+ } else if (name.equals("disabledIcon")) {
+ Icon disabledIcon = (Icon) TypeManager.convertFromString(value, Icon.class);
+ tabInfo.setDisabledIcon(disabledIcon);
+ compiledTabInfo.appendInitializationCode(id + ".setDisabledIcon(" + TypeManager.getJavaCode(disabledIcon) + ");");
+ } else if (name.equals("mnemonic")) {
+ int mnemonic = (Character) TypeManager.convertFromString(value, char.class);
+ tabInfo.setMnemonic(mnemonic);
+ compiledTabInfo.appendInitializationCode(id + ".setMnemonic(" + mnemonic + ");");
+ } else if (name.equals("displayedMnemonicIndex")) {
+ int displayedMnemonicIndex = (Integer) TypeManager.convertFromString(value, int.class);
+ tabInfo.setDisplayedMnemonicIndex(displayedMnemonicIndex);
+ compiledTabInfo.appendInitializationCode(id + ".setDisplayedMnemonicIndex(" + displayedMnemonicIndex + ");");
+ } else if (name.equals("foreground")) {
+ Color foreground = (Color) TypeManager.convertFromString(value, Color.class);
+ tabInfo.setForeground(foreground);
+ compiledTabInfo.appendInitializationCode(id + ".setForeground(" + TypeManager.getJavaCode(foreground) + ");");
+ } else if (name.equals("background")) {
+ Color background = (Color) TypeManager.convertFromString(value, Color.class);
+ tabInfo.setBackground(background);
+ compiledTabInfo.appendInitializationCode(id + ".setBackground(" + TypeManager.getJavaCode(background) + ");");
+ } else if (name.equals("id")) {
+ // ignore, already handled
+ } else {
+ compiler.reportError("The <tab> tag does not support the attribute '" + name + "'");
+ }
+ }
+
+ public void setAttributes(CompiledObject compiledTabInfo, JTabbedPaneHandler.CompiledTabbedPane tabs, Element tag, JAXXCompiler compiler) throws CompilerException {
+ NamedNodeMap children = tag.getAttributes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Attr attribute = (Attr) children.item(i);
+ String name = attribute.getName();
+ String value = attribute.getValue();
+ if (!name.startsWith("xmlns") && !JAXXCompiler.JAXX_INTERNAL_NAMESPACE.equals(attribute.getNamespaceURI())) {
+ setAttribute(compiledTabInfo, tabs, name, value, compiler);
+ }
+ }
+ }
+
+ protected void compileChildrenFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagFirstPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileFirstPass(tag);
+ }
+
+ protected void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node node = children.item(i);
+ int nodeType = node.getNodeType();
+ if (nodeType == Node.ELEMENT_NODE) {
+ Element child = (Element) node;
+ compileChildTagSecondPass(child, compiler);
+ } else if (nodeType == Node.TEXT_NODE || nodeType == Node.CDATA_SECTION_NODE) {
+ String text = ((Text) node).getData().trim();
+ if (text.length() > 0) {
+ compiler.reportError("tag '" + tag.getLocalName() + "' may not contain text ('" + ((Text) node).getData().trim() + "')");
+ }
+ }
+ }
+ }
+
+ protected void compileChildTagSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ compiler.compileSecondPass(tag);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/TableHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/swing/TableHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.swing;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.UnsupportedAttributeException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultComponentHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.swing.Table;
+
+import java.awt.GridBagConstraints;
+import java.awt.Insets;
+import java.util.ArrayList;
+import java.util.List;
+
+public class TableHandler extends DefaultComponentHandler {
+
+ public static final Insets DEFAULT_INSETS = new Insets(3, 3, 3, 3);
+
+ public TableHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, Table.class);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) throws CompilerException {
+ try {
+ if (object instanceof CompiledTable) {
+ CellHandler.setAttribute(((CompiledTable) object).getTableConstraints(), propertyName, stringValue);
+ } else {
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+ } catch (UnsupportedAttributeException e) {
+ super.setAttribute(object, propertyName, stringValue, inline, compiler);
+ }
+ }
+
+ class CompiledTable extends CompiledObject {
+
+ private List<Integer> rowSpans = new ArrayList<Integer>();
+ private GridBagConstraints tableConstraints;
+ private GridBagConstraints rowConstraints = null;
+ private GridBagConstraints cellConstraints = null;
+ private boolean emptyCell;
+
+ public CompiledTable(String id, ClassDescriptor objectClass, JAXXCompiler compiler) throws CompilerException {
+ super(id, objectClass, compiler);
+ tableConstraints = new GridBagConstraints();
+ tableConstraints.gridx = -1;
+ tableConstraints.gridy = -1;
+ tableConstraints.insets = DEFAULT_INSETS;
+ }
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ if (constraints != null) {
+ compiler.reportError("Table does not accept constraints");
+ }
+ GridBagConstraints c = getCellConstraints();
+ if (c == null) {
+ compiler.reportError("Table tag may only contain row tags");
+ return;
+ }
+ if (!emptyCell) {
+ compiler.reportError("Table cells may only have one child component");
+ }
+ while (rowSpans.size() < c.gridx + c.gridwidth) {
+ rowSpans.add(null);
+ }
+ for (int x = c.gridx; x < c.gridx + c.gridwidth; x++) {
+ rowSpans.set(x, c.gridheight);
+ }
+
+ super.addChild(child, TypeManager.getJavaCode(c), compiler);
+
+ emptyCell = false;
+ }
+
+ public GridBagConstraints getTableConstraints() {
+ return tableConstraints;
+ }
+
+ public GridBagConstraints getRowConstraints() {
+ return rowConstraints;
+ }
+
+ public GridBagConstraints getCellConstraints() {
+ return cellConstraints;
+ }
+
+ public void newRow() {
+ tableConstraints.gridy++;
+ tableConstraints.gridx = -1;
+ rowConstraints = (GridBagConstraints) tableConstraints.clone();
+
+ for (int x = 0; x < rowSpans.size(); x++) {
+ int rowSpan = rowSpans.get(x);
+ if (rowSpan > 0) {
+ rowSpans.set(x, rowSpan - 1);
+ }
+ }
+ }
+
+ public void newCell() {
+ emptyCell = true;
+ rowConstraints.gridx++;
+ while (rowConstraints.gridx < rowSpans.size() && rowSpans.get(rowConstraints.gridx) > 0) {
+ rowConstraints.gridx++;
+ }
+ cellConstraints = (GridBagConstraints) rowConstraints.clone();
+ }
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledTable(id, getBeanClass(), compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/BeanValidatorHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/BeanValidatorHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,734 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.validator;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.beans.JAXXBeanInfo;
+import jaxx.compiler.beans.JAXXPropertyDescriptor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.DefaultObjectHandler;
+import jaxx.compiler.types.TypeManager;
+import jaxx.runtime.validator.swing.SwingValidatorUtil;
+import jaxx.runtime.validator.swing.SwingValidator;
+import jaxx.runtime.validator.swing.ui.AbstractBeanValidatorUI;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.beans.IntrospectionException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.TreeMap;
+
+public class BeanValidatorHandler extends DefaultObjectHandler {
+
+ public static final String TAG = "BeanValidator";
+ public static final String BEAN_ATTRIBUTE = "bean";
+ public static final String BEAN_CLASS_ATTRIBUTE = "beanClass";
+ public static final String BEAN_INITIALIZER_ATTRIBUTE = "beanInitializer";
+ public static final String ERROR_LIST_MODEL_ATTRIBUTE = "errorListModel";
+ public static final String ERROR_TABLE_MODEL_ATTRIBUTE = "errorTableModel";
+ public static final String ERROR_LIST_ATTRIBUTE = "errorList";
+ public static final String ERROR_TABLE_ATTRIBUTE = "errorTable";
+ public static final String ERROR_LIST_MODEL_DEFAULT = "errors";
+ public static final String ERROR_TABLE_MODEL_DEFAULT = "errors2";
+ public static final String ERROR_LIST_DEFAULT = "errorList";
+ public static final String ERROR_TABLE_DEFAULT = "errorTable";
+ public static final String AUTOFIELD_ATTRIBUTE = "autoField";
+ public static final String UI_CLASS_ATTRIBUTE = "uiClass";
+ public static final String STRICT_MODE_ATTRIBUTE = "strictMode";
+ public static final String CONTEXT_NAME_ATTRIBUTE = "contextName";
+ //public static final String SCOPE_ATTRIBUTE = "scope";
+ public static final String PARENT_VALIDATOR_ATTRIBUTE = "parentValidator";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static Log log = LogFactory.getLog(BeanValidatorHandler.class);
+ protected static Map<JAXXCompiler, List<CompiledBeanValidator>> validators = new HashMap<JAXXCompiler, List<CompiledBeanValidator>>();
+ protected static Map<JAXXCompiler, List<String>> validatedComponents = new HashMap<JAXXCompiler, List<String>>();
+
+ public BeanValidatorHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, SwingValidator.class);
+ }
+
+ @Override
+ protected CompiledObject createCompiledObject(String id, JAXXCompiler compiler) {
+ return new CompiledBeanValidator(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ protected void compileChildTagFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+ if (!tag.getLocalName().equals(FieldValidatorHandler.TAG)) {
+ compiler.reportError("tag '" + tag.getParentNode().getLocalName() + "' may only contain " + FieldValidatorHandler.TAG + " as children, but found : " + tag.getLocalName());
+ } else {
+ compiler.compileFirstPass(tag);
+ }
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+
+ super.compileSecondPass(tag, compiler);
+
+ CompiledBeanValidator info = (CompiledBeanValidator) objectMap.get(tag);
+
+ boolean error = info.addErrorListModel(tag, this, compiler);
+
+ if (!error) {
+ error = info.addErrorList(tag, compiler);
+ }
+
+ if (!error) {
+ error = info.addErrorTableModel(tag, this, compiler);
+ }
+
+ if (!error) {
+ error = info.addErrorTable(tag, compiler);
+ }
+
+ if (!error) {
+ error = info.addUiClass(this, compiler);
+ }
+
+ if (!error) {
+ error = info.addBean(tag, this, compiler);
+ }
+
+ /*if (!error) {
+ error = info.addContextName(this, compiler);
+ }*/
+
+ /*if (!error) {
+ error = info.addScope(this, compiler);
+ }*/
+
+ if (!error) {
+ error = info.addParentValidator(tag, this, compiler);
+ }
+
+ if (error) {
+ log.warn("error were detected in second compile pass of CompiledObject [" + info + "]");
+ }
+
+ // close the compiled object
+ compiler.closeComponent(info);
+ }
+
+ @Override
+ protected void setDefaults(CompiledObject object, Element tag, JAXXCompiler compiler) {
+ // open the compiled object
+ compiler.openInvisibleComponent(object);
+ }
+
+ @Override
+ public void setAttribute(CompiledObject object, String propertyName, String stringValue, boolean inline, JAXXCompiler compiler) {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(propertyName + " : " + stringValue + " for " + object);
+ }
+ // delegate to the compiled object with is statefull (but not the tag handler)
+ object.addProperty(propertyName, stringValue);
+ }
+
+ /**
+ * The compiled objet representing a BeanValidator to be generated in JAXXObject
+ *
+ * @author chemit
+ */
+ public static class CompiledBeanValidator extends CompiledObject {
+
+ protected Map<String, String> fields;
+ protected Map<String, String> excludeFields;
+ protected String bean;
+ protected String beanClass;
+ protected String contextName;
+ protected String uiClass;
+ protected String errorListModel;
+ protected String errorList;
+ protected Boolean autoField;
+ protected Boolean strictMode;
+ protected JAXXBeanInfo beanDescriptor;
+ protected String errorTableModel;
+ protected String errorTable;
+ protected String parentValidator;
+
+ public CompiledBeanValidator(String id, ClassDescriptor objectClass, JAXXCompiler compiler) {
+ //TC-20090524 Use the real class descriptor, not the one by default,
+ //TC-20090524 otherwise can not override the validator class while generation
+ //super(id, objectClass, compiler);
+ super(id, getDescriptor(objectClass, compiler), compiler);
+ fields = new TreeMap<String, String>();
+ excludeFields = new TreeMap<String, String>();
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("validator objectClass " + super.getObjectClass());
+ }
+ }
+
+ protected static ClassDescriptor getDescriptor(ClassDescriptor objectClass, JAXXCompiler compiler) {
+ ClassDescriptor result = objectClass;
+ Class<?> validatorClass = compiler.getConfiguration().getValidatorClass();
+ result = ClassDescriptorLoader.getClassDescriptor(validatorClass);
+ return result;
+ }
+
+ public Map<String, String> getFields() {
+ return fields;
+ }
+
+ public Map<String, String> getExcludeFields() {
+ return excludeFields;
+ }
+
+ public void setFields(Map<String, String> fields) {
+ this.fields = fields;
+ }
+
+ public void setExcludeFields(Map<String, String> excludeFields) {
+ this.excludeFields = excludeFields;
+ }
+
+ @Override
+ public void addProperty(String property, String value) {
+
+ if (BEAN_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ bean = value.trim();
+ }
+ return;
+ }
+
+ if (CONTEXT_NAME_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ contextName = value.trim();
+ }
+ return;
+ }
+
+ if (BEAN_CLASS_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ beanClass = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_LIST_MODEL_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorListModel = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_LIST_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorList = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_TABLE_MODEL_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorTableModel = value.trim();
+ }
+ return;
+ }
+
+ if (ERROR_TABLE_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ errorTable = value.trim();
+ }
+ return;
+ }
+
+ if (UI_CLASS_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ uiClass = value.trim();
+ }
+ return;
+ }
+
+ if (AUTOFIELD_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ autoField = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class);
+ }
+ return;
+ }
+
+ if (STRICT_MODE_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ strictMode = (Boolean) TypeManager.convertFromString(value.trim(), Boolean.class);
+ }
+ return;
+ }
+
+ if (PARENT_VALIDATOR_ATTRIBUTE.equals(property)) {
+ if (value != null && !value.trim().isEmpty()) {
+ parentValidator = value.trim();
+ }
+ return;
+ }
+
+ throw new CompilerException("property " + property + " is not allowed on object " + this);
+ }
+
+ public String getBean() {
+ return bean;
+ }
+
+ public String getErrorListModel() {
+ return errorListModel;
+ }
+
+ public boolean getAutoField() {
+ return autoField != null && autoField;
+ }
+
+ public boolean getStrictMode() {
+ return strictMode != null && strictMode;
+ }
+
+ public String getUiClass() {
+ return uiClass;
+ }
+
+ public String getBeanClass() {
+ return beanClass;
+ }
+
+ public String getContextName() {
+ return contextName;
+ }
+
+ public String getParentValidator() {
+ return parentValidator;
+ }
+
+ public JAXXBeanInfo getBeanDescriptor(JAXXCompiler compiler) {
+ if (beanDescriptor == null && foundBean()) {
+
+ String beanClassName = null;
+ try {
+ //TC-20090111 beanClass is mandatory
+ // get the real bean class name (from bean or beanClass)
+ /*if (beanClass != null) {
+ beanClassName = beanClass;
+ } else {
+ beanClassName = compiler.getSymbolTable().getClassTagIds().get(bean);
+ if (beanClassName == null) {
+ compiler.reportError("could not find class of the bean '" + bean + "'");
+ return null;
+ }
+ }*/
+ ClassDescriptor beanClassDescriptor = ClassDescriptorLoader.getClassDescriptor(beanClass);
+ beanDescriptor = DefaultObjectHandler.getJAXXBeanInfo(beanClassDescriptor);
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("could not load class " + beanClassName);
+ } catch (IntrospectionException e) {
+ compiler.reportError("could not load class " + beanClassName);
+ }
+ }
+ return beanDescriptor;
+ }
+
+ @Override
+ public void addChild(CompiledObject child, String constraints, JAXXCompiler compiler) throws CompilerException {
+ // do nothing
+ compiler.reportError("can not add CompiledObject in the tag '" + TAG + " (only field tags)");
+ }
+
+ public boolean foundBean() {
+ return !(beanClass == null || beanClass.isEmpty());
+ }
+
+ protected boolean addUiClass(BeanValidatorHandler handler, JAXXCompiler compiler) {
+ boolean withError = false;
+ if (uiClass == null && compiler.getConfiguration().getDefaultErrorUI() != null) {
+ uiClass = compiler.getConfiguration().getDefaultErrorUI().getName();
+ }
+ if (uiClass != null) {
+ try {
+ ClassDescriptor uiClazz = ClassDescriptorLoader.getClassDescriptor(uiClass);
+ if (!ClassDescriptorLoader.getClassDescriptor(AbstractBeanValidatorUI.class).isAssignableFrom(uiClazz)) {
+ compiler.reportError("attribute 'ui' :'" + uiClass + "' is not assignable from class " + AbstractBeanValidatorUI.class);
+ withError = true;
+ } else {
+ String code = handler.getSetPropertyCode(getJavaCode(), UI_CLASS_ATTRIBUTE, uiClazz.getName() + ".class", compiler);
+ appendAdditionCode(code);
+ }
+ } catch (ClassNotFoundException e) {
+ compiler.reportError("class not found '" + uiClass + "'");
+ withError = true;
+ }
+ }
+
+ return withError;
+ }
+
+ protected boolean addErrorListModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (errorListModel == null) {
+ // try with the default "errors"
+ if (!compiler.checkReference(tag, ERROR_LIST_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) {
+ return false;
+ }
+ errorListModel = ERROR_LIST_MODEL_DEFAULT;
+ } else {
+ if (errorListModel.startsWith("{") && errorListModel.endsWith("}")) {
+ // this is a script, no check here
+ errorListModel = errorListModel.substring(1, errorListModel.length() - 1).trim();
+ } else if (!compiler.checkReference(tag, errorListModel, true, ERROR_LIST_MODEL_ATTRIBUTE)) {
+ // errorListModel is not defined
+ return true;
+ }
+ }
+
+ String code = handler.getSetPropertyCode(getJavaCode(), ERROR_LIST_MODEL_ATTRIBUTE, errorListModel, compiler);
+ appendAdditionCode(code);
+
+ return false;
+
+ }
+
+ protected boolean addErrorTableModel(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (errorTableModel == null) {
+ // try with the default "errors"
+ if (!compiler.checkReference(tag, ERROR_TABLE_MODEL_DEFAULT, false, ERROR_LIST_MODEL_ATTRIBUTE)) {
+ return false;
+ }
+ errorTableModel = ERROR_TABLE_MODEL_DEFAULT;
+ } else {
+ if (errorTableModel.startsWith("{") && errorTableModel.endsWith("}")) {
+ // this is a script, no check here
+ errorTableModel = errorTableModel.substring(1, errorTableModel.length() - 1).trim();
+ } else if (!compiler.checkReference(tag, errorTableModel, true, ERROR_TABLE_MODEL_ATTRIBUTE)) {
+ // errorListModel is not defined
+ return true;
+ }
+ }
+
+ String code = handler.getSetPropertyCode(getJavaCode(), ERROR_TABLE_MODEL_ATTRIBUTE, errorTableModel, compiler);
+ appendAdditionCode(code);
+
+ return false;
+
+ }
+
+ /*protected boolean addContextName(BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (contextName != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), CONTEXT_NAME_ATTRIBUTE, TypeManager.getJavaCode(contextName), compiler);
+ appendAdditionCode(code);
+ }
+ return false;
+ }*/
+
+ /*protected boolean addScope(BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (scope != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), SCOPE_ATTRIBUTE, TypeManager.getJavaCode(scope), compiler);
+ appendAdditionCode(code);
+ }
+ return false;
+ }*/
+ protected boolean addParentValidator(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+ if (parentValidator != null) {
+ String initializer;
+ if (parentValidator.startsWith("{") && parentValidator.endsWith("}")) {
+
+ // todo : should be able to bind
+ initializer = parentValidator.substring(1, parentValidator.length() - 1);
+
+ } else {
+ // the attribute referes an existing widget
+ if (!compiler.checkReference(tag, parentValidator, true, PARENT_VALIDATOR_ATTRIBUTE)) {
+ // parentValidator is not defined
+ return true;
+ }
+ initializer = parentValidator;
+ }
+ String code = handler.getSetPropertyCode(getJavaCode(), PARENT_VALIDATOR_ATTRIBUTE, initializer, compiler);
+ appendAdditionCode(code);
+ }
+ return false;
+ }
+
+ protected boolean addErrorList(Element tag, JAXXCompiler compiler) {
+
+ if (errorList == null) {
+ // try with the default "errorList"
+ if (!compiler.checkReference(tag, ERROR_LIST_DEFAULT, false, ERROR_LIST_ATTRIBUTE)) {
+ return false;
+ }
+ errorList = ERROR_LIST_DEFAULT;
+ } else {
+ if (!compiler.checkReference(tag, errorList, true, ERROR_LIST_ATTRIBUTE)) {
+ return true;
+ }
+ }
+
+ String code = SwingValidatorUtil.class.getName() + ".registerErrorListMouseListener(" + errorList + ");";
+ appendAdditionCode(code);
+
+ return false;
+ }
+
+ protected boolean addErrorTable(Element tag, JAXXCompiler compiler) {
+
+ if (errorTable == null) {
+ // try with the default "errorList"
+ if (!compiler.checkReference(tag, ERROR_TABLE_DEFAULT, false, ERROR_TABLE_ATTRIBUTE)) {
+ return false;
+ }
+ errorTable = ERROR_TABLE_DEFAULT;
+ } else {
+ if (!compiler.checkReference(tag, errorTable, true, ERROR_TABLE_ATTRIBUTE)) {
+ return true;
+ }
+ }
+
+ String code = SwingValidatorUtil.class.getName() + ".registerErrorTableMouseListener(" + errorTable + ");";
+ appendAdditionCode(code);
+
+ return false;
+ }
+
+ protected boolean addBean(Element tag, BeanValidatorHandler handler, JAXXCompiler compiler) {
+
+ if (beanClass == null || beanClass.isEmpty()) {
+ // try to guest beanClass from bean attribute
+ if (bean != null && !bean.isEmpty()) {
+ beanClass = compiler.getSymbolTable().getClassTagIds().get(bean);
+ if (beanClass == null) {
+ compiler.reportError("could not find class of the bean '" + bean + "', and no beanClass was setted");
+ return true;
+ }
+ }
+ }
+ if (beanClass == null) {
+ compiler.reportError("tag '" + tag + "' requires a 'beanClass' attribute, and could not guest it from 'bean' attribute (no bean attribute setted...)");
+ return true;
+ }
+
+ JAXXBeanInfo beanInfo = getBeanDescriptor(compiler);
+ if (beanInfo == null) {
+ compiler.reportError(tag, "could not find descriptor of class " + beanClass);
+ return true;
+ }
+
+ String beanInitializer = null;
+ if (bean != null) {
+
+ if (bean.startsWith("{") && bean.endsWith("}")) {
+
+ // just has an intializer
+ beanInitializer = bean.substring(1, bean.length() - 1);
+ // this is not a real bean, so delete it
+ bean = null;
+ } else {
+
+ if (!compiler.checkReference(tag, bean, true, BEAN_ATTRIBUTE)) {
+ // could not find bean in compiled object
+ return true;
+ }
+
+ if (isBeanUsedByValidator(compiler, bean)) {
+ compiler.reportError("the bean '" + bean + "' is already used in another the validator, can not used it in '" + tag + "'");
+ return true;
+ }
+
+ /*if (beanInitializer != null) {
+ compiler.reportWarning("tag '" + tag + "' found a 'bean' and a 'beanInitializer' attributes, 'beanInitializer' is skipped");
+ }*/
+ beanInitializer = bean;
+ }
+ }
+
+ if (beanInitializer != null) {
+ String code = handler.getSetPropertyCode(getJavaCode(), BEAN_ATTRIBUTE, compiler.checkJavaCode(beanInitializer), compiler);
+ appendAdditionCode(code);
+ }
+
+ String beanClassName = beanInfo.getJAXXBeanDescriptor().getClassDescriptor().getName();
+ // contextName must be in constructor to able to init validator with his correct contextName
+ setConstructorParams(beanClassName + ".class, " + TypeManager.getJavaCode(contextName));
+ // add generic type to validator
+ setGenericTypes(new String[]{beanClassName});
+
+ if (getAutoField()) {
+ registerAutoFieldBean(tag, compiler, beanInfo);
+ }
+
+ if (getBeanDescriptor(compiler) != null) {
+
+ // add fieldrepresentation invocations
+ addFieldRepresentations(tag, compiler);
+
+ // register the validator in compiler
+ registerValidator(compiler, this);
+
+ }
+
+ return false;
+ }
+
+ private void registerValidator(JAXXCompiler compiler, CompiledBeanValidator compiledBeanValidator) {
+ List<CompiledBeanValidator> vals = validators.get(compiler);
+ if (vals == null) {
+ vals = new ArrayList<CompiledBeanValidator>();
+ validators.put(compiler, vals);
+ }
+ vals.add(compiledBeanValidator);
+ List<String> ids = validatedComponents.get(compiler);
+ if (ids == null) {
+ ids = new ArrayList<String>();
+ validatedComponents.put(compiler, ids);
+ }
+ ids.addAll(compiledBeanValidator.getFields().values());
+ }
+
+ protected void addFieldRepresentations(Element tag, JAXXCompiler compiler) {
+ for (Entry<String, String> entry : fields.entrySet()) {
+ String propertyName = entry.getKey();
+ String component = entry.getValue();
+ if (!checkBeanProperty(compiler, propertyName)) {
+ // property not find on bean
+ continue;
+ }
+ if (!compiler.checkReference(tag, component, true, null)) {
+ // editor component not find on ui
+ continue;
+ }
+ /*if (compiler.isComponentUsedByValidator(component)) {
+ // component is already used by another validator
+ compiler.reportError("component '" + component + "' is already used by another validator.");
+ continue;
+ }*/
+ String keyCode = TypeManager.getJavaCode(propertyName);
+ appendAdditionCode(getJavaCode() + ".setFieldRepresentation(" + keyCode + ", " + component + ");");
+ }
+ }
+
+ protected void registerAutoFieldBean(Element tag, JAXXCompiler compiler, JAXXBeanInfo beanInfo) {
+ for (JAXXPropertyDescriptor beanProperty : beanInfo.getJAXXPropertyDescriptors()) {
+ String descriptionName = beanProperty.getName();
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("try to bind on bean " + beanInfo.getJAXXBeanDescriptor().getName() + " property " + descriptionName);
+ }
+ if (beanProperty.getWriteMethodDescriptor() == null) {
+ // read-only property
+ continue;
+ }
+ if (fields.containsKey(descriptionName)) {
+ // already defined in field
+ continue;
+ }
+ if (excludeFields.containsKey(descriptionName)) {
+ // exclude field
+ continue;
+ }
+ if (!compiler.checkReference(tag, descriptionName, getStrictMode(), null)) {
+ // no editor component found
+ continue;
+ }
+ // ok add the field mapping
+ registerField(descriptionName, descriptionName, compiler);
+ }
+
+ for (Entry<String, String> entry : excludeFields.entrySet()) {
+ String key = entry.getKey();
+ if (fields.containsKey(key)) {
+ compiler.reportWarning("field '" + key + "' can not be used and excluded at same time ! (field is skipped) for validator " + this);
+ fields.remove(key);
+ }
+ }
+ }
+
+ public void registerField(String id, String component, JAXXCompiler compiler) {
+ if (fields.containsKey(id)) {
+ compiler.reportError("duplicate field '" + id + "' for validator " + this);
+ } else {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("add field <" + id + ":" + component + ">");
+ }
+ fields.put(id, component);
+ }
+ }
+
+ public void registerExcludeField(String id, String component, JAXXCompiler compiler) {
+ if (excludeFields.containsKey(id)) {
+ compiler.reportError("duplicate field '" + id + "' for validator " + this);
+ } else {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info("add excludeField <" + id + ":" + component + ">");
+ }
+ excludeFields.put(id, component);
+ }
+ }
+
+ protected boolean checkBeanProperty(JAXXCompiler compiler, String propertyName) {
+
+ for (JAXXPropertyDescriptor beanProperty : getBeanDescriptor(compiler).getJAXXPropertyDescriptors()) {
+ if (beanProperty.getName().equals(propertyName)) {
+ if (beanProperty.getWriteMethodDescriptor() == null) {
+ // read-onlyproperty
+ compiler.reportError("could not bind the readonly property '" + propertyName + "' on bean [" + getBean() + "] ");
+ return false;
+ }
+ return true;
+ }
+ }
+ compiler.reportError("could not find the property '" + propertyName + "' on bean [" + getBean() + "] ");
+ return false;
+ }
+ }
+
+ /**
+ * Test if a given bean is attached to a validator.
+ *
+ * @param compiler current compiler to use
+ * @param beanId the bean to test
+ * @return <code>true</code> if the given bean is attached to a validator, <code>false</code> otherwise
+ */
+ public static boolean isBeanUsedByValidator(JAXXCompiler compiler, String beanId) {
+ List<CompiledBeanValidator> beanValidatorList = validators.get(compiler);
+ if (beanValidatorList != null) {
+ for (CompiledBeanValidator validator : beanValidatorList) {
+ if (beanId.equals(validator.getBean())) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * @param compiler compiler to use
+ * @return <code>true</code> if some validators were detected, <code>false</code> otherwise
+ */
+ public static boolean hasValidator(JAXXCompiler compiler) {
+ List<CompiledBeanValidator> beanValidatorList = validators.get(compiler);
+ return beanValidatorList != null && !beanValidatorList.isEmpty();
+ }
+
+ /**
+ * Test if a given CompiledObject is attached to a validator.
+ *
+ * @param compiler compiler to use
+ * @param componentId the compiled object to test
+ * @return <code>true</code> if the given compiled object is attached to a validator, <code>false</code> otherwise
+ */
+ public static boolean isComponentUsedByValidator(JAXXCompiler compiler, String componentId) {
+ List<String> ids = validatedComponents.get(compiler);
+ return ids != null && ids.contains(componentId);
+ }
+
+ public static List<CompiledBeanValidator> getValidators(JAXXCompiler compiler) {
+ return validators.get(compiler);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/ExcludeFieldValidatorHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/ExcludeFieldValidatorHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,85 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.validator;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+public class ExcludeFieldValidatorHandler implements TagHandler {
+
+ public static final String TAG = "excludeField";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String COMPONENT_ATTRIBUTE = "component";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(ExcludeFieldValidatorHandler.class);
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+ //todo check there is no child
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.debug(tag);
+ }
+
+ if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag);
+ return;
+ }
+
+ CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent();
+ if (!info.getAutoField()) {
+ compiler.reportError(TAG + " tag can not be used without an 'autoField' validator : " + tag);
+ return;
+ }
+ String name = tag.getAttribute(NAME_ATTRIBUTE);
+ String component = tag.getAttribute(COMPONENT_ATTRIBUTE);
+ if (name == null || name.trim().isEmpty()) {
+ compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
+ return;
+ }
+ name = name.trim();
+ if (component == null || component.trim().isEmpty()) {
+ // try to use the name as component
+ if (!compiler.checkReference(tag, name, false, name)) {
+ compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found");
+ return;
+ }
+ component = name;
+ }
+ component = component.trim();
+
+ // check component is not already used by this compiled object
+ if (info.getFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator");
+ return;
+ }
+ if (info.getExcludeFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator");
+ return;
+ }
+ // check component exist (again perharps, but let the error knows exactly which tag failed...)
+ if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) {
+ // add a field
+ info.registerField(name, component, compiler);
+ }
+
+
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/validator/FieldValidatorHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tags/validator/FieldValidatorHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,78 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.tags.validator;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tags.TagHandler;
+import jaxx.compiler.tags.validator.BeanValidatorHandler.CompiledBeanValidator;
+import jaxx.runtime.validator.swing.SwingValidator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.w3c.dom.Element;
+
+import java.io.IOException;
+
+public class FieldValidatorHandler implements TagHandler {
+
+ public static final String TAG = "field";
+ public static final String NAME_ATTRIBUTE = "name";
+ public static final String COMPONENT_ATTRIBUTE = "component";
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(FieldValidatorHandler.class);
+
+ @Override
+ public void compileFirstPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+ //todo check there is no child
+ }
+
+ @Override
+ public void compileSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ if (compiler.getConfiguration().isVerbose()) {
+ log.info(tag);
+ }
+
+ if (!ClassDescriptorLoader.getClassDescriptor(SwingValidator.class).isAssignableFrom(compiler.getOpenComponent().getObjectClass())) {
+ compiler.reportError(TAG + " tag may only appear within " + BeanValidatorHandler.TAG + " tag but was " + tag);
+ return;
+ }
+
+ CompiledBeanValidator info = (CompiledBeanValidator) compiler.getOpenComponent();
+
+ String name = tag.getAttribute(NAME_ATTRIBUTE);
+ String component = tag.getAttribute(COMPONENT_ATTRIBUTE);
+ if (name == null || name.trim().isEmpty()) {
+ compiler.reportError(TAG + " tag requires a " + NAME_ATTRIBUTE + " attribute");
+ return;
+ }
+ name = name.trim();
+ if (component == null || component.trim().isEmpty()) {
+ // try to use the name as component
+ if (!compiler.checkReference(tag, name, false, name)) {
+ compiler.reportError(TAG + " tag requires a " + COMPONENT_ATTRIBUTE + " attribute, try to use the name attribute [" + name + "] for the component, but no such component found");
+ return;
+ }
+ component = name;
+ }
+ component = component.trim();
+
+ // check component is not already used by this compiled object
+ if (info.getFields().containsValue(component)) {
+ compiler.reportError(TAG + " tag found a attribute " + COMPONENT_ATTRIBUTE + " [" + component + "] already used in this validator");
+ return;
+ }
+ // check component exist (again perharps, but let the error knows exactly which tag failed...)
+ if (compiler.checkReference(tag, component, true, COMPONENT_ATTRIBUTE)) {
+ // add a field
+ info.registerField(name, component, compiler);
+ }
+
+
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/PrintTagInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,117 @@
+package jaxx.compiler.tools;
+
+import jaxx.compiler.tags.*;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.beans.JAXXPropertyDescriptor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.reflect.MethodDescriptor;
+
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.OutputStreamWriter;
+
+/** Generates information about a tag for use on the jaxxframework.org web site. */
+public class PrintTagInfo {
+ /**
+ * Displays information about the class name in arg[0].
+ *
+ * @param arg command-line arguments
+ * @throws Exception if an error occurs
+ */
+ public static void main(String[] arg) throws Exception {
+ if (arg.length < 1) {
+ throw new IllegalArgumentException("programm needs at least two parameters : the file where to put the result, and at least one fqn class to treate");
+ }
+ String firstarg = arg[0];
+ boolean toFile = false;
+ BufferedWriter w;
+ if (firstarg.startsWith("file:")) {
+ w = new BufferedWriter(new FileWriter(firstarg.substring(5)));
+ toFile = true;
+ } else {
+ w = new BufferedWriter(new OutputStreamWriter(System.out));
+ }
+
+ try {
+ JAXXCompilerLaunchor.loadLibraries(false);
+ for (int i = toFile ? 1 : 0; i < arg.length; i++) {
+ String className = arg[i];
+ treateClass(w, className);
+ }
+ } finally {
+ w.flush();
+ w.close();
+ }
+
+ }
+
+ protected static void treateClass(BufferedWriter w, String className) throws ClassNotFoundException, IOException {
+
+ ClassDescriptor beanClass = ClassDescriptorLoader.getClassDescriptor(className);
+ DefaultObjectHandler handler = TagManager.getTagHandler(beanClass);
+
+ DefaultObjectHandler superHandler = TagManager.getTagHandler(beanClass.getSuperclass());
+
+ // dump all bean properties
+ w.append("Properties in ").append(String.valueOf(beanClass));
+ w.newLine();
+ JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
+ JAXXPropertyDescriptor[] superProperties = superHandler.getJAXXBeanInfo().getJAXXPropertyDescriptors();
+ for (JAXXPropertyDescriptor property : properties) {
+ if (property.getWriteMethodDescriptor() == null) {
+ continue;
+ }
+
+ boolean found = false;
+ String name = property.getName();
+ for (JAXXPropertyDescriptor superProperty : superProperties) {
+ if (superProperty.getName().equals(name)) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ if (property.getPropertyType() == null) {
+ System.err.println(name + " has null type");
+ } else {
+ w.append("{{EquivalentAttribute|");
+ w.append(name);
+ w.append("|");
+ w.append(className.replace('.', '/'));
+ w.append("|set");
+ w.append(org.apache.commons.lang.StringUtils.capitalize(name));
+ w.append("|");
+ w.append(JAXXCompiler.getCanonicalName(property.getPropertyType()));
+ w.append("}}");
+ w.append("|-");
+ w.newLine();
+ }
+ }
+ }
+
+ w.newLine();
+ w.newLine();
+
+ // dump all bound methods
+ dumpMethods(w, beanClass, handler);
+ }
+
+ protected static void dumpMethods(BufferedWriter w, ClassDescriptor beanClass, DefaultObjectHandler handler) throws IOException {
+ MethodDescriptor[] methods = beanClass.getMethodDescriptors();
+ w.append("Bound methods in ").append(String.valueOf(beanClass));
+ w.newLine();
+ for (MethodDescriptor method : methods) {
+ try {
+ if (handler.isMemberBound(method.getName())) {
+ w.append("* <tt>").append(method.getName()).append("()</tt>");
+ w.newLine();
+ }
+ } catch (Throwable e) {
+ // ignore ?
+ }
+ }
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/PrintTagInfo.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/AbstractContextNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,19 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public abstract class AbstractContextNode implements ContextNode {
+ private List<ContextNode> arguments = new ArrayList<ContextNode>();
+
+
+ @Override
+ public void addArgument(ContextNode node) {
+ arguments.add(node);
+ }
+
+ @Override
+ public ContextNode[] getArguments() {
+ return arguments.toArray(new ContextNode[arguments.size()]);
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/AbstractContextNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/CapturedObject.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,146 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler;
+
+import java.awt.Component;
+import java.util.HashMap;
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+public class CapturedObject extends AbstractContextNode {
+ private String className;
+ private ObjectHandler handler;
+ /** Maps children to their constraints. */
+ private Map<CapturedObject, ContextNode> children = new LinkedHashMap<CapturedObject, ContextNode>();
+ private CapturedObject parent;
+ private Map<String, String> properties = new LinkedHashMap<String, String>();
+ private Map<String, Object> additionalData = new HashMap<String, Object>();
+ private StringBuffer innerXML = new StringBuffer();
+ private StringBuffer script = new StringBuffer();
+ private boolean inlineable = true;
+ private JAXXCapture capture;
+
+ public CapturedObject(ObjectHandler handler, String className, JAXXCapture capture) {
+ this.handler = handler;
+ this.className = className;
+ this.capture = capture;
+ }
+
+
+ public ObjectHandler getObjectHandler() {
+ return handler;
+ }
+
+
+ public void addChild(CapturedObject child, ContextNode constraints) {
+ children.put(child, constraints);
+ child.setParent(this);
+ }
+
+
+ public CapturedObject[] getChildren() {
+ return children.keySet().toArray(new CapturedObject[children.size()]);
+ }
+
+
+ public CapturedObject getParent() {
+ return parent;
+ }
+
+
+ public void setParent(CapturedObject parent) {
+ this.parent = parent;
+ }
+
+
+ public ContextNode getConstraints(CapturedObject child) {
+ return children.get(child);
+ }
+
+
+ public String getClassName() {
+ return className;
+ }
+
+
+ public String getProperty(String key) {
+ return properties.get(key);
+ }
+
+
+ public void setProperty(String key, String value) {
+ properties.put(key, value);
+ }
+
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+
+ public Object getAdditionalData(String key) {
+ return additionalData.get(key);
+ }
+
+
+ public void setAdditionalData(String key, Object value) {
+ additionalData.put(key, value);
+ }
+
+
+ public Map<String, Object> getAdditionalData() {
+ return additionalData;
+ }
+
+
+ public void setInlineable(boolean inlineable) {
+ this.inlineable = inlineable;
+ }
+
+
+ public boolean isInlineable() {
+ try {
+ return script.length() == 0 && !Component.class.isAssignableFrom(Class.forName(className, true, capture.getClassLoader())) && inlineable;
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ public void appendInnerXML(String xml) {
+ if (this.innerXML.length() > 0) {
+ this.innerXML.append(JAXXCompiler.getLineSeparator());
+ }
+ this.innerXML.append(xml);
+ }
+
+
+ public String getInnerXML() {
+ return innerXML.toString();
+ }
+
+
+ public void appendScriptCode(String script) {
+ if (this.script.length() > 0) {
+ this.script.append(JAXXCompiler.getLineSeparator());
+ }
+ this.script.append(script);
+ }
+
+
+ public String getScriptCode() {
+ return script.toString();
+ }
+
+
+ public String getXML(JAXXCapture capture) {
+ return getObjectHandler().getXML(this, capture);
+ }
+
+ @Override
+ public String toString() {
+ return "CapturedObject[" + getProperty("id") + ", " + className + "]";
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/CapturedObject.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/ContextNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,8 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public interface ContextNode {
+
+ void addArgument(ContextNode node);
+
+ ContextNode[] getArguments();
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ContextNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/JAXXCapture.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,378 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+import jaxx.compiler.ClassMap;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import jaxx.compiler.tools.jaxxcapture.handlers.JTabbedPaneHandler;
+import jaxx.compiler.tools.jaxxcapture.handlers.ObjectHandler;
+import jaxx.compiler.tools.jaxxcapture.handlers.TableHandler;
+import jaxx.compiler.types.TypeManager;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+import org.w3c.dom.Text;
+import org.xml.sax.SAXException;
+
+import javax.swing.JDialog;
+import javax.swing.JFrame;
+import javax.swing.JTabbedPane;
+import javax.swing.JWindow;
+import javax.swing.SwingUtilities;
+import java.awt.AWTEvent;
+import java.awt.Component;
+import java.awt.Container;
+import java.awt.EventQueue;
+import java.awt.Toolkit;
+import java.awt.Window;
+import java.awt.event.MouseEvent;
+import java.beans.XMLEncoder;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Stack;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.Manifest;
+
+public class JAXXCapture {
+
+ private static ClassMap<Object> objectHandlers = new ClassMap<Object>();
+
+ static {
+ //TODO make a serviceLoader mecanism to allow inter-module loading
+ objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(Object.class), new ObjectHandler());
+ objectHandlers.put(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), new JTabbedPaneHandler());
+ try {
+ objectHandlers.put(ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.Table"), new TableHandler());
+ } catch (ClassNotFoundException e) {
+ System.err.println(e);
+ }
+ }
+ private Map<String, Object> sourceObjects = new HashMap<String, Object>();
+ private Map<String, CapturedObject> capturedObjects = new HashMap<String, CapturedObject>();
+ private ClassLoader classLoader;
+ private int count;
+
+ private static class CaptureEventQueue extends EventQueue {
+
+ private ClassLoader classLoader;
+
+ private CaptureEventQueue(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ @Override
+ public void dispatchEvent(AWTEvent event) {
+ if (event.getID() == MouseEvent.MOUSE_PRESSED && ((MouseEvent) event).isControlDown()) {
+ Component target = ((MouseEvent) event).getComponent();
+ if (!(target instanceof Window)) {
+ target = SwingUtilities.getWindowAncestor(target);
+ }
+ if (target instanceof JFrame) {
+ target = ((JFrame) target).getContentPane();
+ } else if (target instanceof JDialog) {
+ target = ((JDialog) target).getContentPane();
+ }
+ if (target instanceof JWindow) {
+ target = ((JWindow) target).getContentPane();
+ }
+ if (target != null) {
+ Thread.currentThread().setContextClassLoader(classLoader);
+ JAXXCapture capture = new JAXXCapture(classLoader);
+ capture.applyNames(target);
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ XMLEncoder encoder = new XMLEncoder(buffer);
+ encoder.writeObject(target);
+ encoder.close();
+ try {
+ System.err.println(new String(buffer.toByteArray()));
+ System.out.println(capture.convertToJAXX(new ByteArrayInputStream(buffer.toByteArray())));
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
+ }
+ }
+ super.dispatchEvent(event);
+ }
+ }
+
+ private JAXXCapture(ClassLoader classLoader) {
+ this.classLoader = classLoader;
+ }
+
+ public ClassLoader getClassLoader() {
+ return classLoader;
+ }
+
+ public Map<String, CapturedObject> getCapturedObjects() {
+ return capturedObjects;
+ }
+
+ private void applyNames(Component target) {
+ String name = target.getName();
+ if (name == null || sourceObjects.containsKey(name) || !CompiledObject.isValidID(name)) {
+ do {
+ name = "Object" + ++count;
+ } while (sourceObjects.containsKey(name));
+ }
+ target.setName(name);
+ assert !sourceObjects.containsKey(name) : "ID " + name + " is already registered";
+ sourceObjects.put(name, target);
+
+ if (target instanceof Container) {
+ Container container = (Container) target;
+ for (int i = 0; i < container.getComponentCount(); i++) {
+ applyNames(container.getComponent(i));
+ }
+ }
+ }
+
+ public static String getText(Element tag) { // NOT a safe general-purpose implementation!
+ return ((Text) tag.getChildNodes().item(0)).getData();
+ }
+
+ private String getArgumentsCode(ContextNode[] arguments) {
+ StringBuffer result = new StringBuffer();
+ result.append('(');
+ for (int i = 0; i < arguments.length; i++) {
+ if (i != 0) {
+ result.append(", ");
+ }
+ result.append(getJavaCode(arguments[i]));
+ }
+ result.append(')');
+ return result.toString();
+ }
+
+ public String getJavaCode(ContextNode node) {
+ StringBuffer result = new StringBuffer();
+ if (node instanceof PropertyNode) {
+ ContextNode[] arguments = node.getArguments();
+ result.append(arguments.length == 0 ? "get" : "set");
+ result.append(org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty()));
+ result.append(getArgumentsCode(arguments));
+ } else if (node instanceof MethodNode) {
+ result.append((((MethodNode) node).getMethodName()));
+ result.append(getArgumentsCode(node.getArguments()));
+ } else if (node instanceof CapturedObject) {
+ CapturedObject object = (CapturedObject) node;
+ if (object.isInlineable()) {
+ result.append("new ");
+ result.append(object.getClassName());
+ result.append(getArgumentsCode(node.getArguments()));
+ } else {
+ String id = object.getProperty("id");
+ assert id != null;
+ result.append(id);
+ }
+ } else if (node instanceof ValueNode) {
+ result.append(TypeManager.getJavaCode(((ValueNode) node).getValue()));
+ } else if (node instanceof LiteralNode) {
+ result.append(((LiteralNode) node).getJavaCode());
+ } else {
+ throw new IllegalArgumentException("unrecognized node type: " + node);
+ }
+ return result.toString();
+ }
+
+ // returns the best matching method for the specified argument types
+ private static Method getMethod(Class<?> target, String methodName, Class<?>[] arguments) {
+ try {
+ // use the package-private class java.beans.ReflectionUtils to resolve the method. This isn't 100% safe, but it's better than
+ // having to rewrite the resolution myself.
+ Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils");
+ Method getMethod = reflectionUtils.getDeclaredMethod("getMethod", new Class<?>[]{Class.class, String.class, Class[].class});
+ getMethod.setAccessible(true);
+ return (Method) getMethod.invoke(null, target, methodName, arguments);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ // returns the best matching constructor for the specified argument types
+ private static Constructor<?> getConstructor(Class<?> target, Class<?>[] arguments) {
+ try {
+ // use the package-private class java.beans.ReflectionUtils to resolve the constructor. This isn't 100% safe, but it's better than
+ // having to rewrite the resolution myself.
+ Class<?> reflectionUtils = Class.forName("java.beans.ReflectionUtils");
+ Method getConstructor = reflectionUtils.getDeclaredMethod("getConstructor", new Class<?>[]{Class.class, Class[].class});
+ getConstructor.setAccessible(true);
+ return (Constructor<?>) getConstructor.invoke(null, target, arguments);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ private Object createInstance(CapturedObject object) {
+ try {
+ ContextNode[] argumentNodes = object.getArguments();
+ Object[] arguments = new Object[argumentNodes.length];
+ Class<?>[] argumentTypes = new Class<?>[argumentNodes.length];
+ for (int j = 0; j < argumentNodes.length; j++) {
+ if (argumentNodes[j] instanceof ValueNode) {
+ arguments[j] = ((ValueNode) argumentNodes[j]).getValue();
+ argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null;
+ } else if (argumentNodes[j] instanceof CapturedObject) {
+ arguments[j] = createInstance((CapturedObject) argumentNodes[j]);
+ argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null;
+ }
+ }
+ Constructor<?> constructor = getConstructor(Class.forName(object.getClassName(), true, classLoader), argumentTypes);
+ return constructor.newInstance(arguments);
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ public String getJavaCode(Stack/*<ContextNode>*/ context) {
+ CapturedObject contextCapturedObject = (CapturedObject) context.get(0);
+ StringBuffer result = new StringBuffer();
+ int start = 1;
+ for (int i = context.size() - 1; i > 1; i--) {
+ if (context.get(i) instanceof CapturedObject) {
+ start = i;
+ contextCapturedObject = (CapturedObject) context.get(i);
+ break;
+ }
+ }
+ Object contextObject = sourceObjects.get(contextCapturedObject.getProperty("id"));
+ Class<?> contextClass = contextObject != null ? contextObject.getClass() : null;
+
+ for (int i = start; i < context.size(); i++) {
+ ContextNode node = (ContextNode) context.get(i);
+ if (contextObject != null && (node instanceof MethodNode || node instanceof PropertyNode)) {
+ // need to follow the call chain so we can insert typecasts as necessary
+ try {
+ String methodName;
+ ContextNode[] argumentNodes = node.getArguments();
+ if (node instanceof MethodNode) {
+ methodName = ((MethodNode) node).getMethodName();
+ } else {
+ methodName = (argumentNodes.length == 0 ? "get" : "set") + org.apache.commons.lang.StringUtils.capitalize(((PropertyNode) node).getProperty());
+ }
+ Object[] arguments = new Object[argumentNodes.length];
+ Class<?>[] argumentTypes = new Class<?>[argumentNodes.length];
+ for (int j = 0; j < argumentNodes.length; j++) {
+ if (argumentNodes[j] instanceof ValueNode) {
+ arguments[j] = ((ValueNode) argumentNodes[j]).getValue();
+ argumentTypes[j] = arguments[j] != null ? arguments[j].getClass() : null;
+ } else if (argumentNodes[j] instanceof CapturedObject) {
+ arguments[j] = createInstance((CapturedObject) argumentNodes[j]);
+ argumentTypes[j] = arguments[j].getClass();
+ } else if (argumentNodes[j] instanceof LiteralNode) {
+ arguments[j] = ((LiteralNode) argumentNodes[j]).getValue();
+ argumentTypes[j] = arguments[j].getClass();
+ } else {
+ throw new IllegalArgumentException("unsupported argument type: " + argumentNodes[j]);
+ }
+ }
+
+ Method method = getMethod(contextClass, methodName, argumentTypes);
+ if (method == null) {
+ // could not find method in contextClass, must be defined in a subclass -- insert a typecast
+ result.insert(0, "((" + getOutputName(contextObject.getClass()) + ") ");
+ result.append(')');
+ method = getMethod(contextObject.getClass(), methodName, argumentTypes);
+ }
+ if (method == null) {
+ throw new RuntimeException("could not find method " + methodName + Arrays.asList(argumentTypes) + " in " + contextObject.getClass() + " (context: " + context + ")");
+ }
+ contextObject = method.invoke(contextObject, arguments);
+ contextClass = method.getReturnType();
+ } catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ if (i > start) {
+ result.append('.');
+ }
+
+ result.append(getJavaCode(node));
+ }
+ return result + ";";
+ }
+
+ private String getOutputName(Class<?> c) {
+ return c.getName();
+ }
+
+ public CapturedObject processObject(Element objectTag, Stack<ContextNode> context) {
+ String className = objectTag.getAttribute("class");
+ ObjectHandler handler;
+ if (className.length() > 0) {
+ try {
+ ClassDescriptor descriptor = ClassDescriptorLoader.getClassDescriptor(className, classLoader);
+ handler = (ObjectHandler) objectHandlers.get(descriptor);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ handler = (ObjectHandler) objectHandlers.get(ClassDescriptorLoader.getClassDescriptor(Object.class));
+ }
+
+ return handler.processObject(objectTag, context, this);
+ }
+
+ private synchronized String convertToJAXX(InputStream beansXML) throws IOException {
+ try {
+ Document document = JAXXCompiler.parseDocument(beansXML);
+ Element rootElement = document.getDocumentElement();
+ NodeList nodes = rootElement.getChildNodes();
+ Stack<ContextNode> context = new Stack<ContextNode>();
+ for (int i = 0; i < nodes.getLength(); i++) {
+ Node child = nodes.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) child;
+ if (!element.getTagName().equals("object")) {
+ throw new Error("expected tag 'object', found '" + element.getTagName() + "'");
+ }
+ CapturedObject root = processObject(element, context);
+ for (CapturedObject object : capturedObjects.values()) { // add all orphan objects to the root, so any non-inlineable ones have their XML created
+ if (object.getParent() == null && object != root) {
+ root.addChild(object, null);
+ }
+ }
+ return root.getXML(this);
+ }
+ }
+ return null;
+ } catch (SAXException e) {
+ throw new RuntimeException(e);
+ } finally {
+ reset();
+ }
+ }
+
+ private void reset() {
+ sourceObjects.clear();
+ capturedObjects.clear();
+ count = 0;
+ }
+
+ public static void main(String[] arg) throws Exception {
+ File file = new File(arg[0]);
+ JarFile jarFile = new JarFile(file);
+ ClassLoader classLoader = new URLClassLoader(new URL[]{file.toURI().toURL()});
+ Thread.currentThread().setContextClassLoader(classLoader);
+ EventQueue systemQueue = Toolkit.getDefaultToolkit().getSystemEventQueue();
+ systemQueue.push(new CaptureEventQueue(classLoader));
+ Manifest mf = jarFile.getManifest();
+ String mainClassName = mf.getMainAttributes().getValue(Attributes.Name.MAIN_CLASS);
+ Class<?> mainClass = Class.forName(mainClassName, true, classLoader);
+ Method main = mainClass.getMethod("main", String[].class);
+ main.invoke(null, new Object[]{new String[0]});
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/JAXXCapture.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/LiteralNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,20 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class LiteralNode extends AbstractContextNode {
+ private String javaCode;
+ private Object value;
+
+ public LiteralNode(String javaCode, Object value) {
+ this.javaCode = javaCode;
+ this.value = value;
+ }
+
+
+ public String getJavaCode() {
+ return javaCode;
+ }
+
+ public Object getValue() {
+ return value;
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/LiteralNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/MethodNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,19 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class MethodNode extends AbstractContextNode {
+ private String methodName;
+
+ public MethodNode(String methodName) {
+ this.methodName = methodName;
+ }
+
+
+ public String getMethodName() {
+ return methodName;
+ }
+
+ @Override
+ public String toString() {
+ return "Method[" + methodName + ", " + java.util.Arrays.asList(getArguments()) + "]";
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/MethodNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/PropertyNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,19 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class PropertyNode extends AbstractContextNode {
+ private String property;
+
+ public PropertyNode(String property) {
+ this.property = property;
+ }
+
+
+ public String getProperty() {
+ return property;
+ }
+
+
+ public String toString() {
+ return "Property[" + property + ", " + java.util.Arrays.asList(getArguments()) + "]";
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/PropertyNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/ValueNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,14 @@
+package jaxx.compiler.tools.jaxxcapture;
+
+public class ValueNode extends AbstractContextNode {
+ private Object value;
+
+ public ValueNode(Object value) {
+ this.value = value;
+ }
+
+
+ public Object getValue() {
+ return value;
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/ValueNode.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/handlers/JTabbedPaneHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,26 @@
+package jaxx.compiler.tools.jaxxcapture.handlers;
+
+import jaxx.compiler.tools.jaxxcapture.ContextNode;
+import jaxx.compiler.tools.jaxxcapture.JAXXCapture;
+import jaxx.compiler.tools.jaxxcapture.MethodNode;
+import org.w3c.dom.Element;
+
+import java.util.Arrays;
+import java.util.Stack;
+
+public class JTabbedPaneHandler extends ObjectHandler {
+
+ @Override
+ protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ String methodName = tag.getAttribute("method");
+ if (methodName.equals("addTab")) {
+ MethodNode addTab = new MethodNode(methodName);
+ context.push(addTab);
+ processChildren(tag, context, capture);
+ context.pop();
+ System.err.println(Arrays.asList(addTab.getArguments()));
+ } else {
+ super.evaluateMethod(tag, context, capture);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/JTabbedPaneHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/handlers/ObjectHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,323 @@
+package jaxx.compiler.tools.jaxxcapture.handlers;
+
+import jaxx.compiler.JavaFile;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.tools.jaxxcapture.CapturedObject;
+import jaxx.compiler.tools.jaxxcapture.ContextNode;
+import jaxx.compiler.tools.jaxxcapture.JAXXCapture;
+import jaxx.compiler.tools.jaxxcapture.LiteralNode;
+import jaxx.compiler.tools.jaxxcapture.MethodNode;
+import jaxx.compiler.tools.jaxxcapture.PropertyNode;
+import jaxx.compiler.tools.jaxxcapture.ValueNode;
+import org.w3c.dom.Element;
+import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
+
+import java.awt.Container;
+import java.lang.reflect.Field;
+import java.util.Map;
+import java.util.Stack;
+
+public class ObjectHandler {
+ private static int count;
+
+ protected CapturedObject createCapturedObject(String className, JAXXCapture capture) {
+ return new CapturedObject(this, className, capture);
+ }
+
+
+ // returns true if the tag has any "void" children
+ protected boolean processChildren(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ boolean result = false;
+ NodeList children = tag.getChildNodes();
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element innerTag = (Element) child;
+ if (innerTag.getTagName().equals("void")) {
+ result = true;
+ }
+ evaluate(innerTag, context, capture);
+ }
+ }
+ return result;
+ }
+
+
+ protected void evaluateProperty(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ // determine containing object
+ CapturedObject contextObject = null;
+ for (int i = context.size() - 1; i >= 0; i--) {
+ if (context.get(i) instanceof CapturedObject) {
+ contextObject = (CapturedObject) context.get(i);
+ break;
+ }
+ }
+ assert contextObject != null;
+
+ String property = tag.getAttribute("property");
+ if (!property.equals("actionCommand")) { // filter out actionCommand due to screwiness in XMLEncoder's handling of it
+ Object current = context.peek();
+ PropertyNode newContext = new PropertyNode(property);
+ context.push(newContext);
+ boolean voidChildren = processChildren(tag, context, capture);
+
+ ContextNode[] arguments = newContext.getArguments();
+ if (arguments.length == 1) {
+ if (current instanceof CapturedObject && arguments[0] instanceof ValueNode) // simple property assignment
+ {
+ ((CapturedObject) current).setProperty(property, dataBindingEncode(String.valueOf(((ValueNode) arguments[0]).getValue())));
+ } else if (current instanceof CapturedObject && arguments[0] instanceof CapturedObject && ((CapturedObject) arguments[0]).isInlineable()) // simple data binding
+ {
+ ((CapturedObject) current).setProperty(property, "{" + capture.getJavaCode(arguments[0]) + "}");
+ } else {
+ contextObject.setInlineable(false);
+ contextObject.appendScriptCode(capture.getJavaCode(context));
+ }
+ } else if (!voidChildren) {
+ contextObject.setInlineable(false);
+ contextObject.appendScriptCode(capture.getJavaCode(context));
+ }
+
+ assert context.peek() == newContext;
+ context.pop();
+ }
+ }
+
+
+ protected void evaluateAdd(CapturedObject contextObject, CapturedObject child, ContextNode constraints) {
+ contextObject.addChild(child, constraints);
+ }
+
+
+ protected void evaluateMethod(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ // determine containing object
+ CapturedObject contextObject = null;
+ for (int i = context.size() - 1; i >= 0; i--) {
+ if (context.get(i) instanceof CapturedObject) {
+ contextObject = (CapturedObject) context.get(i);
+ break;
+ }
+ }
+ assert contextObject != null;
+
+ try {
+ String methodName = tag.getAttribute("method");
+ MethodNode newContext = new MethodNode(methodName);
+ context.push(newContext);
+ boolean voidChildren = processChildren(tag, context, capture);
+ boolean add = false;
+
+ ContextNode[] arguments = newContext.getArguments();
+ if (methodName.equals("add") && arguments.length >= 1 && arguments[0] instanceof CapturedObject) {
+ Class<?> contextClass = Class.forName(contextObject.getClassName(), true, capture.getClassLoader());
+ if (Container.class.isAssignableFrom(contextClass)) {
+ add = true;
+ evaluateAdd(contextObject, (CapturedObject) arguments[0], null);
+ }
+ }
+
+ if (!voidChildren && !add) {
+ contextObject.appendScriptCode(capture.getJavaCode(context));
+ }
+
+ assert context.peek() == newContext;
+ context.pop();
+ }
+ catch (ClassNotFoundException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+
+ protected void evaluate(Element tag, Stack<ContextNode> context, JAXXCapture capture) {
+ String tagName = tag.getTagName();
+ if (tagName.equals("object")) {
+ String fieldName = tag.getAttribute("field");
+ ContextNode currentNode = context.peek();
+ if (fieldName.length() > 0) {
+ try {
+ String className = tag.getAttribute("class");
+ Field field = Class.forName(className, true, capture.getClassLoader()).getField(fieldName);
+ Object value = field.get(null);
+ currentNode.addArgument(new LiteralNode(className + "." + fieldName, value));
+ }
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ currentNode.addArgument(capture.processObject(tag, context));
+ }
+ } else if (tagName.equals("void")) {
+ String property = tag.getAttribute("property");
+ if (property.length() > 0) {
+ evaluateProperty(tag, context, capture);
+ } else {
+ evaluateMethod(tag, context, capture);
+ }
+ } else if (tagName.equals("string")) {
+ context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag)));
+ } else if (tagName.equals("boolean")) {
+ context.peek().addArgument(new ValueNode(Boolean.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("char")) {
+ context.peek().addArgument(new ValueNode(JAXXCapture.getText(tag).charAt(0)));
+ } else if (tagName.equals("short")) {
+ context.peek().addArgument(new ValueNode(Short.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("int")) {
+ context.peek().addArgument(new ValueNode(Integer.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("long")) {
+ context.peek().addArgument(new ValueNode(Long.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("float")) {
+ context.peek().addArgument(new ValueNode(Float.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("double")) {
+ context.peek().addArgument(new ValueNode(Double.valueOf(JAXXCapture.getText(tag))));
+ } else if (tagName.equals("null")) {
+ context.peek().addArgument(new ValueNode(null));
+ } else {
+ System.err.println("unsupported tag: " + tag.getTagName());
+ }
+ }
+
+
+ private static String dataBindingEncode(String value) {
+ return value.replaceAll("\\{", "\\\\{").replaceAll("\\}", "\\\\}");
+ }
+
+
+ public CapturedObject processObject(Element objectTag, Stack<ContextNode> context, JAXXCapture capture) {
+ String className = objectTag.getAttribute("class");
+ if (className.length() > 0) {
+ CapturedObject capturedObject = createCapturedObject(className, capture);
+ context.push(capturedObject);
+ NodeList children = objectTag.getChildNodes();
+ String id = objectTag.getAttribute("id");
+ if (id.length() == 0 || capture.getCapturedObjects().containsKey(id)) {
+ id = "Auto" + ++count;
+ }
+ assert !capture.getCapturedObjects().containsKey(id);
+ capture.getCapturedObjects().put(id, capturedObject);
+ capturedObject.setProperty("id", id);
+ // process object's name before anything else
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) child;
+ if (element.getTagName().equals("void") && element.getAttribute("property").equals("name")) {
+ evaluate(element, context, capture);
+ String name = capturedObject.getProperty("name");
+ if (name != null && !capture.getCapturedObjects().containsKey(name)) {
+ capture.getCapturedObjects().put(name, capturedObject);
+ capturedObject.setProperty("id", name);
+ capturedObject.getProperties().remove("name");
+ }
+ }
+ }
+ }
+ // process remaining children
+ for (int i = 0; i < children.getLength(); i++) {
+ Node child = children.item(i);
+ if (child.getNodeType() == Node.ELEMENT_NODE) {
+ Element element = (Element) child;
+ if (!element.getTagName().equals("void") || !element.getAttribute("property").equals("name")) {
+ evaluate(element, context, capture);
+ }
+ }
+ }
+ assert context.peek() == capturedObject;
+ context.pop();
+
+ return capturedObject;
+ } else {
+ CapturedObject result = capture.getCapturedObjects().get(objectTag.getAttribute("idref"));
+ if (result == null) {
+ throw new RuntimeException("Internal error: could not find tag with id " + objectTag.getAttribute("idref"));
+ }
+ result.setInlineable(false); // we have at least two references to it, and so can't inline it
+ return result;
+ }
+ }
+
+
+ private static String xmlEncode(String src) {
+ return src.replaceAll("'", "&").replaceAll("<", "<");
+ }
+
+
+ public String getXML(CapturedObject object, JAXXCapture capture) {
+ StringBuffer result = new StringBuffer();
+ result.append('<');
+ String className = object.getClassName();
+ if (className.startsWith("javax.swing.")) {
+ className = className.substring("javax.swing.".length());
+ }
+ result.append(className);
+ Map<String, String> properties = object.getProperties();
+ for (Map.Entry<String, String> e : properties.entrySet()) {
+ result.append(' ');
+ result.append(e.getKey());
+ result.append("='");
+ result.append(xmlEncode(e.getValue()));
+ result.append('\'');
+ }
+ ContextNode[] arguments = object.getArguments();
+ if (arguments != null && arguments.length > 0) {
+ result.append(" constructorParams='");
+ for (int j = 0; j < arguments.length; j++) {
+ if (j != 0) {
+ result.append(", ");
+ }
+ result.append(capture.getJavaCode(arguments[j]));
+ }
+ result.append('\'');
+ }
+ boolean tagClosed = false;
+
+ String children = getChildXML(object, capture);
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+ if (children != null && children.length() > 0) {
+ if (!tagClosed) {
+ tagClosed = true;
+ result.append('>');
+ result.append(lineSeparator);
+ }
+ result.append(children);
+ }
+
+ String script = object.getScriptCode();
+ if (script != null && script.length() > 0) {
+ if (!tagClosed) {
+ tagClosed = true;
+ result.append('>');
+ result.append(lineSeparator);
+ }
+ result.append(" <script>");
+ result.append(lineSeparator);
+ result.append(JavaFile.indent(script, 4, false, lineSeparator));
+ result.append(lineSeparator);
+ result.append(" </script>");
+ result.append(lineSeparator);
+ }
+ if (tagClosed) {
+ result.append("</");
+ result.append(className);
+ result.append('>');
+ } else {
+ result.append("/>");
+ }
+ return result.toString();
+ }
+
+
+ protected String getChildXML(CapturedObject object, JAXXCapture capture) {
+ StringBuffer result = new StringBuffer();
+ CapturedObject[] children = object.getChildren();
+ String lineSeparator = JAXXCompiler.getLineSeparator();
+ for (CapturedObject aChildren : children) {
+ if (!aChildren.isInlineable()) {
+ result.append(JavaFile.indent(aChildren.getXML(capture), 2, false, lineSeparator));
+ result.append(lineSeparator);
+ }
+ }
+ return result.toString();
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/ObjectHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tools/jaxxcapture/handlers/TableHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,14 @@
+package jaxx.compiler.tools.jaxxcapture.handlers;
+
+import jaxx.compiler.tools.jaxxcapture.CapturedObject;
+import jaxx.compiler.tools.jaxxcapture.JAXXCapture;
+
+public class TableHandler extends ObjectHandler {
+
+ @Override
+ protected CapturedObject createCapturedObject(String className, JAXXCapture capture) {
+ CapturedObject result = new CapturedObject(this, "javax.swing.JPanel", capture);
+ result.setProperty("layout", "{new GridBagLayout()}");
+ return result;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/tools/jaxxcapture/handlers/TableHandler.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/ColorConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/ColorConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,35 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.awt.Color;
+import java.lang.reflect.Field;
+
+public class ColorConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ Color color = (Color) object;
+ return "new Color(" + color.getRed() + ", " + color.getGreen() + ", " + color.getBlue() + ")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type != Color.class) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ if (string.length() == 7 && string.charAt(0) == '#') {
+ return new Color(Integer.parseInt(string.substring(1), 16));
+ }
+ try {
+ Field color = Color.class.getField(string);
+ return color.get(null);
+ } catch (NoSuchFieldException e) {
+ throw new IllegalArgumentException("colors must be of the form #xxxxxx ('#' followed by six hexadecimal digits), or the name of a constant field in java.awt.Color (found: '" + string + "')");
+ } catch (IllegalAccessException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/GridBagConstraintsConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/GridBagConstraintsConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.awt.GridBagConstraints;
+
+public class GridBagConstraintsConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ GridBagConstraints g = (GridBagConstraints) object;
+ return "new GridBagConstraints(" + g.gridx + ", " + g.gridy + ", " + g.gridwidth + ", " + g.gridheight + ", " +
+ g.weightx + ", " + g.weighty + ", " + g.anchor + ", " + g.fill + ", " +
+ TypeManager.getJavaCode(g.insets) + ", " + g.ipadx + ", " + g.ipady + ")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ throw new UnsupportedOperationException("GridBagConstraints must be represented using Java code");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/InsetsConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/InsetsConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,38 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.awt.Insets;
+import java.util.StringTokenizer;
+
+public class InsetsConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ Insets insets = (Insets) object;
+ return "new Insets(" + insets.top + ", " + insets.left + ", " + insets.bottom + ", " + insets.right + ")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type != Insets.class) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ StringTokenizer tokenizer = new StringTokenizer(string, ",");
+ int count = tokenizer.countTokens();
+ if (count == 1) {
+ int i = Integer.parseInt(tokenizer.nextToken().trim());
+ return new Insets(i, i, i, i);
+ }
+ if (count == 4) {
+ int[] insets = new int[count];
+ for (int i = 0; tokenizer.hasMoreTokens(); i++) {
+ insets[i] = Integer.parseInt(tokenizer.nextToken().trim());
+ }
+ return new Insets(insets[0], insets[1], insets[2], insets[3]);
+ }
+ throw new IllegalArgumentException("unable to convert string '" + string + "' to Insets");
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/KeyStrokeConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/KeyStrokeConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,23 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import javax.swing.KeyStroke;
+
+public class KeyStrokeConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ return "KeyStroke.getKeyStroke(\"" + object.toString() + "\")";
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type != KeyStroke.class) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ return KeyStroke.getKeyStroke(string);
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/PrimitiveConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,80 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import jaxx.compiler.JAXXCompiler;
+
+public class PrimitiveConverter implements TypeConverter {
+
+ @Override
+ public String getJavaCode(Object object) {
+ if (object instanceof Boolean) {
+ return String.valueOf(((Boolean) object).booleanValue());
+ }
+ if (object instanceof Byte) {
+ return String.valueOf(((Byte) object).byteValue());
+ }
+ if (object instanceof Short) {
+ return String.valueOf(((Short) object).shortValue());
+ }
+ if (object instanceof Integer) {
+ return String.valueOf(((Integer) object).intValue());
+ }
+ if (object instanceof Long) {
+ return String.valueOf(((Long) object).longValue()) + "L";
+ }
+ if (object instanceof Float) {
+ return String.valueOf(((Float) object).floatValue()) + "F";
+ }
+ if (object instanceof Double) {
+ return String.valueOf(((Double) object).doubleValue());
+ }
+ if (object instanceof String) {
+ return '"' + JAXXCompiler.escapeJavaString((String) object) + '"';
+ }
+ throw new IllegalArgumentException("unsupported object: " + object);
+ }
+
+ @Override
+ public Object convertFromString(String string, Class<?> type) {
+ if (type == String.class || type == Object.class || type == null) {
+ return string;
+ }
+ if (type == int.class || type == Integer.class) {
+ return Integer.valueOf(string);
+ }
+ if (type == boolean.class || type == Boolean.class) {
+ if (string.toLowerCase().equals("true")) {
+ return Boolean.TRUE;
+ }
+ if (string.toLowerCase().equals("false")) {
+ return Boolean.FALSE;
+ }
+ throw new IllegalArgumentException("expected 'true' or 'false', found '" + string + "'");
+ }
+ if (type == byte.class || type == Byte.class) {
+ return Byte.valueOf(string);
+ }
+ if (type == short.class || type == Short.class) {
+ return Short.valueOf(string);
+ }
+ if (type == long.class || type == Long.class) {
+ return Long.valueOf(string);
+ }
+ if (type == float.class || type == Float.class) {
+ return Float.valueOf(string);
+ }
+ if (type == double.class || type == Double.class) {
+ return Double.valueOf(string);
+ }
+ if (type == char.class || type == Character.class) {
+ if (string.length() == 1) {
+ return string.charAt(0);
+ }
+ throw new IllegalArgumentException("expected a single character, found '" + string + "'");
+ }
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/PrimitiveConverter.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/TypeConverter.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,12 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+public interface TypeConverter {
+
+ String getJavaCode(Object object);
+
+ Object convertFromString(String string, Class<?> type);
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeConverter.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/types/TypeManager.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.compiler.types;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class TypeManager {
+
+ private static Map<Class<?>, TypeConverter> converters = new HashMap<Class<?>, TypeConverter>();
+
+ private TypeManager() { /* not instantiable */ }
+
+ public static void registerTypeConverter(Class<?> type, TypeConverter converter) {
+ converters.put(type, converter);
+ }
+
+ public static TypeConverter getTypeConverter(Class<?> type) {
+ return converters.get(type);
+ }
+
+ public static String getJavaCode(Object object) {
+ if (object == null) {
+ return "null";
+ }
+ TypeConverter converter = getTypeConverter(object.getClass());
+ if (converter == null) {
+ throw new IllegalArgumentException("unsupported type: " + object.getClass());
+ }
+ return converter.getJavaCode(object);
+ }
+
+ public static Object convertFromString(String string, Class<?> type) {
+ TypeConverter converter = getTypeConverter(type);
+ if (converter == null) {
+ throw new IllegalArgumentException("unsupported type: " + type);
+ }
+ return converter.convertFromString(string, type);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/compiler/types/TypeManager.java
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,3 +0,0 @@
-jaxx.compiler.JAXXObjectGenerator
-jaxx.compiler.SwingGenerator
-jaxx.compiler.ValidatorGenerator
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.Generator)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.generators.Generator 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,3 @@
+jaxx.compiler.generators.JAXXObjectGenerator
+jaxx.compiler.generators.SwingGenerator
+jaxx.compiler.generators.ValidatorGenerator
Copied: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1 @@
+jaxx.compiler.spi.DefaultInitializer
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.compiler.spi.Initializer
___________________________________________________________________
Added: svn:mergeinfo
+
Deleted: branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/resources/META-INF/services/jaxx.spi.Initializer 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,3 +0,0 @@
-jaxx.DefaultInitializer
-jaxx.SwingInitializer
-jaxx.tags.validator.ValidatorInitializer
Modified: branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-compiler/src/site/rst/JAXXContext.rst 2009-10-07 14:22:07 UTC (rev 1562)
@@ -13,7 +13,7 @@
Le besoin initial de ce développement est de pouvoir facilement intégrer un context applicatif dans JAXX et de pouvoir
l'utiliser dans les fichiers JAXX pour injecter par exemple des données dans les widgets.
-jaxx.runtime.JAXXContext
+jaxx.runtime.context.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
@@ -32,7 +32,7 @@
Le nom qui est facultatif permet de pouvoir distinguer plusieurs données d'un même type dans le context. Si le nom
n'est pas utilisé pour caractériser une données on fixera alors sa valeur à *null*.
-Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.JAXXContextEntryDef*.
+Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.context.JAXXContextEntryDef*.
Les méthodes de lecture
***********************
@@ -87,7 +87,7 @@
Cette entrée spéciale ne sera pas stockée avec les autres entrées afin d'optimiser les algorithmes d'injection et de
restitution.
-jaxx.runtime.JAXXInitialContext
+jaxx.runtime.context.JAXXInitialContext
*******************************
On a implanté un second type de context qui lui peut servir à l'initialisation des JAXXObject.
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/JavaFileParserTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaFileParserTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,57 @@
+package jaxx.compiler;
+
+import jaxx.compiler.CompilerException;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.JavaFileParser;
+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 java.io.File;
+import java.io.FileReader;
+import java.io.Reader;
+
+public class JavaFileParserTest {
+
+
+ /** log */
+ protected static final Log log = LogFactory.getLog(JavaFileParserTest.class);
+
+ static File basedir;
+
+ @BeforeClass
+ public static void initBaseDir() {
+ // get maven env basedir
+ String basedir = System.getenv("basedir");
+ if (basedir == null) {
+ basedir = new File("").getAbsolutePath();
+ }
+ JavaFileParserTest.basedir = new File(basedir);
+ }
+
+ @Test
+ public void testParseJavaSourceFile() throws Exception {
+
+ File testSourceRoot = new File(basedir, "src" + File.separator + "test" + File.separator + "java");
+ Assert.assertTrue(testSourceRoot.exists());
+
+ File src = new File(testSourceRoot, getClass().getName().replaceAll("\\.", File.separator) + ".java");
+ Assert.assertTrue(src.exists());
+ log.info("trying parsing file " + src);
+ Reader reader = new FileReader(src);
+ try {
+ ClassDescriptor result = JavaFileParser.parseJavaFile("TestParserJava", reader, getClass().getClassLoader());
+ Assert.assertNotNull(result);
+
+ } catch (CompilerException e) {
+ log.error("could not parse file " + src + " for reason " + e.getMessage(), e);
+ Assert.fail(e.getMessage());
+ }
+ finally {
+ reader.close();
+ }
+ }
+
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/JavaMethodTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,52 @@
+package jaxx.compiler;
+
+import jaxx.compiler.JavaMethod;
+import jaxx.compiler.JavaMethod.MethodOrder;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.lang.reflect.Modifier;
+import java.util.EnumSet;
+
+/** @author chemit */
+public class JavaMethodTest {
+
+ @Test
+ public void testGetMethodOrderScope() {
+ EnumSet<MethodOrder> allConstants = EnumSet.allOf(MethodOrder.class);
+
+ EnumSet<MethodOrder> constants;
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.STATIC);
+
+ Assert.assertEquals(1, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.statics));
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PUBLIC);
+
+ Assert.assertEquals(8, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.constructors));
+ Assert.assertTrue(constants.contains(MethodOrder.JAXXObject));
+ Assert.assertTrue(constants.contains(MethodOrder.JAXXContext));
+ Assert.assertTrue(constants.contains(MethodOrder.JAXXValidation));
+ Assert.assertTrue(constants.contains(MethodOrder.events));
+ Assert.assertTrue(constants.contains(MethodOrder.publicGetters));
+ Assert.assertTrue(constants.contains(MethodOrder.publicSetters));
+ Assert.assertTrue(constants.contains(MethodOrder.otherPublic));
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PROTECTED);
+
+ Assert.assertEquals(3, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.protectedGetters));
+ Assert.assertTrue(constants.contains(MethodOrder.protecteds));
+ Assert.assertTrue(constants.contains(MethodOrder.createMethod));
+
+
+ constants = JavaMethod.getMethodOrderScope(allConstants, Modifier.PRIVATE);
+ Assert.assertEquals(3, constants.size());
+ Assert.assertTrue(constants.contains(MethodOrder.createMethod));
+ Assert.assertTrue(constants.contains(MethodOrder.packageLocal));
+ Assert.assertTrue(constants.contains(MethodOrder.privates));
+
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/JavaMethodTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/beaninfos/BeanIntoUtilTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,34 @@
+package jaxx.compiler.beans;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.beans.Introspector;
+
+/** @author chemit */
+public class BeanIntoUtilTest {
+
+ @Test
+ public void testExtraBeanInfoPath() {
+ BeanInfoUtil.reset();
+ String[] searchPath0 = Introspector.getBeanInfoSearchPath();
+
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.runtime.swing");
+
+ String[] searchPath = Introspector.getBeanInfoSearchPath();
+ Assert.assertEquals(searchPath0.length + 1, searchPath.length);
+
+ BeanInfoUtil.reset();
+ Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length);
+
+ String packageName = getClass().getPackage().getName() + ".dummy";
+ BeanInfoUtil.addJaxxBeanInfoPath("jaxx.beaninfos", packageName);
+
+ searchPath = Introspector.getBeanInfoSearchPath();
+ Assert.assertEquals(searchPath0.length + 2, searchPath.length);
+ Assert.assertEquals(packageName, searchPath[searchPath.length - 1]);
+
+ BeanInfoUtil.reset();
+ Assert.assertEquals(searchPath0.length, Introspector.getBeanInfoSearchPath().length);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/beans/BeanIntoUtilTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/ClassDescriptorTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,59 @@
+package jaxx.compiler.reflect;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import org.junit.Test;
+
+public class ClassDescriptorTest {
+
+ /*@Test
+ public void testGetClassDescriptor() throws Exception {
+ ClassDescriptorLoader.getClassDescriptor("jaxx.runtime.swing.navigation.NavigationTreeModel.NavigationTreeNode");
+ }*/
+ @Test
+ public void testBuiltInClassName() throws ClassNotFoundException, NoSuchMethodException {
+ ClassDescriptor object = ClassDescriptorLoader.getClassDescriptor("java.lang.Object");
+ MethodDescriptor toString = object.getMethodDescriptor("toString");
+ assertEquals(toString.getName(), "toString");
+ assertEquals(toString.getParameterTypes().length, 0);
+
+ MethodDescriptor equals = object.getMethodDescriptor("equals", object);
+ assertEquals(equals.getName(), "equals");
+ assertEquals(equals.getParameterTypes().length, 1);
+ assertEquals(equals.getParameterTypes()[0], object);
+ }
+
+ @Test
+ public void testBuiltInClass() throws ClassNotFoundException, NoSuchMethodException {
+ ClassDescriptor object1 = ClassDescriptorLoader.getClassDescriptor("java.lang.Object");
+ ClassDescriptor object2 = ClassDescriptorLoader.getClassDescriptor(Object.class);
+ assertEquals(object1, object2);
+ }
+
+ @Test
+ public void testUserClassName() throws ClassNotFoundException, NoSuchMethodException {
+ ClassDescriptor me = ClassDescriptorLoader.getClassDescriptor(ClassDescriptorTest.class.getName(), getClass().getClassLoader());
+ MethodDescriptor testUserClassName = me.getMethodDescriptor("testUserClassName");
+ assertEquals(testUserClassName.getName(), "testUserClassName");
+ assertEquals(testUserClassName.getParameterTypes().length, 0);
+ }
+
+ @Test(expected = ClassNotFoundException.class)
+ public void testWrongCase() throws ClassNotFoundException {
+ //try {
+ //ClassDescriptor object =
+ ClassDescriptorLoader.getClassDescriptor("jaxx.junit.classdescriptortest", getClass().getClassLoader());
+ // fail("Found descriptor using wrong case: " + object);
+ //}
+ //catch (ClassNotFoundException e) {
+ //}
+ }
+
+ @Test
+ public void testArrays() throws ClassNotFoundException {
+ ClassDescriptor intArray = ClassDescriptorLoader.getClassDescriptor(int[].class);
+ assertNotNull(intArray);
+ ClassDescriptor objectArray = ClassDescriptorLoader.getClassDescriptor(Object[].class);
+ assertNotNull(objectArray);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/reflect/ClassDescriptorTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/TagManagerTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/tags/TagManagerTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,138 @@
+package jaxx.compiler.tags;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import jaxx.compiler.reflect.ClassDescriptor;
+import jaxx.compiler.reflect.ClassDescriptorLoader;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import javax.swing.JPopupMenu;
+import java.io.ByteArrayOutputStream;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+
+public class TagManagerTest {
+
+ protected JAXXCompiler compiler;
+
+ public static class TestHandler extends DefaultObjectHandler {
+
+ public TestHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ }
+ }
+
+ @BeforeClass
+ public static void initTagManaer() throws Exception {
+
+ TagManager.reset(true);
+
+ }
+
+ @Before
+ public void setUp() {
+ JAXXCompilerLaunchor.newLaunchor();
+ compiler = JAXXCompilerLaunchor.createDummyCompiler(JAXXCompiler.class.getClassLoader());
+// compiler = new JAXXCompiler(JAXXCompiler.class.getClassLoader());
+ compiler.addImport("javax.swing.*");
+
+ }
+
+ @Test
+ public void testRegisterBean() {
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(InputStream.class), TestHandler.class);
+
+ Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(InputStream.class)) instanceof TestHandler);
+ Assert.assertTrue(TagManager.getTagHandler(ClassDescriptorLoader.getClassDescriptor(FileInputStream.class)) instanceof TestHandler);
+ }
+
+ @Test
+ public void testRegisterDefaultNamespace() {
+
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(OutputStream.class), TestHandler.class);
+
+ TagManager.registerDefaultNamespace("OutputStream", "java.io.*");
+ Assert.assertTrue("Could not find handler for OutputStream despite default namespace", TagManager.getTagHandler(null, "OutputStream", compiler) instanceof TestHandler);
+
+ PrintStream oldErr = System.err;
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(buffer));
+ TagManager.registerDefaultNamespace("OutputStream", "java.dummy.*");
+ Assert.assertNull("Found handler for OutputStream despite ambiguous default namespace", TagManager.getTagHandler(null, "OutputStream", compiler));
+ System.setErr(oldErr);
+ Assert.assertTrue("No errors were produced with an ambiguous default namespace", buffer.size() > 0);
+ Assert.assertTrue(buffer.size() > 0);
+ }
+
+ @Test
+ public void testResolveClassName() {
+ Assert.assertEquals("Could not resolve class name 'Object'", TagManager.resolveClassName("Object", compiler), "java.lang.Object");
+ Assert.assertEquals("Could not resolve class name 'java.lang.Object'", TagManager.resolveClassName("java.lang.Object", compiler), "java.lang.Object");
+ Assert.assertNull("Unexpectedly resolved class name 'java.awt.Object'", TagManager.resolveClassName("java.awt.Object", compiler));
+ }
+
+ @Test
+ public void testPackages() {
+ Assert.assertNull("Unexpectedly found handler for java.awt.JButton", TagManager.getTagHandler(null, "java.awt.JButton", compiler));
+ Assert.assertNotNull("Did not find handler for JButton with default namespace of java.awt.*", TagManager.getTagHandler("java.awt.*", "JButton", compiler));
+ Assert.assertNull("Unexpectedly found handler for java.awt.*:JButton", TagManager.getTagHandler("java.awt.*", "JButton", true, compiler));
+ Assert.assertNotNull("Did not find handler for javax.swing.JButton", TagManager.getTagHandler(null, "javax.swing.JButton", compiler));
+ Assert.assertNotNull("Did not find handler for JButton with default namespace of java.swing.*", TagManager.getTagHandler("java.swing.*", "JButton", compiler));
+ Assert.assertNotNull("Did not find handler for javax.swing.*:JButton", TagManager.getTagHandler("javax.swing.*", "JButton", true, compiler));
+ }
+
+ @Test
+ public void testImport() throws Exception {
+ Assert.assertNull("Found handler for ActionListener despite no java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler));
+
+ compiler.addImport("java.awt.event.*");
+
+ Assert.assertNotNull("Did not find ActionListener with java.awt.event.* import", TagManager.getTagHandler(null, "ActionListener", compiler));
+ }
+
+ @Test
+ public void testAmbiguousImport() throws Exception {
+ compiler.addImport("java.sql.*");
+ Assert.assertNotNull("Did not find java.sql.Date with only java.sql.* imported", TagManager.getTagHandler(null, "Date", compiler));
+
+ PrintStream oldErr = System.err;
+ ByteArrayOutputStream buffer = new ByteArrayOutputStream();
+ System.setErr(new PrintStream(buffer));
+ compiler.addImport("java.util.*");
+ TagManager.reset(true);
+ Assert.assertNull("Still found a handler for Date with an ambiguous import", TagManager.getTagHandler(null, "Date", compiler));
+ System.setErr(oldErr);
+ Assert.assertTrue("No errors were produced with an ambiguous import", buffer.size() > 0);
+
+ compiler.addImport("java.util.Date");
+ Assert.assertNotNull("Did not find java.util.Date with a disambiguating import", TagManager.getTagHandler(null, "Date", compiler));
+ }
+
+ @Test
+ public void testInnerClass() {
+ TagHandler handler = TagManager.getTagHandler(null, "JPopupMenu.Separator", compiler);
+ Assert.assertTrue("Unable to resolve tag <JPopupMenu.Separator>", handler instanceof DefaultComponentHandler);
+ Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName()));
+
+ handler = TagManager.getTagHandler(null, "javax.swing.JPopupMenu.Separator", compiler);
+ Assert.assertTrue("Unable to resolve tag <javax.swing.JPopupMenu.Separator>", handler instanceof DefaultComponentHandler);
+ Assert.assertTrue(((DefaultComponentHandler) handler).getBeanClass().getName().equals(JPopupMenu.Separator.class.getName()));
+ }
+
+ @Test
+ public void testWrongCase() {
+ Assert.assertNull("Unexpectedly found handler for 'object'", TagManager.getTagHandler(null, "object", compiler));
+ Assert.assertNull("Unexpectedly found handler for 'tagmanagertest'", TagManager.getTagHandler(null, "tagmanagertest", compiler));
+ }
+
+ @Test
+ public void testAliasing() {
+ Assert.assertEquals("ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("ButtonGroup", compiler));
+ Assert.assertEquals("javax.swing.ButtonGroup is not aliased to jaxx.runtime.swing.JAXXButtonGroup", "jaxx.runtime.swing.JAXXButtonGroup", TagManager.resolveClassName("javax.swing.ButtonGroup", compiler));
+ }
+}
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/ColorConverterTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/ColorConverterTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,51 @@
+package jaxx.compiler.types;
+
+import jaxx.compiler.types.ColorConverter;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.Color;
+
+public class ColorConverterTest {
+
+ ColorConverter converter;
+
+ @Before
+ public void setUp() {
+ converter = new ColorConverter();
+ }
+
+ @Test
+ public void testHexValue() {
+ Color value = (Color) converter.convertFromString("#3000FF", Color.class);
+ Assert.assertEquals(value, new Color(48, 0, 255));
+ }
+
+ @Test
+ public void testUpperCaseConstant() {
+ Color value = (Color) converter.convertFromString("RED", Color.class);
+ Assert.assertEquals(value, Color.RED);
+ }
+
+ @Test
+ public void testLowerCaseConstant() {
+ Color value = (Color) converter.convertFromString("blue", Color.class);
+ Assert.assertEquals(value, Color.blue);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMissingHash() {
+ converter.convertFromString("ABCDEF", Color.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidNumber() {
+ converter.convertFromString("#ABCDEG", Color.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidConstant() {
+ converter.convertFromString("rEd", Color.class);
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/InsetsConverterTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/InsetsConverterTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,50 @@
+package jaxx.compiler.types;
+
+import jaxx.compiler.types.InsetsConverter;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.Insets;
+
+public class InsetsConverterTest {
+
+ InsetsConverter converter;
+
+ @Before
+ public void setUp() {
+ converter = new InsetsConverter();
+ }
+
+ @Test
+ public void testSingleValue() {
+ Insets value = (Insets) converter.convertFromString("3", Insets.class);
+ Assert.assertEquals(value, new Insets(3, 3, 3, 3));
+ }
+
+ @Test
+ public void testFourValues() {
+ Insets value = (Insets) converter.convertFromString("3, 0, 12, 1000000", Insets.class);
+ Assert.assertEquals(value, new Insets(3, 0, 12, 1000000));
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testTwoValues() {
+ converter.convertFromString("0, 4", Insets.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testThreeValues() {
+ converter.convertFromString("0, 4, 9", Insets.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInvalidNumber() {
+ converter.convertFromString("0, 4, 9, A", Insets.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testBadFormatting() {
+ converter.convertFromString("0 - 1 - 2 - 3", Insets.class);
+ }
+}
\ No newline at end of file
Copied: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java (from rev 1560, branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/junit/PrimitiveConverterTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,113 @@
+package jaxx.compiler.types;
+
+import jaxx.compiler.types.PrimitiveConverter;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+public class PrimitiveConverterTest {
+
+ PrimitiveConverter converter;
+
+
+ @Before
+ public void setUp() {
+ converter = new PrimitiveConverter();
+ }
+
+ @Test
+ public void testBoolean() {
+ Boolean value = (Boolean) converter.convertFromString("true", Boolean.class);
+ Assert.assertTrue(value);
+
+ value = (Boolean) converter.convertFromString("false", Boolean.class);
+ Assert.assertFalse(value);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testBoolean2() {
+ converter.convertFromString("yes", Boolean.class);
+ }
+
+ @Test
+ public void testByte() {
+ Byte value = (Byte) converter.convertFromString(String.valueOf(Byte.MAX_VALUE), Byte.class);
+ Assert.assertEquals(value.byteValue(), Byte.MAX_VALUE);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testByte2() {
+
+ converter.convertFromString(String.valueOf(1 + Byte.MAX_VALUE), Byte.class);
+ }
+
+ @Test
+ public void testShort() {
+ Short value = (Short) converter.convertFromString(String.valueOf(Short.MAX_VALUE), Short.class);
+ Assert.assertEquals(value.shortValue(), Short.MAX_VALUE);
+
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testShort2() {
+
+ converter.convertFromString(String.valueOf(1 + Short.MAX_VALUE), Short.class);
+ }
+
+ @Test
+ public void testInteger() {
+ Integer value = (Integer) converter.convertFromString(String.valueOf(Integer.MAX_VALUE), Integer.class);
+ Assert.assertEquals(value.intValue(), Integer.MAX_VALUE);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testInteger2() {
+
+ converter.convertFromString(String.valueOf(1L + Integer.MAX_VALUE), Integer.class);
+ }
+
+ @Test
+ public void testLong() {
+ Long value = (Long) converter.convertFromString(String.valueOf(Long.MAX_VALUE), Long.class);
+ Assert.assertEquals(value.longValue(), Long.MAX_VALUE);
+ }
+
+ @Test
+ public void testFloat() {
+ Float value = (Float) converter.convertFromString("3.1415", Float.class);
+ Assert.assertTrue(value == 3.1415f);
+ }
+
+ @Test
+ public void testDouble() {
+ Double value = (Double) converter.convertFromString("3.1415", Double.class);
+ Assert.assertTrue(value == 3.1415);
+ }
+
+ @Test
+ public void testCharacter() {
+ Character value = (Character) converter.convertFromString("A", Character.class);
+ Assert.assertEquals(value.charValue(), 'A');
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCharacter2() {
+
+ converter.convertFromString("12", Character.class);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testCharacter3() {
+ converter.convertFromString("", Character.class);
+ }
+
+ @Test
+ public void testString() {
+ String value = (String) converter.convertFromString("Test", String.class);
+ Assert.assertEquals(value, "Test");
+ }
+}
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/test/java/jaxx/compiler/types/PrimitiveConverterTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoTreeHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,29 +20,36 @@
*/
package jaxx.demo;
-import java.util.Stack;
-import javax.swing.JPanel;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+
+import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
+
import jaxx.demo.component.swing.*;
import jaxx.demo.component.jaxx.*;
import jaxx.demo.component.jaxx.editor.*;
import jaxx.demo.component.jaxx.navigation.item.ItemTreeNavigationDemo;
-import jaxx.demo.component.jaxx.tree.FullNavigationTreeDemo;
+import jaxx.demo.component.jaxx.navigation.FullNavigationTreeDemo;
import jaxx.demo.feature.databinding.BeanDataBindingDemo;
import jaxx.demo.feature.validation.*;
import jaxx.demo.fun.*;
import static org.nuiton.i18n.I18n.n_;
-
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXContextEntryDef;
-import jaxx.runtime.JAXXObject;
-import jaxx.runtime.swing.CardLayout2;
-import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.swing.tree.*;
-import jaxx.runtime.swing.tree.NavigationTreeHandler.Strategy;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import java.util.Stack;
+import javax.swing.JPanel;
+
/**
*
* @author chemit
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -29,7 +29,7 @@
<script><![CDATA[
import jaxx.runtime.SwingUtil;
-import jaxx.runtime.swing.tree.*;
+import jaxx.runtime.swing.navigation.*;
import java.util.Locale;
public DemoConfig getConfig() {
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUIHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -21,9 +21,9 @@
package jaxx.demo;
import jaxx.runtime.swing.ErrorDialogUI;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXInitialContext;
-import jaxx.runtime.swing.tree.NavigationTreeNode;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n._;
@@ -33,8 +33,8 @@
import java.net.URL;
import java.util.Locale;
import javax.swing.SwingUtilities;
-import jaxx.runtime.DefaultApplicationContext;
-import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.context.DefaultApplicationContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
import jaxx.runtime.swing.AboutPanel;
import jaxx.runtime.swing.editor.config.ConfigUI;
import jaxx.runtime.swing.editor.config.ConfigUIBuilder;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/RunDemo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,7 +20,7 @@
*/
package jaxx.demo;
-import jaxx.runtime.DefaultApplicationContext;
+import jaxx.runtime.context.DefaultApplicationContext;
import jaxx.runtime.swing.ErrorDialogUI;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/I18nEditorDemo.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,49 +18,69 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
##%*
-->
-
-<jaxx.demo.DemoPanel>
- <script><![CDATA[
-//localeEditor.loadI18nBundles();
-]]>
- </script>
- <Table id='demoPanel' fill='both'>
- <row>
- <cell>
- <JLabel text='Empty I18n editor:' labelFor='{localeEmptyEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeEmptyEditor' />
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='I18n editor:' labelFor='{localeEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeEditor'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='I18n editor with no text :' labelFor='{localeWithNoTextEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoTextEditor'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
- showText='false'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='I18n editor with no icon :' labelFor='{localeWithNoIconEditor}'/>
- </cell>
- <cell>
- <jaxx.runtime.swing.editor.I18nEditor id='localeWithNoIconEditor'
- locales='{java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales())}'
- showIcon='false'/>
- </cell>
- </row>
- </Table>
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+import jaxx.runtime.swing.editor.I18nEditor;
+import org.nuiton.i18n.I18n;
+import java.util.Arrays;
+
+protected Border getPopupBorder(String text) {
+ if (text==null || text.trim().isEmpty()) {
+ return null;
+ }
+ return new TitledBorder(_(text));
+}
+]]>
+ </script>
+ <Table id='demoPanel' fill='both'>
+ <row>
+ <cell>
+ <JPanel border='{new TitledBorder(_("jaxxdemo.i18neditor.configuration"))}'
+ layout='{new GridLayout(0,1)}'>
+
+ <JCheckBox id='showText'
+ text='jaxxdemo.i18neditor.showText'
+ selected='true'/>
+
+ <JCheckBox id='showIcon'
+ text='jaxxdemo.i18neditor.showIcon'
+ selected='true'/>
+
+ <JCheckBox id='showPopupText'
+ text='jaxxdemo.i18neditor.showPopupText'
+ selected='true'/>
+
+ <JCheckBox id='showPopupIcon'
+ text='jaxxdemo.i18neditor.showPopupIcon'
+ selected='true'/>
+
+ <JPanel>
+ <JLabel text='jaxxdemo.i18neditor.popupBorderText'
+ labelFor='{popupBorderText}'/>
+ <JTextField id='popupBorderText'
+ text='{_("i18neditor.popup.title")}'/>
+ </JPanel>
+
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <I18nEditor id='editor'
+ showText='{showText.isSelected()}'
+ showIcon='{showIcon.isSelected()}'
+ showPopupText='{showPopupText.isSelected()}'
+ showPopupIcon='{showPopupIcon.isSelected()}'
+ popupBorder='{getPopupBorder(popupBorderText.getText())}'
+ locales='{Arrays.asList(I18n.getLoader().getLocales())}'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel border='{new TitledBorder(_("jaxxdemo.i18neditor.selected.locale"))}'
+ text='{editor.getSelectedLocale()}'/>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemo.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,135 +18,165 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
##%*
-->
-
-<jaxx.demo.DemoPanel>
- <script><![CDATA[
-import jaxx.runtime.swing.editor.NumberEditor;
-
-void $afterCompleteSetup() {
- positifIntegerEditor.init();
- positifIntegerEditor2.init();
- normalIntegerEditor.init();
- normalIntegerEditor2.init();
- positifFloatEditor.init();
- positifFloatEditor2.init();
- normalFloatEditor.init();
- normalFloatEditor2.init();
-}
-]]>
- </script>
-
- <!-- model -->
- <NumberEditorDemoModel id='demoModel'/>
-
- <Table id='demoPanel' insets='0' fill='both'>
- <row>
- <cell weightx='0.5'>
- <JLabel horizontalAlignment='center' text='numbereditor.type'/>
- </cell>
- <cell weightx='0.25'>
- <JLabel horizontalAlignment='center' text='numbereditor.without.auto.popup'/>
- </cell>
- <cell weightx='0.25'>
- <JLabel horizontalAlignment='center' text='numbereditor.with.auto.popup'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.positive.int", demoModel.getPositifInteger())}'/>
- </cell>
- <cell>
- <NumberEditor id='positifIntegerEditor'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifIntegerEditor2'
- property='positifInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalIntegerEditor2'
- property='normalInteger'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- <cell>
- <NumberEditor id='positifFloatEditor2'
- property='positifFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'/>
- </cell>
- </row>
- <row>
- <cell>
- <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='false'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- <cell>
- <NumberEditor id='normalFloatEditor2'
- property='normalFloat'
- constructorParams='this'
- bean='{demoModel}'
- autoPopup='true'
- showPopupButton='true'
- showReset='true'
- useSign='true'/>
- </cell>
- </row>
- </Table>
-
-</jaxx.demo.DemoPanel>
+
+<jaxx.demo.DemoPanel>
+ <script><![CDATA[
+import jaxx.runtime.swing.editor.NumberEditor;
+
+void $afterCompleteSetup() {
+ editor.init();
+}
+]]>
+ </script>
+
+ <!-- model -->
+ <NumberEditorDemoModel id='demoModel'/>
+
+ <Table id='demoPanel' insets='0' fill='both'>
+ <row>
+ <cell>
+ <JPanel border='{new TitledBorder(_("jaxxdemo.numbereditor.configuration"))}'
+ layout='{new GridLayout(0,1)}'>
+
+ <JCheckBox id='useFloat'
+ text='jaxxdemo.numbereditor.useFloat'
+ selected='true'/>
+
+ <JCheckBox id='useSign'
+ text='jaxxdemo.numbereditor.useSign'
+ selected='true'/>
+
+ <JCheckBox id='showPopupButton'
+ text='jaxxdemo.numbereditor.showPopupButton'
+ selected='true'/>
+
+ <JCheckBox id='showResetButton'
+ text='jaxxdemo.numbereditor.showReset'
+ selected='true'/>
+
+ <JCheckBox id='autoPopup'
+ text='jaxxdemo.numbereditor.autoPopup'
+ selected='false'/>
+
+ </JPanel>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <NumberEditor id='editor'
+ constructorParams='this'
+ bean='{demoModel}'
+ property='{useFloat.isSelected() ? "floatProperty" : "integerProperty"}'
+ useFloat='{useFloat.isSelected()}'
+ useSign='{useSign.isSelected()}'
+ autoPopup='{autoPopup.isSelected()}'
+ showPopupButton='{showPopupButton.isSelected()}'
+ showReset='{showResetButton.isSelected()}' />
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JPanel border='{new TitledBorder(_("jaxxdemo.numbereditor.model"))}'
+ layout='{new GridLayout(0,1)}'>
+ <JLabel text='{_("jaxxdemo.numbereditor.model.int", demoModel.getIntegerProperty())}'/>
+ <JLabel text='{_("jaxxdemo.numbereditor.model.float", demoModel.getFloatProperty())}'/>
+
+ </JPanel>
+ </cell>
+ </row>
+ </Table>
+</jaxx.demo.DemoPanel>
+ <!--row>
+ <cell>
+ <NumberEditor id='positifIntegerEditor'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifIntegerEditor2'
+ property='positifInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.int", demoModel.getNormalInteger())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalIntegerEditor2'
+ property='normalInteger'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.positive.float", demoModel.getPositifFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='positifFloatEditor2'
+ property='positifFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'/>
+ </cell>
+ </row>
+ <row>
+ <cell>
+ <JLabel text='{_("numbereditor.normal.float", demoModel.getNormalFloat())}'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='false'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ <cell>
+ <NumberEditor id='normalFloatEditor2'
+ property='normalFloat'
+ constructorParams='this'
+ bean='{demoModel}'
+ autoPopup='true'
+ showPopupButton='true'
+ showReset='true'
+ useSign='true'/>
+ </cell>
+ </row-->
+
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/editor/NumberEditorDemoModel.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -30,56 +30,80 @@
*/
public class NumberEditorDemoModel {
+ public static final String INTEGER_PROPERTY = "integerProperty";
+ public static final String FLOAT_PROPERTY = "floatProperty";
protected PropertyChangeSupport p;
- protected int positifInteger;
- protected int normalInteger;
- protected float positifFloat;
- protected float normalFloat;
+ protected int integerProperty;
+ protected float floatProperty;
+// protected int positifInteger;
+// protected int normalInteger;
+// protected float positifFloat;
+// protected float normalFloat;
public NumberEditorDemoModel() {
p = new PropertyChangeSupport(this);
}
- public float getNormalFloat() {
- return normalFloat;
+ public float getFloatProperty() {
+ return floatProperty;
}
- public int getNormalInteger() {
- return normalInteger;
+ public int getIntegerProperty() {
+ return integerProperty;
}
- public float getPositifFloat() {
- return positifFloat;
+ public void setFloatProperty(float floatProperty) {
+ float old = this.floatProperty;
+ this.floatProperty = floatProperty;
+ p.firePropertyChange(FLOAT_PROPERTY, old, floatProperty);
}
- public int getPositifInteger() {
- return positifInteger;
+ public void setIntegerProperty(int integerProperty) {
+ int old = this.integerProperty;
+ this.integerProperty = integerProperty;
+ p.firePropertyChange(INTEGER_PROPERTY, old, integerProperty);
}
- public void setNormalFloat(float normalFloat) {
- float old = this.normalFloat;
- this.normalFloat = normalFloat;
- p.firePropertyChange("normalFloat", old, normalFloat);
- }
-
- public void setNormalInteger(int normalInteger) {
- int old = this.normalInteger;
- this.normalInteger = normalInteger;
- p.firePropertyChange("normalInteger", old, normalInteger);
- }
-
- public void setPositifFloat(float positifFloat) {
- float old = this.positifFloat;
- this.positifFloat = positifFloat;
- p.firePropertyChange("positifFloat", old, positifFloat);
- }
-
- public void setPositifInteger(int positifInteger) {
- int old = this.positifInteger;
- this.positifInteger = positifInteger;
- p.firePropertyChange("positifInteger", old, positifInteger);
- }
-
+//
+// public float getNormalFloat() {
+// return normalFloat;
+// }
+//
+// public int getNormalInteger() {
+// return normalInteger;
+// }
+//
+// public float getPositifFloat() {
+// return positifFloat;
+// }
+//
+// public int getPositifInteger() {
+// return positifInteger;
+// }
+//
+// public void setNormalFloat(float normalFloat) {
+// float old = this.normalFloat;
+// this.normalFloat = normalFloat;
+// p.firePropertyChange("normalFloat", old, normalFloat);
+// }
+//
+// public void setNormalInteger(int normalInteger) {
+// int old = this.normalInteger;
+// this.normalInteger = normalInteger;
+// p.firePropertyChange("normalInteger", old, normalInteger);
+// }
+//
+// public void setPositifFloat(float positifFloat) {
+// float old = this.positifFloat;
+// this.positifFloat = positifFloat;
+// p.firePropertyChange("positifFloat", old, positifFloat);
+// }
+//
+// public void setPositifInteger(int positifInteger) {
+// int old = this.positifInteger;
+// this.positifInteger = positifInteger;
+// p.firePropertyChange("positifInteger", old, positifInteger);
+// }
public void addPropertyChangeListener(PropertyChangeListener listener) {
p.addPropertyChangeListener(listener);
}
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/BaseContent.jaxx)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,99 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 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>.
+ ##%*
+-->
+<JPanel layout='{new BorderLayout()}'>
+
+ <Object id='data' javaBean='helper.getSelectedBean(this)'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+String getType(Object data) {
+ if (data == null) {
+ return "no type";
+ }
+ if (data instanceof java.util.List<?>) {
+ java.util.List<?> l = (java.util.List<?>) data;
+ if (l.isEmpty()) {
+ return "Empty collection";
+ }
+ return "Collection of " + l.size() + " " + l.get(0).getClass().getSimpleName() + "(s)";
+ }
+ return data.getClass().getSimpleName();
+}
+
+String getContent(Object data) {
+ if (data == null) {
+ return "no content";
+ }
+ StringBuilder buffer = new StringBuilder();
+ if (data instanceof java.util.List) {
+ for (Object o : ((java.util.List)data)) {
+ buffer.append(o).append("\n");
+ }
+ } else {
+ buffer.append(data);
+ }
+ return buffer.toString();
+}
+
+ImageIcon getImage(Object data) {
+ if (data == null) {
+ return null;
+ }
+ if (data instanceof Movie) {
+ return SwingUtil.createIcon(((Movie)data).getImage());
+ }
+ if (data instanceof People) {
+ return SwingUtil.createIcon(((People)data).getImage());
+ }
+ return null;
+}
+ ]]>
+ </script>
+
+ <JSplitPane id='splitPane'
+ orientation='{JSplitPane.VERTICAL_SPLIT}'
+ resizeWeight='0.5'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'>
+ <JTextPane border='{new TitledBorder("Content Type : " + getType(getData()))}'
+ editable='false'
+ font-size='11'
+ text='{getContent(getData())}'/>
+ </JScrollPane>
+
+ <JScrollPane border='{new TitledBorder("Picture")}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED}'
+ minimumSize='{SwingUtil.newMinDimension()}'>
+
+ <JLabel horizontalAlignment='center' icon='{getImage(getData())}'/>
+
+ </JScrollPane>
+
+ </JSplitPane>
+</JPanel>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/BaseContent.jaxx
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeDemo.jaxx)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,82 @@
+<!--
+ *##%
+ jaxx-demo
+ Copyright (C) 2008 - 2009 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>.
+ ##%*
+-->
+
+<jaxx.demo.DemoPanel>
+
+ <jaxx.runtime.swing.CardLayout2 id='contentLayout'
+ useOnlyVisibleComponentDimension='true'/>
+
+ <script><![CDATA[
+import jaxx.runtime.SwingUtil;
+
+private final FullNavigationTreeHelper helper = new FullNavigationTreeHelper();
+
+helper.createModel(this);
+
+@Override
+protected String[] getSources() {
+ return new String[]{ getDefaultSource(), "BaseContent.jaxx", "FullNavigationTreeHelper.java", "Movie.java", "People.java" };
+}
+
+private void $afterCompleteSetup() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ navigation.setSelectionInterval(0, 0);
+ splitPane.resetToPreferredSizes();
+ }
+ });
+ // expand the tree
+ SwingUtil.expandTree(navigation);
+ // auto-expand node when selected
+ SwingUtil.addExpandOnClickListener(navigation);
+}
+ ]]>
+ </script>
+
+ <JPanel id='demoPanel' layout='{new BorderLayout()}'>
+
+ <JSplitPane id='splitPane'
+ constraints='BorderLayout.CENTER'
+ oneTouchExpandable='true'>
+
+ <JScrollPane border='{null}'
+ horizontalScrollBarPolicy='{JScrollPane.HORIZONTAL_SCROLLBAR_NEVER}'
+ verticalScrollBarPolicy='{JScrollPane.VERTICAL_SCROLLBAR_NEVER}'>
+
+ <JTree id="navigation"
+ font-size='11'
+ rootVisible='false'
+ showsRootHandles='false'
+ model='{helper.createTreeModel(this)}'
+ selectionModel="{helper.createTreeHandler(this)}"/>
+ <!--cellRenderer='{new NavigationTreeCellRenderer(this, 150)}' />-->
+
+ </JScrollPane>
+
+ <JPanel id="content" layout="{contentLayout}" />
+
+ </JSplitPane>
+
+ </JPanel>
+
+</jaxx.demo.DemoPanel>
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeDemo.jaxx
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/FullNavigationTreeHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,242 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 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>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation;
+
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import static jaxx.runtime.context.JAXXContextEntryDef.newListDef;
+import jaxx.runtime.decorator.Decorator;
+import jaxx.runtime.decorator.DecoratorUtils;
+import jaxx.runtime.swing.CardLayout2;
+import jaxx.runtime.swing.ErrorDialogUI;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler;
+import jaxx.runtime.swing.navigation.NavigationTreeHandler.Strategy;
+import jaxx.runtime.swing.navigation.NavigationTreeHandlerWithCardLayout;
+import jaxx.runtime.swing.navigation.NavigationTreeHelper;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import static org.nuiton.i18n.I18n._;
+
+import java.util.Arrays;
+import java.util.List;
+import javax.swing.JPanel;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class FullNavigationTreeHelper extends NavigationTreeHelper {
+
+ static {
+ // register decorator one for all
+
+ DecoratorUtils.register(
+ Movie.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(Movie.class, "${title}$s##${year}$s", "##", " - "));
+
+ DecoratorUtils.register(
+ People.class.getSimpleName(),
+ DecoratorUtils.newMultiJXPathDecorator(People.class, "${firstName}$s##${lastName}$s", "##", " "));
+ }
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(FullNavigationTreeHelper.class);
+ /**
+ * where the movies are hold in context
+ */
+ static public final JAXXContextEntryDef<List<Movie>> MOVIES = JAXXContextEntryDef.newListDef("movies");
+ /**
+ * where the actors are hold in context
+ */
+ static public final JAXXContextEntryDef<List<People>> ACTORS = JAXXContextEntryDef.newListDef("actors");
+
+ public FullNavigationTreeHelper() {
+ super("full");
+ }
+
+ /**
+ * Create the model and store it in the given context.
+ *
+ * @param context the context where to hold the model
+ */
+ public void createModel(JAXXContext context) {
+ People a = new People("0", "Jack", "Black", 0, "/jaxx/demo/images/jack.jpg");
+ People a2 = new People("1", "Héctor", "Jiménez", 0, "/jaxx/demo/images/hector.jpg");
+ People a3 = new People("2", "Ana", "de la Reguera", 0, "/jaxx/demo/images/ana.jpg");
+
+ Movie m = new Movie("0", "Nacho libre", 1996, "/jaxx/demo/images/nacho.jpg");
+ m.addActor(a);
+ m.addActor(a2);
+ m.addActor(a3);
+
+ Movie m2 = new Movie("1", "Nacho 2", 2009, "/jaxx/demo/images/nacho2.png");
+ m2.addActor(a);
+ m2.addActor(a2);
+
+ MOVIES.setContextValue(context, Arrays.asList(m, m2));
+ ACTORS.setContextValue(context, Arrays.asList(a, a2, a3));
+ }
+
+ @Override
+ public NavigationTreeModel createTreeModel(JAXXContext context) {
+
+ List<Movie> movies = MOVIES.getContextValue(context);
+ List<People> actors = ACTORS.getContextValue(context);
+
+ if (log.isDebugEnabled()) {
+ log.debug("for " + movies.size() + " movie(s)");
+ }
+
+ NavigationTreeModelBuilder builder = new NavigationTreeModelBuilder("/", context, BaseContent.class,
+ null);
+
+ Decorator<Movie> mDecorator = DecoratorUtils.get(Movie.class.getSimpleName());
+ Decorator<People> pDecorator = DecoratorUtils.get(People.class.getSimpleName());
+
+ // construction du noeud root
+ // il ne contient pas de context et ne sera pas visible
+ NavigationTreeNode rootNode = builder.buildEmptyRoot(null, "$root");
+
+ // construction du noeud avec les films recupere la liste des films
+ // dans le context avec la clef movies
+ // navigation path = $root/movies
+ NavigationTreeNode moviesNode = builder.build(
+ rootNode,
+ _("movies"),
+ newListDef("movies"),
+ "movies",
+ null,
+ null);
+
+ for (Movie m : movies) {
+
+ // navigation path = $root/movies/m.id
+ NavigationTreeNode movieNode = builder.build(
+ moviesNode,
+ mDecorator,
+ "..[@id=\"" + m.getId() + "\"]",
+ m.getId(),
+ null,
+ null);
+
+ // navigation path = $root/movies/m.id/actors
+ NavigationTreeNode actorsNode = builder.build(
+ movieNode,
+ _("actors"),
+ "../actors",
+ "actors",
+ null,
+ null);
+
+ for (People p : m.getActors()) {
+ // navigation path = $root/movies/m.id/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ }
+
+ // construction du noeud avec les acteurs
+ NavigationTreeNode actorsNode = builder.build(rootNode, _("actors"),
+ newListDef("actors"),
+ "actors", null, null);
+
+ for (People p : actors) {
+ // navigation path = $root/actors/p.id
+ builder.build(
+ actorsNode,
+ pDecorator,
+ "..[@id=\"" + p.getId() + "\"]",
+ p.getId(),
+ null,
+ null);
+ }
+ NavigationTreeModel model = builder.getModel();
+
+ if (log.isDebugEnabled()) {
+ builder.printModel(model.getRoot());
+ }
+
+ // save tree model in context
+ setTreeModel(context, model);
+ return model;
+ }
+
+ @Override
+ public NavigationTreeHandler createTreeHandler(JAXXObject context) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("create handler");
+ }
+
+ NavigationTreeHandler handler;
+
+ handler = new NavigationTreeHandlerWithCardLayout(
+ getPrefix(),
+ context,
+ Strategy.PER_NODE) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected NavigationTreeModel getNavigationTreeModel() {
+ return getSafeTreeModel(getContext());
+ }
+
+ @Override
+ protected JPanel getContentContainer() {
+ return getContext().getContent();
+ }
+
+ @Override
+ protected CardLayout2 getContentLayout() {
+ return getContext().getContentLayout();
+ }
+
+ @Override
+ protected void treateError(Exception e) {
+ ErrorDialogUI.showError(e);
+ }
+
+ @Override
+ public FullNavigationTreeDemo getContext() {
+ return (FullNavigationTreeDemo) this.context;
+ }
+ };
+ // on ne peut selectionner qu'un seul noeud a la fois
+ handler.setSelectionMode(NavigationTreeHandler.SINGLE_TREE_SELECTION);
+
+ // save handler in ui context
+ setTreeHandler(context, handler);
+ return handler;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/FullNavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/Movie.java)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,128 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 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>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation;
+
+import java.util.ArrayList;
+import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class Movie {
+
+ protected String id;
+ protected String title;
+ protected String image;
+ protected int year;
+ protected List<People> actors;
+
+ public Movie(String id, String title, int year,String image) {
+ this();
+ this.id = id;
+ this.title = title;
+ this.year = year;
+ this.image=image;
+ }
+
+ public Movie() {
+ actors = new ArrayList<People>();
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public List<People> getActors() {
+ return actors;
+ }
+
+ public void setActors(List<People> actors) {
+ this.actors = actors;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ public void addActor(People actor) {
+ actors.add(actor);
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final Movie other = (Movie) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 5;
+ hash = 41 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("title", title);
+ b.append("year", year);
+ b.append("actors", actors);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/Movie.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java (from rev 1560, branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/tree/People.java)
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java (rev 0)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,118 @@
+/*
+ * *##%
+ * jaxx-demo
+ * Copyright (C) 2008 - 2009 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>.
+ * ##%*
+ */
+package jaxx.demo.component.jaxx.navigation;
+
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
+/**
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class People {
+
+ protected String id;
+ protected String image;
+ protected String firstName;
+ protected String lastName;
+ protected int age;
+
+ public People(String id, String firstName, String lastName, int age, String image) {
+ this.id = id;
+ this.firstName = firstName;
+ this.lastName = lastName;
+ this.age = age;
+ this.image = image;
+ }
+
+ public int getAge() {
+ return age;
+ }
+
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ public String getFirstName() {
+ return firstName;
+ }
+
+ public void setFirstName(String firstName) {
+ this.firstName = firstName;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public void setId(String id) {
+ this.id = id;
+ }
+
+ public String getLastName() {
+ return lastName;
+ }
+
+ public void setLastName(String lastName) {
+ this.lastName = lastName;
+ }
+
+ public String getImage() {
+ return image;
+ }
+
+ public void setImage(String image) {
+ this.image = image;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ final People other = (People) obj;
+ if ((this.id == null) ? (other.id != null) : !this.id.equals(other.id)) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = 7;
+ hash = 97 * hash + (this.id != null ? this.id.hashCode() : 0);
+ return hash;
+ }
+
+ @Override
+ public String toString() {
+ ToStringBuilder b = new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE);
+ b.append("id", id);
+ b.append("firstName", firstName);
+ b.append("lastName", lastName);
+ b.append("age", age);
+ return b.toString();
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/People.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-en_GB.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -106,12 +106,14 @@
edit=Edit
edit2=Edit 2
edit3=Edit 3
+editor.getSelectedLocale()=
form.ratio=Ratio
form.text=Text
form.text2=Text 2
form2.ratio=Form 2 Ratio
form2.text=Form 2 Text
form2.text2=Form 2 Text 2
+i18neditor.popup.title=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>For more informations, viste the <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">website of the project</a>.
jaxxdemo.action.about=About...
jaxxdemo.action.about.tip=About JAXXDemo...
@@ -138,6 +140,13 @@
jaxxdemo.config.configFileName.description=Configuration file name
jaxxdemo.config.ui.fullscreen=To change the screen mode (true for full screen)
jaxxdemo.config.ui.locale=Locale of the application
+jaxxdemo.i18neditor.configuration=Configuration
+jaxxdemo.i18neditor.popupBorderText=Popup title
+jaxxdemo.i18neditor.selected.locale=Selected Language
+jaxxdemo.i18neditor.showIcon=Show icons
+jaxxdemo.i18neditor.showPopupIcon=Show icons in popup
+jaxxdemo.i18neditor.showPopupText=Show texts in popup
+jaxxdemo.i18neditor.showText=Show text
jaxxdemo.init.closed=JAXXDemo was closed at %1$s
jaxxdemo.init.context.done=Context initialized in %1$s
jaxxdemo.init.ui.done=UI initialized.
@@ -146,6 +155,15 @@
jaxxdemo.menu.help=
jaxxdemo.message.config.loaded=Configuration of JAXXDemo v. %1$s loaded.
jaxxdemo.message.goto.site=Go to JAXXDemo Web site
+jaxxdemo.numbereditor.autoPopup=
+jaxxdemo.numbereditor.configuration=
+jaxxdemo.numbereditor.model=
+jaxxdemo.numbereditor.model.float=
+jaxxdemo.numbereditor.model.int=
+jaxxdemo.numbereditor.showPopupButton=
+jaxxdemo.numbereditor.showReset=
+jaxxdemo.numbereditor.useFloat=
+jaxxdemo.numbereditor.useSign=
jaxxdemo.title.about=About JAXXDemo...
jaxxdemo.tree.component.jaxx=JAXX Components
jaxxdemo.tree.component.jaxx.editor=Editors
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/i18n/jaxx-demo-fr_FR.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -106,12 +106,14 @@
edit=Editer
edit2=Editer 2
edit3=Editer 3
+editor.getSelectedLocale()=
form.ratio=Form \: ratio
form.text=Form \: text
form.text2=Form \: text2
form2.ratio=Form2 \: ratio
form2.text=Form2 \: text
form2.text2=Form2 \: text2
+i18neditor.popup.title=
jaxxdemo.about.message=<h3>JAXX Demo</h3><hr/>Pour plus d'informations, vous pouvez visiter le <a href\="http\://maven-site.nuiton.org/jaxx/jaxx-demo">site du projet</a>.
jaxxdemo.action.about=A propos
jaxxdemo.action.about.tip=A propos de JAXX Demo...
@@ -138,6 +140,13 @@
jaxxdemo.config.configFileName.description=Le nom du fichier de configuration
jaxxdemo.config.ui.fullscreen=Pour afficher l'aplication en mode pleine \u00E9cran
jaxxdemo.config.ui.locale=Langue utilis\u00E9e par l'application (fr_FR, en_GB ou es_ES)
+jaxxdemo.i18neditor.configuration=Configuration
+jaxxdemo.i18neditor.popupBorderText=Titre de la popup
+jaxxdemo.i18neditor.selected.locale=Langue s\u00E9lectionn\u00E9e
+jaxxdemo.i18neditor.showIcon=Afficher les icones
+jaxxdemo.i18neditor.showPopupIcon=Afficher les icones dans la popup
+jaxxdemo.i18neditor.showPopupText=Afficher les textes dans la popup
+jaxxdemo.i18neditor.showText=Afficher le text
jaxxdemo.init.closed=JAXX Demo a \u00E9t\u00E9 ferm\u00E9 \u00E0 %1$s
jaxxdemo.init.context.done=Initialisation du contexte termin\u00E9e en %1$s.
jaxxdemo.init.ui.done=Initialisation de l'interface graphique termin\u00E9e.
@@ -146,6 +155,15 @@
jaxxdemo.menu.help=Aide
jaxxdemo.message.config.loaded=Configuration de JAXX Demo v. %1$s charg\u00E9e.
jaxxdemo.message.goto.site=Acc\u00E9der au site de JAXX Demo (%1$s)
+jaxxdemo.numbereditor.autoPopup=Affichage automatique popup
+jaxxdemo.numbereditor.configuration=Configuration
+jaxxdemo.numbereditor.model=R\u00E9sultat
+jaxxdemo.numbereditor.model.float=Valeur d\u00E9cimale \: %1$s
+jaxxdemo.numbereditor.model.int=Valeur enti\u00E8re \: %1$s
+jaxxdemo.numbereditor.showPopupButton=Afficher le boutton de popup
+jaxxdemo.numbereditor.showReset=Afficher le boutton de reset
+jaxxdemo.numbereditor.useFloat=Utiliser les d\u00E9cimales
+jaxxdemo.numbereditor.useSign=Utiliser le signe
jaxxdemo.title.about=A propos de JAXX Demo...
jaxxdemo.tree.component.jaxx=Composants JAXX
jaxxdemo.tree.component.jaxx.editor=Editeurs
Modified: branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-demo/src/main/resources/log4j.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -6,7 +6,8 @@
log4j.appender.stdout.layout.ConversionPattern=%5p [%t] (%F:%L) %M - %m%n
log4j.logger.jaxx.demo=INFO
-#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeCellRenderer=DEBUG
-#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeNodeRenderer=DEBUG
-#log4j.logger.jaxx.runtime.swing.tree.NavigationTreeModel=DEBUG
+log4j.logger.jaxx.runtime.swing.editor.I18nEditor=INFO
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeCellRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeNodeRenderer=DEBUG
+#log4j.logger.jaxx.runtime.swing.navigation.NavigationTreeModel=DEBUG
log4j.logger.org.nuiton=WARN
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,240 +0,0 @@
-package jaxx;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectInputStream;
-import java.io.ObjectOutputStream;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
-
-/**
- * A Base64 Encoder/Decoder.
- * <p/>
- * <p/>
- * This class is used to encode and decode data in Base64 format as described in RFC 1521.
- * <p/>
- * <p/>
- * This is "Open Source" software and released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a> license.<br>
- * It is provided "as is" without warranty of any kind.<br>
- * Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.<br>
- * Home page: <a href="http://www.source-code.biz">www.source-code.biz</a><br>
- * <p/>
- * <p/>
- * Version history:<br>
- * 2003-07-22 Christian d'Heureuse (chdh): Module created.<br>
- * 2005-08-11 chdh: Lincense changed from GPL to LGPL.<br>
- * 2006-11-21 chdh:<br>
- * Method encode(String) renamed to encodeString(String).<br>
- * Method decode(String) renamed to decodeString(String).<br>
- * New method encode(byte[],int) added.<br>
- * New method decode(String) added.<br>
- */
-
-public class Base64Coder {
-
- // Mapping table from 6-bit nibbles to Base64 characters.
- private static char[] map1 = new char[64];
-
- static {
- int i = 0;
- for (char c = 'A'; c <= 'Z'; c++) {
- map1[i++] = c;
- }
- for (char c = 'a'; c <= 'z'; c++) {
- map1[i++] = c;
- }
- for (char c = '0'; c <= '9'; c++) {
- map1[i++] = c;
- }
- map1[i++] = '+';
- map1[i] = '/';
- }
-
- // Mapping table from Base64 characters to 6-bit nibbles.
- private static byte[] map2 = new byte[128];
-
- static {
- for (int i = 0; i < map2.length; i++) {
- map2[i] = -1;
- }
- for (int i = 0; i < 64; i++) {
- map2[map1[i]] = (byte) i;
- }
- }
-
- /**
- * Read the object from Base64 string.
- *
- * @param s the string representation of serialized object.
- * @param gzip if gzip stream
- * @return the deserialize object
- * @throws java.io.IOException if any io pb
- * @throws ClassNotFoundException if class not found ?
- */
- public static Object deserialize(String s, boolean gzip) throws IOException,
- ClassNotFoundException {
- byte[] data = Base64Coder.decode(s);
- InputStream stream = new ByteArrayInputStream(data);
- if (gzip) {
- stream = new GZIPInputStream(stream);
- }
- ObjectInputStream ois = new ObjectInputStream(stream);
- Object o = ois.readObject();
- ois.close();
- return o;
- }
-
- /**
- * Write the object to a Base64 string.
- *
- * @param o the object to serialize
- * @param gzip if gzip stream
- * @return the string representation
- * @throws java.io.IOException if any io pb
- */
- public static String serialize(Object o, boolean gzip) throws IOException {
- ByteArrayOutputStream stream = new ByteArrayOutputStream();
- ObjectOutputStream oos;
- if (gzip) {
- oos = new ObjectOutputStream(new GZIPOutputStream(stream));
- } else {
- oos = new ObjectOutputStream(stream);
- }
- oos.writeObject(o);
- oos.close();
- return new String(Base64Coder.encode(stream.toByteArray()));
- }
-
- /**
- * Encodes a string into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param s a String to be encoded.
- * @return A String with the Base64 encoded data.
- */
- public static String encodeString(String s) {
- return new String(encode(s.getBytes()));
- }
-
- /**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param in an array containing the data bytes to be encoded.
- * @return A character array with the Base64 encoded data.
- */
- public static char[] encode(byte[] in) {
- return encode(in, in.length);
- }
-
- /**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param in an array containing the data bytes to be encoded.
- * @param iLen number of bytes to process in <code>in</code>.
- * @return A character array with the Base64 encoded data.
- */
- public static char[] encode(byte[] in, int iLen) {
- int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
- int oLen = ((iLen + 2) / 3) * 4; // output length including padding
- char[] out = new char[oLen];
- int ip = 0;
- int op = 0;
- while (ip < iLen) {
- int i0 = in[ip++] & 0xff;
- int i1 = ip < iLen ? in[ip++] & 0xff : 0;
- int i2 = ip < iLen ? in[ip++] & 0xff : 0;
- int o0 = i0 >>> 2;
- int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
- int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
- int o3 = i2 & 0x3F;
- out[op++] = map1[o0];
- out[op++] = map1[o1];
- out[op] = op < oDataLen ? map1[o2] : '=';
- op++;
- out[op] = op < oDataLen ? map1[o3] : '=';
- op++;
- }
- return out;
- }
-
- /**
- * Decodes a string from Base64 format.
- *
- * @param s a Base64 String to be decoded.
- * @return A String containing the decoded data.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static String decodeString(String s) {
- return new String(decode(s));
- }
-
- /**
- * Decodes a byte array from Base64 format.
- *
- * @param s a Base64 String to be decoded.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static byte[] decode(String s) {
- return decode(s.toCharArray());
- }
-
- /**
- * Decodes a byte array from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded data.
- *
- * @param in a character array containing the Base64 encoded data.
- * @return An array containing the decoded data bytes.
- * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
- */
- public static byte[] decode(char[] in) {
- int iLen = in.length;
- if (iLen % 4 != 0) {
- throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
- }
- while (iLen > 0 && in[iLen - 1] == '=') {
- iLen--;
- }
- int oLen = (iLen * 3) / 4;
- byte[] out = new byte[oLen];
- int ip = 0;
- int op = 0;
- while (ip < iLen) {
- int i0 = in[ip++];
- int i1 = in[ip++];
- int i2 = ip < iLen ? in[ip++] : 'A';
- int i3 = ip < iLen ? in[ip++] : 'A';
- if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) {
- throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
- }
- int b0 = map2[i0];
- int b1 = map2[i1];
- int b2 = map2[i2];
- int b3 = map2[i3];
- if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) {
- throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
- }
- int o0 = (b0 << 2) | (b1 >>> 4);
- int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
- int o2 = ((b2 & 3) << 6) | b3;
- out[op++] = (byte) o0;
- if (op < oLen) {
- out[op++] = (byte) o1;
- }
- if (op < oLen) {
- out[op++] = (byte) o2;
- }
- }
- return out;
- }
-
- // Dummy constructor.
- private Base64Coder() {
- }
-
-} // end class Base64Coder
-
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/Base64Coder.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,240 @@
+package jaxx.runtime;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
+/**
+ * A Base64 Encoder/Decoder.
+ * <p/>
+ * <p/>
+ * This class is used to encode and decode data in Base64 format as described in RFC 1521.
+ * <p/>
+ * <p/>
+ * This is "Open Source" software and released under the <a href="http://www.gnu.org/licenses/lgpl.html">GNU/LGPL</a> license.<br>
+ * It is provided "as is" without warranty of any kind.<br>
+ * Copyright 2003: Christian d'Heureuse, Inventec Informatik AG, Switzerland.<br>
+ * Home page: <a href="http://www.source-code.biz">www.source-code.biz</a><br>
+ * <p/>
+ * <p/>
+ * Version history:<br>
+ * 2003-07-22 Christian d'Heureuse (chdh): Module created.<br>
+ * 2005-08-11 chdh: Lincense changed from GPL to LGPL.<br>
+ * 2006-11-21 chdh:<br>
+ * Method encode(String) renamed to encodeString(String).<br>
+ * Method decode(String) renamed to decodeString(String).<br>
+ * New method encode(byte[],int) added.<br>
+ * New method decode(String) added.<br>
+ */
+
+public class Base64Coder {
+
+ // Mapping table from 6-bit nibbles to Base64 characters.
+ private static char[] map1 = new char[64];
+
+ static {
+ int i = 0;
+ for (char c = 'A'; c <= 'Z'; c++) {
+ map1[i++] = c;
+ }
+ for (char c = 'a'; c <= 'z'; c++) {
+ map1[i++] = c;
+ }
+ for (char c = '0'; c <= '9'; c++) {
+ map1[i++] = c;
+ }
+ map1[i++] = '+';
+ map1[i] = '/';
+ }
+
+ // Mapping table from Base64 characters to 6-bit nibbles.
+ private static byte[] map2 = new byte[128];
+
+ static {
+ for (int i = 0; i < map2.length; i++) {
+ map2[i] = -1;
+ }
+ for (int i = 0; i < 64; i++) {
+ map2[map1[i]] = (byte) i;
+ }
+ }
+
+ /**
+ * Read the object from Base64 string.
+ *
+ * @param s the string representation of serialized object.
+ * @param gzip if gzip stream
+ * @return the deserialize object
+ * @throws java.io.IOException if any io pb
+ * @throws ClassNotFoundException if class not found ?
+ */
+ public static Object deserialize(String s, boolean gzip) throws IOException,
+ ClassNotFoundException {
+ byte[] data = Base64Coder.decode(s);
+ InputStream stream = new ByteArrayInputStream(data);
+ if (gzip) {
+ stream = new GZIPInputStream(stream);
+ }
+ ObjectInputStream ois = new ObjectInputStream(stream);
+ Object o = ois.readObject();
+ ois.close();
+ return o;
+ }
+
+ /**
+ * Write the object to a Base64 string.
+ *
+ * @param o the object to serialize
+ * @param gzip if gzip stream
+ * @return the string representation
+ * @throws java.io.IOException if any io pb
+ */
+ public static String serialize(Object o, boolean gzip) throws IOException {
+ ByteArrayOutputStream stream = new ByteArrayOutputStream();
+ ObjectOutputStream oos;
+ if (gzip) {
+ oos = new ObjectOutputStream(new GZIPOutputStream(stream));
+ } else {
+ oos = new ObjectOutputStream(stream);
+ }
+ oos.writeObject(o);
+ oos.close();
+ return new String(Base64Coder.encode(stream.toByteArray()));
+ }
+
+ /**
+ * Encodes a string into Base64 format.
+ * No blanks or line breaks are inserted.
+ *
+ * @param s a String to be encoded.
+ * @return A String with the Base64 encoded data.
+ */
+ public static String encodeString(String s) {
+ return new String(encode(s.getBytes()));
+ }
+
+ /**
+ * Encodes a byte array into Base64 format.
+ * No blanks or line breaks are inserted.
+ *
+ * @param in an array containing the data bytes to be encoded.
+ * @return A character array with the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in) {
+ return encode(in, in.length);
+ }
+
+ /**
+ * Encodes a byte array into Base64 format.
+ * No blanks or line breaks are inserted.
+ *
+ * @param in an array containing the data bytes to be encoded.
+ * @param iLen number of bytes to process in <code>in</code>.
+ * @return A character array with the Base64 encoded data.
+ */
+ public static char[] encode(byte[] in, int iLen) {
+ int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
+ int oLen = ((iLen + 2) / 3) * 4; // output length including padding
+ char[] out = new char[oLen];
+ int ip = 0;
+ int op = 0;
+ while (ip < iLen) {
+ int i0 = in[ip++] & 0xff;
+ int i1 = ip < iLen ? in[ip++] & 0xff : 0;
+ int i2 = ip < iLen ? in[ip++] & 0xff : 0;
+ int o0 = i0 >>> 2;
+ int o1 = ((i0 & 3) << 4) | (i1 >>> 4);
+ int o2 = ((i1 & 0xf) << 2) | (i2 >>> 6);
+ int o3 = i2 & 0x3F;
+ out[op++] = map1[o0];
+ out[op++] = map1[o1];
+ out[op] = op < oDataLen ? map1[o2] : '=';
+ op++;
+ out[op] = op < oDataLen ? map1[o3] : '=';
+ op++;
+ }
+ return out;
+ }
+
+ /**
+ * Decodes a string from Base64 format.
+ *
+ * @param s a Base64 String to be decoded.
+ * @return A String containing the decoded data.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static String decodeString(String s) {
+ return new String(decode(s));
+ }
+
+ /**
+ * Decodes a byte array from Base64 format.
+ *
+ * @param s a Base64 String to be decoded.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(String s) {
+ return decode(s.toCharArray());
+ }
+
+ /**
+ * Decodes a byte array from Base64 format.
+ * No blanks or line breaks are allowed within the Base64 encoded data.
+ *
+ * @param in a character array containing the Base64 encoded data.
+ * @return An array containing the decoded data bytes.
+ * @throws IllegalArgumentException if the input is not valid Base64 encoded data.
+ */
+ public static byte[] decode(char[] in) {
+ int iLen = in.length;
+ if (iLen % 4 != 0) {
+ throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
+ }
+ while (iLen > 0 && in[iLen - 1] == '=') {
+ iLen--;
+ }
+ int oLen = (iLen * 3) / 4;
+ byte[] out = new byte[oLen];
+ int ip = 0;
+ int op = 0;
+ while (ip < iLen) {
+ int i0 = in[ip++];
+ int i1 = in[ip++];
+ int i2 = ip < iLen ? in[ip++] : 'A';
+ int i3 = ip < iLen ? in[ip++] : 'A';
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) {
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ }
+ int b0 = map2[i0];
+ int b1 = map2[i1];
+ int b2 = map2[i2];
+ int b3 = map2[i3];
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) {
+ throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ }
+ int o0 = (b0 << 2) | (b1 >>> 4);
+ int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
+ int o2 = ((b2 & 3) << 6) | b3;
+ out[op++] = (byte) o0;
+ if (op < oLen) {
+ out[op++] = (byte) o1;
+ }
+ if (op < oLen) {
+ out[op++] = (byte) o2;
+ }
+ }
+ return out;
+ }
+
+ // Dummy constructor.
+ private Base64Coder() {
+ }
+
+} // end class Base64Coder
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Base64Coder.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingListener.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -34,6 +34,7 @@
*
* @param e the event which triggered the binding
*/
+ @Override
public void propertyChange(PropertyChangeEvent e) {
object.processDataBinding(dest);
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataBindingUpdateListener.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -39,6 +39,7 @@
*
* @param e the event which triggered the binding
*/
+ @Override
public void propertyChange(PropertyChangeEvent e) {
object.removeDataBinding(dest);
object.applyDataBinding(dest);
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,400 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Container;
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.util.Iterator;
-import java.util.NoSuchElementException;
-import java.util.regex.Pattern;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * Un contexte de données qui permet l'utilisation des bindings sur les
- * entrées du contexte.
- *
- * TODO javadoc
- *
- * @author tony
- * @since 1.3
- */
-public abstract class DataContext {
-
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private Log log = LogFactory.getLog(DataContext.class);
- /** le context qui contient les données */
- protected final DefaultJAXXContext delegate;
- /** la definition de l'entree actuallement selectionnee */
- protected DataContextEntry<?> currentEntry;
- /** to manage properties modifications */
- protected final PropertyChangeSupport pcs;
- protected DataContextEntry<?>[] entries;
- protected final String[] DEFAULT_JAXX_PCS;
-
- public abstract String getContextPath(Object... e);
-
- public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) {
- this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS;
- this.entries = entries;
- delegate = new DefaultJAXXContext() {
-
- @Override
- protected void setUi(JAXXObject ui) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Class<O> clazz) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- protected JAXXObject getUi() {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- protected void setParentContext(JAXXContext parentContext) {
- throw new IllegalStateException("can not use this method for this type of context");
- }
-
- @Override
- protected JAXXContext getParentContext() {
- return null;
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- if (log.isTraceEnabled()) {
- log.trace(klazz + " - " + name);
- }
- super.removeContextValue(klazz, name);
- }
-
- @Override
- public <T> void setContextValue(T o, String name) {
- if (log.isTraceEnabled()) {
- log.trace(name + " - " + o.getClass());
- }
- super.setContextValue(o, name);
- }
- };
- pcs = new PropertyChangeSupport(this);
- }
-
- public DefaultJAXXContext getDelegate() {
- return delegate;
- }
-
- public Iterable<? extends DataContextEntry<?>> iterateOnAll() {
- return new Iterable<DataContextEntry<?>>() {
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- return new DataContextEntryIterator(entries);
- }
- };
- }
-
- public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) {
- return new Iterable<DataContextEntry<?>>() {
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- return new DataContextEntryIterator(entries, level);
- }
- };
- }
-
- public Iterable<? extends DataContextEntry<?>> reverseIterateOnAll() {
-
- return new Iterable<DataContextEntry<?>>() {
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- return new DataContextEntryIterator(entries, true);
- }
- };
- }
-
- public DataContextEntry<?> getCurrentEntry() {
- return currentEntry;
- }
-
- public DataContextEntry<?> getEntry(String path) {
- for (DataContextEntry<?> scope : reverseIterateOnAll()) {
- if (scope.acceptPath(path)) {
- return scope;
- }
- }
- return null;
- }
-
- public DataContextEntry<?> getEntry(Class<?> type) {
- for (DataContextEntry<?> scope : iterateOnAll()) {
- if (scope.acceptType(type)) {
- return scope;
- }
- }
- return null;
- }
-
- public <T> T getContextValue(DataContextEntry<T> entry, String key) {
- String contextKey = getKey(entry, key);
- T result = delegate.getContextValue(entry.getKlass(), contextKey);
- return result;
- }
-
- public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
- String contextKey = getKey(entry, key);
- delegate.setContextValue(value, contextKey);
- }
-
- public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
- String contextKey = getKey(entry, key);
- delegate.removeContextValue(value.getClass(), contextKey);
- }
-
- @SuppressWarnings("unchecked")
- public void updateSelectedData(String path, Object data, UpdateDataContext updator) {
-
- if (log.isDebugEnabled()) {
- log.debug("----------------------------------------------------------------");
- }
- if (currentEntry != null) {
-
- if (log.isDebugEnabled()) {
- log.debug("remove from old entry " + currentEntry);
- }
- for (DataContextEntry<?> s : currentEntry) {
- if (log.isDebugEnabled()) {
- log.debug("remove entry " + s);
- }
- updator.onRemovingData(this, s);
- }
- }
-
- currentEntry = getEntry(path);
-
- if (log.isDebugEnabled()) {
- log.debug("new entry " + currentEntry + " for path " + path);
- }
-
- if (currentEntry != null) {
-
- for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) {
-
- if (log.isDebugEnabled()) {
- log.debug("add entry " + s);
- }
- updator.onAddingData(this, s, path);
- }
- }
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public synchronized boolean hasListeners(String propertyName) {
- return pcs.hasListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
- return pcs.getPropertyChangeListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- return pcs.getPropertyChangeListeners();
- }
-
- public void removeJaxxPropertyChangeListener() {
- PropertyChangeListener[] toRemove = Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
- if (toRemove == null || toRemove.length == 0) {
- return;
- }
- if (log.isDebugEnabled()) {
- log.debug("before remove : " + getPropertyChangeListeners().length);
- log.debug("toRemove : " + toRemove.length);
- }
- for (PropertyChangeListener listener : toRemove) {
- removePropertyChangeListener(listener);
- }
- if (log.isDebugEnabled()) {
- log.debug("after remove : " + getPropertyChangeListeners().length);
- }
- }
-
- protected void firePropertyChange(String name, Object oldValue, Object newValue) {
- pcs.firePropertyChange(name, oldValue, newValue);
- }
-
- protected String getKey(DataContextEntry<?> entry, String key) {
- String result = null;
- if (key != null) {
- result = entry.hashCode() + "#" + key;
- }
- return result;
- }
-
- public void close() throws Exception {
- clear();
-
- // suppression des ecouteurs
-
- for (PropertyChangeListener l : getPropertyChangeListeners()) {
- removePropertyChangeListener(l);
- }
- }
-
- public void clear() {
- delegate.clear();
- }
-
- public static abstract class DataContextEntry<E> implements Iterable<DataContextEntry<?>> {
-
- private final int level;
- private final DataContextEntry<?> previous;
- private final DataContextEntry<?>[] parents;
- private Class<E> klass;
-
- public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
- this.previous = previous;
- this.level = previous.level + 1;
- this.klass = klass;
- this.parents = new DataContextEntry<?>[level];
- int i = level;
- while (i > 0) {
- parents[--i] = previous;
- previous = previous.previous;
- }
- }
-
- public DataContextEntry(Class<E> klass) {
- this.level = 0;
- this.klass = klass;
- this.previous = null;
- this.parents = new DataContextEntry<?>[0];
- }
-
- public Class<E> getKlass() {
- return klass;
- }
-
- public int getLevel() {
- return level;
- }
-
- public DataContextEntry<?>[] getParents() {
- return parents;
- }
-
- public abstract Pattern getPattern();
-
- public abstract String getContextPath(Object... args);
-
- public boolean acceptPath(String path) {
- return getPattern().matcher(path).matches();
- }
-
- public boolean acceptType(Class<?> type) {
- return klass.isAssignableFrom(type);
- }
-
- @Override
- public Iterator<DataContextEntry<?>> iterator() {
- int length = parents.length;
- DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1];
- System.arraycopy(parents, 0, t, 0, length);
- t[length] = this;
- return new DataContextEntryIterator(t, true);
- }
-
- @Override
- public String toString() {
- return super.toString() + "<type: " + klass.getSimpleName() + ">";
- }
- }
-
- public static interface UpdateDataContext<D extends DataContext> {
-
- void onRemovingData(D context, DataContextEntry<D> entry);
-
- void onAddingData(D context, DataContextEntry<D> entry, String path);
- }
-
- public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> {
-
- protected final DataContextEntry<?>[] datas;
- protected final boolean reverse;
- protected final int level;
- protected int index;
-
- public DataContextEntryIterator(DataContextEntry<?>[] datas) {
- this(datas, false, -1);
- }
-
- public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
- this(datas, false, level);
- }
-
- public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
- this(datas, reverse, -1);
- }
-
- DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
- this.datas = datas;
- this.reverse = reverse;
- if (reverse) {
- index = datas.length;
- } else {
- index = -1;
- }
- this.level = level;
- }
-
- @Override
- public boolean hasNext() {
- if (reverse) {
- return index > 0;
- } else {
- return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level);
- }
- }
-
- @Override
- public DataContextEntry<?> next() {
- if (!hasNext()) {
- throw new NoSuchElementException();
- }
- if (reverse) {
- index--;
- } else {
- index++;
- }
- return datas[index];
- }
-
- @Override
- public void remove() {
- throw new UnsupportedOperationException("Not supported yet.");
- }
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,281 +0,0 @@
-package jaxx.runtime;
-
-import java.beans.PropertyChangeListener;
-import java.beans.PropertyChangeSupport;
-import java.lang.annotation.*;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-/**
- * The default context to be used for an application.
- *
- * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate
- * some classes asked via {@link #getContextValue(java.lang.Class)} and
- * {@link #getContextValue(java.lang.Class, java.lang.String)} methods.
- *
- * To registred a such class, just annotate your class with {@link AutoLoad}.
- *
- * @author chemit
- * @since 1.2
- * @see DefaultJAXXContext
- */
-public class DefaultApplicationContext extends DefaultJAXXContext {
-
- /**
- * A class annotated @AutoLoad is used by context to auto
- * instanciate the class when required.
- *
- * Note : A such class always have a public default constructor.
- *
- * @author chemit
- * @version 1.0, 21/02/09
- * @since 1.2
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public static @interface AutoLoad {
- //TODO use this to add a method to init
-
- String initMethod() default "";
- }
-
- /**
- * A class annotated @MethodAccess is used by context to obtain the value
- * of an entry via a declared method.
- *
- * Note : A such class must have a method called {@link #methodName()} with
- * a single String parameter.
- *
- * @author chemit
- * @version 1.0, 21/02/09
- * @since 1.2
- */
- @Retention(RetentionPolicy.RUNTIME)
- @Target(ElementType.TYPE)
- public static @interface MethodAccess {
-
- /**
- * Define a forward to a target class. When the target class
- * will be asked with method {@link #getContextValue(java.lang.Class, java.lang.String)}
- * it will be delegating to this class.
- *
- * @return the forwarded class
- */
- Class<?> target() default Object.class;
-
- /**
- * @return the name of the method to access data
- */
- String methodName();
- }
- /**
- * Map of forwarded classes (key) to classes (values).
- */
- protected Map<Class<?>, Class<?>> forwards;
-
- public DefaultApplicationContext() {
- super();
- forwards = new HashMap<Class<?>, Class<?>>();
- pcs = new PropertyChangeSupport(this);
- }
-
- public DefaultApplicationContext(JAXXObject ui) {
- super(ui);
- }
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
-
- /** to manage properties modifications */
- protected PropertyChangeSupport pcs;
-
- @SuppressWarnings({"unchecked"})
- @Override
- public <T> T getContextValue(Class<T> clazz, String name) {
- Object value = null;
- MethodAccess access;
-
- Class<?> realClass;
-
- if (forwards.containsKey(clazz)) {
- // this is a forward class
- realClass = forwards.get(clazz);
- // always call the forwarder with no name
- value = getContextValue(realClass, null);
- if (log.isDebugEnabled()) {
- log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")");
- }
-
- } else {
- realClass = clazz;
- value = super.getContextValue(realClass, name);
- }
-
- if (value == null) {
- AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
-
- if (anno == null) {
- // no annotation, so do nothing
- return null;
- }
-
- if (name != null) {
- throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
- }
- value = newInstance(clazz);
- if (!anno.initMethod().trim().isEmpty()){
- // apply method on class
- newAccess(clazz, value, anno.initMethod().trim());
- }
- if (log.isDebugEnabled()) {
- log.debug("new instance " + clazz + " : " + value);
- }
- // save new instance
- setContextValue(value, null);
- }
-
- access = realClass.getAnnotation(MethodAccess.class);
-
- if (access != null) {
- if (name == null) {
- if (access.target() != Object.class) {
- // register forward
- Class<?> targetClass = access.target();
- if (!forwards.containsKey(targetClass)) {
- // register forward
- forwards.put(targetClass, clazz);
- if (log.isDebugEnabled()) {
- log.debug("register forward from " + targetClass + " to " + clazz);
- }
- }
- }
- } else {
- // specialized access
- value = newAccess(realClass, value, access.methodName(), name);
- }
- }
- return (T) value;
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- Entry<Class<?>, Class<?>> entry;
- if (name == null && forwards.containsValue(klazz)) {
- // remove forward
- Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
- while (itr.hasNext()) {
- entry = itr.next();
- if (entry.getValue().equals(klazz)) {
- itr.remove();
- if (log.isDebugEnabled()) {
- log.debug("removed forward from " + entry.getKey() + " to " + klazz);
- }
- break;
- }
- }
- }
- //FIXME should update forwards state
- super.removeContextValue(klazz, name);
- }
-
- public void addPropertyChangeListener(PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(listener);
- }
-
- public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.addPropertyChangeListener(propertyName, listener);
- }
-
- public void removePropertyChangeListener(PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(listener);
- }
-
- public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
- pcs.removePropertyChangeListener(propertyName, listener);
- }
-
- public synchronized boolean hasListeners(String propertyName) {
- return pcs.hasListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
- return pcs.getPropertyChangeListeners(propertyName);
- }
-
- public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
- return pcs.getPropertyChangeListeners();
- }
-
- protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
-
- Object value = null;
-
- Constructor<?> constructor = null;
- try {
- constructor = clazz.getConstructor();
- // auto instanciate the class
- if (constructor == null) {
- throw new IllegalArgumentException(clazz + " has no public constructor");
- }
- } catch (NoSuchMethodException ex) {
- throw new IllegalArgumentException(ex);
- } catch (SecurityException ex) {
- throw new IllegalArgumentException(ex);
- }
- try {
- value = constructor.newInstance();
-
- } catch (InstantiationException ex) {
- throw new IllegalArgumentException(ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException(ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- return value;
- }
-
- protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException {
- Object value;
- try {
- Method m = clazz.getMethod(methodName, String.class);
- value = m.invoke(parent, name);
- return value;
- } catch (NoSuchMethodException ex) {
- throw new IllegalArgumentException(ex);
- } catch (SecurityException ex) {
- throw new IllegalArgumentException(ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException(ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- }
-
- protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException {
- Object value;
- try {
- Method m = clazz.getMethod(methodName);
- value = m.invoke(parent);
- return value;
- } catch (NoSuchMethodException ex) {
- throw new IllegalArgumentException(ex);
- } catch (SecurityException ex) {
- throw new IllegalArgumentException(ex);
- } catch (IllegalAccessException ex) {
- throw new IllegalArgumentException(ex);
- } catch (InvocationTargetException ex) {
- throw new IllegalArgumentException(ex);
- }
- }
-
- protected void firePropertyChange(String name, Object oldValue, Object newValue) {
- pcs.firePropertyChange(name, oldValue, newValue);
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,214 +0,0 @@
-package jaxx.runtime;
-
-import static jaxx.runtime.JAXXContextEntryDef.newDef;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import java.awt.Container;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-
-/**
- * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation.
- * <p/>
- * The values are store in a {@link Map} but we can not use directly the values as key.
- * <p/>
- * Because, it does not work if we add for the same object multi entries (named and unamed)...
- * <p/>
- * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value.
- *
- * @author chemit
- */
-public class DefaultJAXXContext implements JAXXContext {
-
- protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = newDef(JAXXContext.class);
- /** to use log facility, just put in your code: log.info(\"...\"); */
- static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
- /** l'ui auquel est rattache le context */
- protected JAXXObject ui;
- /** le context parent */
- protected JAXXContext parentContext;
- /** les données contenues dans le context */
- protected final Map<JAXXContextEntryDef<?>, Object> data;
-
- public DefaultJAXXContext() {
- data = new HashMap<JAXXContextEntryDef<?>, Object>();
- }
-
- public DefaultJAXXContext(JAXXObject ui) {
- this();
- this.ui = ui;
- }
-
- @Override
- public <T> void setContextValue(T o) {
- setContextValue(o, null);
- }
-
- @Override
- public <T> void setContextValue(T o, String name) {
- if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) {
- setParentContext((JAXXContext) o);
- return;
- }
- JAXXContextEntryDef<?> entry = getKey(name, o.getClass());
- // first remove entry
- Object oldValue = remove0(o.getClass(), name);
- if (oldValue != null) {
- if (log.isDebugEnabled()) {
- log.debug("remove value " + oldValue.getClass() + " for " + entry);
- }
- }
- // then can put safely
- data.put(entry, o);
- }
-
- @Override
- public <T> T getContextValue(Class<T> clazz) {
- return getContextValue(clazz, null);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override
- public <T> T getContextValue(Class<T> clazz, String name) {
- if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) {
- return (T) getParentContext();
- }
- for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
- if (entry.getKey().accept(clazz, name)) {
- return (T) entry.getValue();
- }
- }
-
- // no value found in this context, will try in the parent context
- if (JAXXContext.class == clazz) {
- // no seek in the parent context, since we are already looking for it
- return null;
- }
-
- JAXXContext parent = getParentContext();
- if (parent == null) {
- // no parent context, so no value find
- return null;
- }
- // seek in parent context
- return parent.getContextValue(clazz, name);
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz) {
- removeContextValue(klazz, null);
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- remove0(klazz, name);
- }
-
- @Override
- public <O extends Container> O getParentContainer(Class<O> clazz) {
- return this.getParentContainer(ui, clazz);
- }
-
- @SuppressWarnings({"unchecked"})
- @Override
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
- if (ui == null) {
- throw new IllegalStateException("no ui attached to this context");
- }
- if (top == null) {
- throw new IllegalArgumentException("top parameter can not be null");
- }
- if (!Container.class.isAssignableFrom(top.getClass())) {
- throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class);
- }
- Container parent = ((Container) top).getParent();
- if (parent != null && !clazz.isAssignableFrom(parent.getClass())) {
- parent = getParentContainer(parent, clazz);
- }
- return (O) parent;
- }
-
- /**
- * Obtain all the keys of data for a given type.
- *
- * @param klass the type of searched keys
- * @return the array of all names of keys for the given type of data
- * @since 1.3
- */
- public String[] getKeys(Class<?> klass) {
- List<String> keys = new java.util.ArrayList<String>();
- for (JAXXContextEntryDef<?> key : data.keySet()) {
- if (key.getKlass() == klass) {
- keys.add(key.getName());
- }
- }
- return keys.toArray(new String[keys.size()]);
-
- }
-
- public void clear() {
- data.clear();
- }
-
- protected JAXXObject getUi() {
- return ui;
- }
-
- protected void setUi(JAXXObject ui) {
- this.ui = ui;
- }
-
- protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) {
- return JAXXContextEntryDef.newDef(name, klass);
- }
-
- @SuppressWarnings({"unchecked"})
- protected <T> T remove0(Class<T> klazz, String name) {
- if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) {
- JAXXContext old = getParentContext();
- setParentContext(null);
- return (T) old;
- }
- JAXXContextEntryDef<?> entry = null;
- for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
- if (entryDef.accept(klazz, name)) {
- entry = entryDef;
- break;
- }
- }
- if (entry != null) {
- return (T) data.remove(entry);
- }
-
- if (JAXXContext.class == klazz) {
- return null;
- }
- // try in parentContext
- JAXXContext parent = getParentContext();
-
- if (parent == null) {
- return null;
- }
-
- if (parent instanceof DefaultJAXXContext) {
- return ((DefaultJAXXContext) parent).remove0(klazz, name);
- }
-
- return null;
- }
-
- protected JAXXContext getParentContext() {
- return parentContext;
- }
-
- protected void setParentContext(JAXXContext parentContext) {
- if (parentContext instanceof JAXXObject) {
- // keep the real context, not the ui
- parentContext = ((JAXXObject) parentContext).getDelegateContext();
- }
- this.parentContext = parentContext;
- }
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXAction.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,5 +1,8 @@
package jaxx.runtime;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.context.JAXXContext;
+
/**
* This is the contract to be realized by any class to be used as Action class for an ui.
*
@@ -12,7 +15,7 @@
*
* @param parentContent the context of the parent of the ui (can be null if no parent is required)
* @param datas other datas to inject in initial context
- * @return the {@link jaxx.runtime.JAXXInitialContext} to be injected in the ui via the constructor of the {@link jaxx.runtime.JAXXObject}
+ * @return the {@link jaxx.runtime.context.JAXXInitialContext} to be injected in the ui via the constructor of the {@link jaxx.runtime.JAXXObject}
*/
JAXXInitialContext init(JAXXContext parentContent, Object... datas);
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,107 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Container;
-
-/**
- * The {@link jaxx.runtime.JAXXContext} contract defines a generic context.
- * <p/>
- * A context contains two king of entries :
- * <p/>
- * <h2>Unamed entry</h2>
- * a such entry maps filter only on the clas of the object of the entry.
- * <p/>
- * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a
- * such entry.
- * <p/>
- * <h2>named entry</h2>
- * a such entry filter on class of the object and on the name of the entry.
- * <p/>
- * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)}
- * to reteave a such entry.
- *
- * @author letellier
- * @author chemit
- */
-public interface JAXXContext {
-
- /**
- * Push in the context a new unamed entry.
- * <p/>
- * If a previous entry exists in context (unamed and same class), it will be removed.
- *
- * @param <T> type of data to set in context
- * @param o the value to push in context
- */
- public <T> void setContextValue(T o);
-
- /**
- * * Push in the context a new amed entry.
- * <p/>
- * If a previous entry exists in context (same name and class), it will be removed.
- *
- * @param <T> type of data to set in context
- * @param o the value to push in context
- * @param name the name of the new entry
- */
- public <T> void setContextValue(T o, String name);
-
- /**
- * Remove from context the value with the given klazz as an unamed entry
- *
- * @param <T> type of data to remove from context
- * @param klazz the klazz entry
- */
- public <T> void removeContextValue(Class<T> klazz);
-
- /**
- * Remove from context the value with the given klazz as an unamed (if name is null) or named entry
- *
- * @param <T> type of data to remove from context
- * @param klazz the klazz entry
- * @param name extra name of the entry
- */
-
- public <T> void removeContextValue(Class<T> klazz, String name);
-
- /**
- * Seek for a unamed entry in the context
- * <p/>
- * This is an exemple to call a method in JAXX :
- * <p/>
- * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
- *
- * @param <T> type of data to obtain from context
- * @param clazz the class of unamed entry to seek in context
- * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
- */
- public <T> T getContextValue(Class<T> clazz);
-
- /**
- * Seek for a named entry in the context
- *
- * @param <T> type of data to obtain from context
- * @param clazz the class of named entry to seek in context
- * @param name the name of the entry to seek in context
- * @return the value of the named entry for the given class, or <code>null</code> if no such entry.
- */
- public <T> T getContextValue(Class<T> clazz, String name);
-
- /**
- * Return parent's container corresponding to the Class clazz
- *
- * @param <O> type of container to obtain from context
- * @param clazz clazz desired
- * @return parent's container
- */
- public <O extends Container> O getParentContainer(Class<O> clazz);
-
- /**
- * Return parent's container corresponding to the Class clazz
- *
- * @param <O> type of container to obtain from context
- * @param top the top container
- * @param clazz desired
- * @return parent's container
- */
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,119 +0,0 @@
-package jaxx.runtime;
-
-import java.util.Collections;
-import java.util.List;
-
-/**
- * To qualify an entry in a {@link JAXXContext}.
- * <p/>
- * Use the factory methods <code>newDef</code> and <code>newListDef</code< to obtain new instances.
- *
- * @param <O> type of the entry associated to the definition
- * @author chemit
- */
-public class JAXXContextEntryDef<O> implements java.io.Serializable {
-
- /** name of the entry, can be nuill for a unamed entry. */
- protected String name;
-
- /** class of the entry, can not be null */
- protected Class<O> klass;
-
- private static final long serialVersionUID = 1L;
-
- public static <O> JAXXContextEntryDef<O> newDef(Class<O> klass) {
- return newDef(null, klass);
- }
-
- public static <O> JAXXContextEntryDef<O> newDef(String name, Class<O> klass) {
- return new JAXXContextEntryDef<O>(name, klass);
- }
-
- public static <O> JAXXContextEntryDef<List<O>> newListDef() {
- return newListDef(null);
- }
-
- @SuppressWarnings({"unchecked"})
- public static <O> JAXXContextEntryDef<List<O>> newListDef(String name) {
- JAXXContextEntryDef contextEntryDef = new JAXXContextEntryDef<List<O>>(name, JAXXContextEntryDef.<O>castList());
- contextEntryDef.klass = List.class;
- return contextEntryDef;
- }
-
-
- public String getName() {
- return name;
- }
-
- public Class<O> getKlass() {
- return klass;
- }
-
- public O getContextValue(JAXXContext context) {
- return context.getContextValue(klass, name);
- }
-
- public void removeContextValue(JAXXContext context) {
- context.removeContextValue(klass, name);
- }
-
- public void setContextValue(JAXXContext context, O value) {
- context.setContextValue(value, name);
- }
-
- @Override
- public String toString() {
- return super.toString() + "<" + klass + ":" + name + ">";
- }
-
- protected JAXXContextEntryDef(Class<O> klass) {
- this(null, klass);
- }
-
- protected JAXXContextEntryDef(String name, Class<O> klass) {
- if (klass == null) {
- throw new IllegalArgumentException("class can not be null");
- }
- this.name = name;
- this.klass = klass;
- }
-
- @SuppressWarnings({"unchecked"})
- protected static <O> Class<List<O>> castList() {
- return (Class<List<O>>) Collections.emptyList().getClass();
- }
-
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (!(o instanceof JAXXContextEntryDef)) {
- return false;
- }
- JAXXContextEntryDef that = (JAXXContextEntryDef) o;
- return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null);
-
- }
-
- @Override
- public int hashCode() {
- int result = (name != null ? name.hashCode() : 0);
- return 31 * result + klass.hashCode();
- }
-
- public boolean accept(Class<?> klass, String name) {
- if (klass == Object.class && this.klass != Object.class) {
- // try on name only
- return (this.name != null && name != null && this.name.equals(name));
- }
- return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
- || (this.name != null && name != null && this.name.equals(name)));
- }
-
- public boolean accept2(Class<?> klass, String name) {
- return !(klass == Object.class && this.klass != Object.class) &&
- this.klass.isAssignableFrom(klass) && (this.name == null &&
- name == null || (this.name != null && name != null && this.name.equals(name)));
- }
-}
Deleted: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,105 +0,0 @@
-package jaxx.runtime;
-
-import java.awt.Container;
-import java.util.Map.Entry;
-
-/**
- * An initial context to be inject in a {@link JAXXObject}.
- * <p/>
- * The method {@link #add(Object)} register a simple value.
- * <p/>
- * The method {@link #add(String, Object)} register a named value.
- * <p/>
- * The method {@link #to(JAXXContext)} inject in the {@link JAXXObject} the values registred in the initial context.
- * <p/>
- * The initial context is also a "limited" {@link JAXXContext}, since we can only use the two methods
- * <p/>
- * {@link #getContextValue(Class)} or {@link #getContextValue(Class, String)}.
- *
- * @see JAXXContext
- */
-public class JAXXInitialContext extends DefaultJAXXContext {
-
- public JAXXInitialContext() {
- super();
- }
-
- /**
- * Register a simple (none named) value in the context.
- *
- * @param value the value to be registred in the context
- * @return the instance of the context
- */
- public JAXXInitialContext add(Object value) {
- return add((String) null, value);
- }
-
- /**
- * Register a named value in the context.
- *
- * @param name the name of the value
- * @param value the value to registred
- * @return the instance of the context
- */
- public JAXXInitialContext add(String name, Object value) {
- super.setContextValue(value, name);
- return this;
- }
-
- /**
- * Register a named value in the context.
- *
- * @param <O> type of data to add
- * @param def definition of entry
- * @param value the value to registred
- * @return the instance of the context
- */
- public <O> JAXXInitialContext add(JAXXContextEntryDef<O> def, O value) {
- def.setContextValue(this, value);
- return this;
- }
-
- /**
- * Inject all the registed values into the {@link JAXXObject}
- *
- * @param dst the object to fill.
- */
- public void to(JAXXContext dst) {
- if (parentContext != null) {
- dst.setContextValue(parentContext);
- }
- for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
- dst.setContextValue(entry.getValue(), entry.getKey().getName());
- }
- }
-
- @Override
- public void setContextValue(Object o) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public void setContextValue(Object o, String name) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <T> void removeContextValue(Class<T> klazz, String name) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Class<O> clazz) {
- throw new RuntimeException("not implemented");
- }
-
- @Override
- public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
- throw new RuntimeException("not implemented");
- }
-}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObject.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,30 +4,42 @@
*/
package jaxx.runtime;
-/** The <code>JAXXObject</code> interface is implemented by all classes produced by the JAXX compiler. */
+import java.util.Map;
+import jaxx.runtime.context.JAXXContext;
+
+/**
+ * The <code>JAXXObject</code> interface is implemented by all classes
+ * produced by the JAXX compiler.
+ */
public interface JAXXObject extends JAXXContext {
+
/**
* Retrieves an object defined in an XML tag by its ID.
*
* @param id the id of the component to retrieve
* @return the object
*/
- public Object getObjectById(String id);
+ Object getObjectById(String id);
/**
* Pretrieves the dictonary of knwon objects indexed by their ids.
*
* @return the dictonary of objects.
*/
- public java.util.Map<String, Object> get$objectMap();
+ Map<String, Object> get$objectMap();
- public void applyDataBinding(String id);
+ /**
+ *
+ * @return the {@link JAXXContext} attached to the object
+ */
+ JAXXContext getDelegateContext();
+ /**
+ * Apply the data bind by name and then process it.
+ * @param id the id of the databinding
+ */
+ void applyDataBinding(String id);
- public void removeDataBinding(String id);
-
- public jaxx.runtime.JAXXContext getDelegateContext();
-
/**
* Processes a data binding by name. Data binding names are comprised of an object ID and a property name:
* for example, the data binding in the tag <code><JLabel id='label' text='{foo.getText()}'/></code> is
@@ -36,8 +48,14 @@
*
* @param dest the name of the data binding to run
*/
- public void processDataBinding(String dest);
+ void processDataBinding(String dest);
+ /**
+ * Remove a databinding by name.
+ *
+ * @param id the name of databinding to remove
+ */
+ void removeDataBinding(String id);
/**
* All <code>JAXXObject</code> implements are capable of broadcasting <code>PropertyChangeEvent</code>, and
@@ -48,5 +66,5 @@
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
- public void firePropertyChange(String name, Object oldValue, Object newValue);
-}
\ No newline at end of file
+ void firePropertyChange(String name, Object oldValue, Object newValue);
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXObjectDescriptor.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,7 +4,7 @@
*/
package jaxx.runtime;
-import jaxx.css.Stylesheet;
+import jaxx.runtime.css.Stylesheet;
import java.io.Serializable;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/SwingUtil.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,5 @@
package jaxx.runtime;
-import jaxx.runtime.*;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
@@ -169,6 +168,8 @@
}
/**
+ * TODO move this to JAXXComboBox.
+ *
* Fill a combo box model with some datas, and select after all the given object
*
* @param combo the combo to fill
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/Util.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,7 @@
package jaxx.runtime;
-import jaxx.Base64Coder;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
@@ -84,6 +85,21 @@
}
}
+ /**
+ * Method to initialize the context of a ui.
+ *
+ * @param ui the ui
+ * @param parentContext the context to set in ui
+ */
+ public static void initContext(JAXXObject ui, JAXXContext parentContext) {
+
+ if (parentContext instanceof jaxx.runtime.context.JAXXInitialContext) {
+ ((jaxx.runtime.context.JAXXInitialContext) parentContext).to(ui);
+ } else {
+ ui.setContextValue(parentContext);
+ }
+ }
+
public static Object getEventListener(Class<? extends EventListener> listenerClass, final String listenerMethodName, final Object methodContainer, final String methodName) {
WeakReference<List<EventListenerDescriptor>> ref = eventListeners.get(methodContainer);
List<EventListenerDescriptor> descriptors = ref != null ? ref.get() : null;
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DataContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,401 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import java.awt.Container;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.util.Iterator;
+import java.util.NoSuchElementException;
+import java.util.regex.Pattern;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Un contexte de données qui permet l'utilisation des bindings sur les
+ * entrées du contexte.
+ *
+ * TODO javadoc
+ *
+ * @author tony
+ * @since 1.3
+ */
+public abstract class DataContext {
+
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private Log log = LogFactory.getLog(DataContext.class);
+ /** le context qui contient les données */
+ protected final DefaultJAXXContext delegate;
+ /** la definition de l'entree actuallement selectionnee */
+ protected DataContextEntry<?> currentEntry;
+ /** to manage properties modifications */
+ protected final PropertyChangeSupport pcs;
+ protected DataContextEntry<?>[] entries;
+ protected final String[] DEFAULT_JAXX_PCS;
+
+ public abstract String getContextPath(Object... e);
+
+ public DataContext(String[] DEFAULT_JAXX_PCS, DataContextEntry<?>[] entries) {
+ this.DEFAULT_JAXX_PCS = DEFAULT_JAXX_PCS;
+ this.entries = entries;
+ delegate = new DefaultJAXXContext() {
+
+ @Override
+ protected void setUi(JAXXObject ui) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Class<O> clazz) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ protected JAXXObject getUi() {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ protected void setParentContext(JAXXContext parentContext) {
+ throw new IllegalStateException("can not use this method for this type of context");
+ }
+
+ @Override
+ protected JAXXContext getParentContext() {
+ return null;
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ if (log.isTraceEnabled()) {
+ log.trace(klazz + " - " + name);
+ }
+ super.removeContextValue(klazz, name);
+ }
+
+ @Override
+ public <T> void setContextValue(T o, String name) {
+ if (log.isTraceEnabled()) {
+ log.trace(name + " - " + o.getClass());
+ }
+ super.setContextValue(o, name);
+ }
+ };
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ public DefaultJAXXContext getDelegate() {
+ return delegate;
+ }
+
+ public Iterable<? extends DataContextEntry<?>> iterateOnAll() {
+ return new Iterable<DataContextEntry<?>>() {
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ return new DataContextEntryIterator(entries);
+ }
+ };
+ }
+
+ public Iterable<? extends DataContextEntry<?>> iterateToLevel(final int level) {
+ return new Iterable<DataContextEntry<?>>() {
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ return new DataContextEntryIterator(entries, level);
+ }
+ };
+ }
+
+ public Iterable<? extends DataContextEntry<?>> reverseIterateOnAll() {
+
+ return new Iterable<DataContextEntry<?>>() {
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ return new DataContextEntryIterator(entries, true);
+ }
+ };
+ }
+
+ public DataContextEntry<?> getCurrentEntry() {
+ return currentEntry;
+ }
+
+ public DataContextEntry<?> getEntry(String path) {
+ for (DataContextEntry<?> scope : reverseIterateOnAll()) {
+ if (scope.acceptPath(path)) {
+ return scope;
+ }
+ }
+ return null;
+ }
+
+ public DataContextEntry<?> getEntry(Class<?> type) {
+ for (DataContextEntry<?> scope : iterateOnAll()) {
+ if (scope.acceptType(type)) {
+ return scope;
+ }
+ }
+ return null;
+ }
+
+ public <T> T getContextValue(DataContextEntry<T> entry, String key) {
+ String contextKey = getKey(entry, key);
+ T result = delegate.getContextValue(entry.getKlass(), contextKey);
+ return result;
+ }
+
+ public void setContextValue(DataContextEntry<?> entry, Object value, String key) {
+ String contextKey = getKey(entry, key);
+ delegate.setContextValue(value, contextKey);
+ }
+
+ public void removeContextValue(DataContextEntry<?> entry, Object value, String key) {
+ String contextKey = getKey(entry, key);
+ delegate.removeContextValue(value.getClass(), contextKey);
+ }
+
+ @SuppressWarnings("unchecked")
+ public void updateSelectedData(String path, Object data, UpdateDataContext updator) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("----------------------------------------------------------------");
+ }
+ if (currentEntry != null) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("remove from old entry " + currentEntry);
+ }
+ for (DataContextEntry<?> s : currentEntry) {
+ if (log.isDebugEnabled()) {
+ log.debug("remove entry " + s);
+ }
+ updator.onRemovingData(this, s);
+ }
+ }
+
+ currentEntry = getEntry(path);
+
+ if (log.isDebugEnabled()) {
+ log.debug("new entry " + currentEntry + " for path " + path);
+ }
+
+ if (currentEntry != null) {
+
+ for (DataContextEntry<?> s : iterateToLevel(currentEntry.getLevel())) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("add entry " + s);
+ }
+ updator.onAddingData(this, s, path);
+ }
+ }
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ public void removeJaxxPropertyChangeListener() {
+ PropertyChangeListener[] toRemove = Util.findJaxxPropertyChangeListener(DEFAULT_JAXX_PCS, getPropertyChangeListeners());
+ if (toRemove == null || toRemove.length == 0) {
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("before remove : " + getPropertyChangeListeners().length);
+ log.debug("toRemove : " + toRemove.length);
+ }
+ for (PropertyChangeListener listener : toRemove) {
+ removePropertyChangeListener(listener);
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("after remove : " + getPropertyChangeListeners().length);
+ }
+ }
+
+ protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
+
+ protected String getKey(DataContextEntry<?> entry, String key) {
+ String result = null;
+ if (key != null) {
+ result = entry.hashCode() + "#" + key;
+ }
+ return result;
+ }
+
+ public void close() throws Exception {
+ clear();
+
+ // suppression des ecouteurs
+
+ for (PropertyChangeListener l : getPropertyChangeListeners()) {
+ removePropertyChangeListener(l);
+ }
+ }
+
+ public void clear() {
+ delegate.clear();
+ }
+
+ public static abstract class DataContextEntry<E> implements Iterable<DataContextEntry<?>> {
+
+ private final int level;
+ private final DataContextEntry<?> previous;
+ private final DataContextEntry<?>[] parents;
+ private Class<E> klass;
+
+ public DataContextEntry(Class<E> klass, DataContextEntry<?> previous) {
+ this.previous = previous;
+ this.level = previous.level + 1;
+ this.klass = klass;
+ this.parents = new DataContextEntry<?>[level];
+ int i = level;
+ while (i > 0) {
+ parents[--i] = previous;
+ previous = previous.previous;
+ }
+ }
+
+ public DataContextEntry(Class<E> klass) {
+ this.level = 0;
+ this.klass = klass;
+ this.previous = null;
+ this.parents = new DataContextEntry<?>[0];
+ }
+
+ public Class<E> getKlass() {
+ return klass;
+ }
+
+ public int getLevel() {
+ return level;
+ }
+
+ public DataContextEntry<?>[] getParents() {
+ return parents;
+ }
+
+ public abstract Pattern getPattern();
+
+ public abstract String getContextPath(Object... args);
+
+ public boolean acceptPath(String path) {
+ return getPattern().matcher(path).matches();
+ }
+
+ public boolean acceptType(Class<?> type) {
+ return klass.isAssignableFrom(type);
+ }
+
+ @Override
+ public Iterator<DataContextEntry<?>> iterator() {
+ int length = parents.length;
+ DataContextEntry<?>[] t = new DataContextEntry<?>[length + 1];
+ System.arraycopy(parents, 0, t, 0, length);
+ t[length] = this;
+ return new DataContextEntryIterator(t, true);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<type: " + klass.getSimpleName() + ">";
+ }
+ }
+
+ public static interface UpdateDataContext<D extends DataContext> {
+
+ void onRemovingData(D context, DataContextEntry<D> entry);
+
+ void onAddingData(D context, DataContextEntry<D> entry, String path);
+ }
+
+ public static class DataContextEntryIterator implements Iterator<DataContextEntry<?>> {
+
+ protected final DataContextEntry<?>[] datas;
+ protected final boolean reverse;
+ protected final int level;
+ protected int index;
+
+ public DataContextEntryIterator(DataContextEntry<?>[] datas) {
+ this(datas, false, -1);
+ }
+
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, int level) {
+ this(datas, false, level);
+ }
+
+ public DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse) {
+ this(datas, reverse, -1);
+ }
+
+ DataContextEntryIterator(DataContextEntry<?>[] datas, boolean reverse, int level) {
+ this.datas = datas;
+ this.reverse = reverse;
+ if (reverse) {
+ index = datas.length;
+ } else {
+ index = -1;
+ }
+ this.level = level;
+ }
+
+ @Override
+ public boolean hasNext() {
+ if (reverse) {
+ return index > 0;
+ } else {
+ return index + 1 < datas.length && (level == -1 || datas[index + 1].getLevel() <= level);
+ }
+ }
+
+ @Override
+ public DataContextEntry<?> next() {
+ if (!hasNext()) {
+ throw new NoSuchElementException();
+ }
+ if (reverse) {
+ index--;
+ } else {
+ index++;
+ }
+ return datas[index];
+ }
+
+ @Override
+ public void remove() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DataContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultApplicationContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,282 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.lang.annotation.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Map.Entry;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The default context to be used for an application.
+ *
+ * This extends the {@link DefaultJAXXContext} and add a possibility to auto-instanciate
+ * some classes asked via {@link #getContextValue(java.lang.Class)} and
+ * {@link #getContextValue(java.lang.Class, java.lang.String)} methods.
+ *
+ * To registred a such class, just annotate your class with {@link AutoLoad}.
+ *
+ * @author chemit
+ * @since 1.2
+ * @see DefaultJAXXContext
+ */
+public class DefaultApplicationContext extends DefaultJAXXContext {
+
+ /**
+ * A class annotated @AutoLoad is used by context to auto
+ * instanciate the class when required.
+ *
+ * Note : A such class always have a public default constructor.
+ *
+ * @author chemit
+ * @version 1.0, 21/02/09
+ * @since 1.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface AutoLoad {
+ //TODO use this to add a method to init
+
+ String initMethod() default "";
+ }
+
+ /**
+ * A class annotated @MethodAccess is used by context to obtain the value
+ * of an entry via a declared method.
+ *
+ * Note : A such class must have a method called {@link #methodName()} with
+ * a single String parameter.
+ *
+ * @author chemit
+ * @version 1.0, 21/02/09
+ * @since 1.2
+ */
+ @Retention(RetentionPolicy.RUNTIME)
+ @Target(ElementType.TYPE)
+ public static @interface MethodAccess {
+
+ /**
+ * Define a forward to a target class. When the target class
+ * will be asked with method {@link #getContextValue(java.lang.Class, java.lang.String)}
+ * it will be delegating to this class.
+ *
+ * @return the forwarded class
+ */
+ Class<?> target() default Object.class;
+
+ /**
+ * @return the name of the method to access data
+ */
+ String methodName();
+ }
+ /**
+ * Map of forwarded classes (key) to classes (values).
+ */
+ protected Map<Class<?>, Class<?>> forwards;
+
+ public DefaultApplicationContext() {
+ super();
+ forwards = new HashMap<Class<?>, Class<?>>();
+ pcs = new PropertyChangeSupport(this);
+ }
+
+ public DefaultApplicationContext(JAXXObject ui) {
+ super(ui);
+ }
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(DefaultApplicationContext.class);
+
+ /** to manage properties modifications */
+ protected PropertyChangeSupport pcs;
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ Object value = null;
+ MethodAccess access;
+
+ Class<?> realClass;
+
+ if (forwards.containsKey(clazz)) {
+ // this is a forward class
+ realClass = forwards.get(clazz);
+ // always call the forwarder with no name
+ value = getContextValue(realClass, null);
+ if (log.isDebugEnabled()) {
+ log.debug("detect forward from " + clazz + " to " + realClass + " (" + value + ")");
+ }
+
+ } else {
+ realClass = clazz;
+ value = super.getContextValue(realClass, name);
+ }
+
+ if (value == null) {
+ AutoLoad anno = clazz.getAnnotation(AutoLoad.class);
+
+ if (anno == null) {
+ // no annotation, so do nothing
+ return null;
+ }
+
+ if (name != null) {
+ throw new IllegalArgumentException("an " + AutoLoad.class.getName() + " can not have a named context but was call with this one : " + name);
+ }
+ value = newInstance(clazz);
+ if (!anno.initMethod().trim().isEmpty()){
+ // apply method on class
+ newAccess(clazz, value, anno.initMethod().trim());
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("new instance " + clazz + " : " + value);
+ }
+ // save new instance
+ setContextValue(value, null);
+ }
+
+ access = realClass.getAnnotation(MethodAccess.class);
+
+ if (access != null) {
+ if (name == null) {
+ if (access.target() != Object.class) {
+ // register forward
+ Class<?> targetClass = access.target();
+ if (!forwards.containsKey(targetClass)) {
+ // register forward
+ forwards.put(targetClass, clazz);
+ if (log.isDebugEnabled()) {
+ log.debug("register forward from " + targetClass + " to " + clazz);
+ }
+ }
+ }
+ } else {
+ // specialized access
+ value = newAccess(realClass, value, access.methodName(), name);
+ }
+ }
+ return (T) value;
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ Entry<Class<?>, Class<?>> entry;
+ if (name == null && forwards.containsValue(klazz)) {
+ // remove forward
+ Iterator<Entry<Class<?>, Class<?>>> itr = forwards.entrySet().iterator();
+ while (itr.hasNext()) {
+ entry = itr.next();
+ if (entry.getValue().equals(klazz)) {
+ itr.remove();
+ if (log.isDebugEnabled()) {
+ log.debug("removed forward from " + entry.getKey() + " to " + klazz);
+ }
+ break;
+ }
+ }
+ }
+ //FIXME should update forwards state
+ super.removeContextValue(klazz, name);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(listener);
+ }
+
+ public void addPropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.addPropertyChangeListener(propertyName, listener);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(listener);
+ }
+
+ public void removePropertyChangeListener(String propertyName, PropertyChangeListener listener) {
+ pcs.removePropertyChangeListener(propertyName, listener);
+ }
+
+ public synchronized boolean hasListeners(String propertyName) {
+ return pcs.hasListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
+ return pcs.getPropertyChangeListeners(propertyName);
+ }
+
+ public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
+ return pcs.getPropertyChangeListeners();
+ }
+
+ protected Object newInstance(Class<?> clazz) throws IllegalArgumentException {
+
+ Object value = null;
+
+ Constructor<?> constructor = null;
+ try {
+ constructor = clazz.getConstructor();
+ // auto instanciate the class
+ if (constructor == null) {
+ throw new IllegalArgumentException(clazz + " has no public constructor");
+ }
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ try {
+ value = constructor.newInstance();
+
+ } catch (InstantiationException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ return value;
+ }
+
+ protected Object newAccess(Class<?> clazz, Object parent, String methodName, String name) throws IllegalArgumentException {
+ Object value;
+ try {
+ Method m = clazz.getMethod(methodName, String.class);
+ value = m.invoke(parent, name);
+ return value;
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+
+ protected Object newAccess(Class<?> clazz, Object parent, String methodName) throws IllegalArgumentException {
+ Object value;
+ try {
+ Method m = clazz.getMethod(methodName);
+ value = m.invoke(parent);
+ return value;
+ } catch (NoSuchMethodException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (SecurityException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalArgumentException(ex);
+ } catch (InvocationTargetException ex) {
+ throw new IllegalArgumentException(ex);
+ }
+ }
+
+ protected void firePropertyChange(String name, Object oldValue, Object newValue) {
+ pcs.firePropertyChange(name, oldValue, newValue);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultApplicationContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/DefaultJAXXContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,215 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import static jaxx.runtime.context.JAXXContextEntryDef.newDef;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import java.awt.Container;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+/**
+ * The default {@link JAXXContext} to be used in a {@link JAXXObject} by delegation.
+ * <p/>
+ * The values are store in a {@link Map} but we can not use directly the values as key.
+ * <p/>
+ * Because, it does not work if we add for the same object multi entries (named and unamed)...
+ * <p/>
+ * We prefer use as entry the {@link JAXXContextEntryDef} associated with the value.
+ *
+ * @author chemit
+ */
+public class DefaultJAXXContext implements JAXXContext {
+
+ protected static final JAXXContextEntryDef<JAXXContext> PARENT_CONTEXT_ENTRY = newDef(JAXXContext.class);
+ /** to use log facility, just put in your code: log.info(\"...\"); */
+ static private final Log log = LogFactory.getLog(DefaultJAXXContext.class);
+ /** l'ui auquel est rattache le context */
+ protected JAXXObject ui;
+ /** le context parent */
+ protected JAXXContext parentContext;
+ /** les données contenues dans le context */
+ protected final Map<JAXXContextEntryDef<?>, Object> data;
+
+ public DefaultJAXXContext() {
+ data = new HashMap<JAXXContextEntryDef<?>, Object>();
+ }
+
+ public DefaultJAXXContext(JAXXObject ui) {
+ this();
+ this.ui = ui;
+ }
+
+ @Override
+ public <T> void setContextValue(T o) {
+ setContextValue(o, null);
+ }
+
+ @Override
+ public <T> void setContextValue(T o, String name) {
+ if (name == null && PARENT_CONTEXT_ENTRY.accept2(o.getClass(), null)) {
+ setParentContext((JAXXContext) o);
+ return;
+ }
+ JAXXContextEntryDef<?> entry = getKey(name, o.getClass());
+ // first remove entry
+ Object oldValue = remove0(o.getClass(), name);
+ if (oldValue != null) {
+ if (log.isDebugEnabled()) {
+ log.debug("remove value " + oldValue.getClass() + " for " + entry);
+ }
+ }
+ // then can put safely
+ data.put(entry, o);
+ }
+
+ @Override
+ public <T> T getContextValue(Class<T> clazz) {
+ return getContextValue(clazz, null);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <T> T getContextValue(Class<T> clazz, String name) {
+ if (parentContext != null && parentContext.getClass() == clazz || PARENT_CONTEXT_ENTRY.accept(clazz, name)) {
+ return (T) getParentContext();
+ }
+ for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
+ if (entry.getKey().accept(clazz, name)) {
+ return (T) entry.getValue();
+ }
+ }
+
+ // no value found in this context, will try in the parent context
+ if (JAXXContext.class == clazz) {
+ // no seek in the parent context, since we are already looking for it
+ return null;
+ }
+
+ JAXXContext parent = getParentContext();
+ if (parent == null) {
+ // no parent context, so no value find
+ return null;
+ }
+ // seek in parent context
+ return parent.getContextValue(clazz, name);
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz) {
+ removeContextValue(klazz, null);
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ remove0(klazz, name);
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Class<O> clazz) {
+ return this.getParentContainer(ui, clazz);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Override
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
+ if (ui == null) {
+ throw new IllegalStateException("no ui attached to this context");
+ }
+ if (top == null) {
+ throw new IllegalArgumentException("top parameter can not be null");
+ }
+ if (!Container.class.isAssignableFrom(top.getClass())) {
+ throw new IllegalArgumentException("top parameter " + top + " is not a " + Container.class);
+ }
+ Container parent = ((Container) top).getParent();
+ if (parent != null && !clazz.isAssignableFrom(parent.getClass())) {
+ parent = getParentContainer(parent, clazz);
+ }
+ return (O) parent;
+ }
+
+ /**
+ * Obtain all the keys of data for a given type.
+ *
+ * @param klass the type of searched keys
+ * @return the array of all names of keys for the given type of data
+ * @since 1.3
+ */
+ public String[] getKeys(Class<?> klass) {
+ List<String> keys = new java.util.ArrayList<String>();
+ for (JAXXContextEntryDef<?> key : data.keySet()) {
+ if (key.getKlass() == klass) {
+ keys.add(key.getName());
+ }
+ }
+ return keys.toArray(new String[keys.size()]);
+
+ }
+
+ public void clear() {
+ data.clear();
+ }
+
+ protected JAXXObject getUi() {
+ return ui;
+ }
+
+ protected void setUi(JAXXObject ui) {
+ this.ui = ui;
+ }
+
+ protected JAXXContextEntryDef<?> getKey(String name, Class<?> klass) {
+ return JAXXContextEntryDef.newDef(name, klass);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected <T> T remove0(Class<T> klazz, String name) {
+ if (PARENT_CONTEXT_ENTRY.accept(klazz, name)) {
+ JAXXContext old = getParentContext();
+ setParentContext(null);
+ return (T) old;
+ }
+ JAXXContextEntryDef<?> entry = null;
+ for (JAXXContextEntryDef<?> entryDef : data.keySet()) {
+ if (entryDef.accept(klazz, name)) {
+ entry = entryDef;
+ break;
+ }
+ }
+ if (entry != null) {
+ return (T) data.remove(entry);
+ }
+
+ if (JAXXContext.class == klazz) {
+ return null;
+ }
+ // try in parentContext
+ JAXXContext parent = getParentContext();
+
+ if (parent == null) {
+ return null;
+ }
+
+ if (parent instanceof DefaultJAXXContext) {
+ return ((DefaultJAXXContext) parent).remove0(klazz, name);
+ }
+
+ return null;
+ }
+
+ protected JAXXContext getParentContext() {
+ return parentContext;
+ }
+
+ protected void setParentContext(JAXXContext parentContext) {
+ if (parentContext instanceof JAXXObject) {
+ // keep the real context, not the ui
+ parentContext = ((JAXXObject) parentContext).getDelegateContext();
+ }
+ this.parentContext = parentContext;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/DefaultJAXXContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,107 @@
+package jaxx.runtime.context;
+
+import java.awt.Container;
+
+/**
+ * The {@link jaxx.runtime.context.JAXXContext} contract defines a generic context.
+ * <p/>
+ * A context contains two king of entries :
+ * <p/>
+ * <h2>Unamed entry</h2>
+ * a such entry maps filter only on the clas of the object of the entry.
+ * <p/>
+ * To add a <b>unamed</b> entry, use {@link #setContextValue(Object)} and {@link #getContextValue(Class)} to reteave a
+ * such entry.
+ * <p/>
+ * <h2>named entry</h2>
+ * a such entry filter on class of the object and on the name of the entry.
+ * <p/>
+ * To add a <b>named</b> entry, use {@link #setContextValue(Object,String)} and {@link #getContextValue(Class,String)}
+ * to reteave a such entry.
+ *
+ * @author letellier
+ * @author chemit
+ */
+public interface JAXXContext {
+
+ /**
+ * Push in the context a new unamed entry.
+ * <p/>
+ * If a previous entry exists in context (unamed and same class), it will be removed.
+ *
+ * @param <T> type of data to set in context
+ * @param o the value to push in context
+ */
+ public <T> void setContextValue(T o);
+
+ /**
+ * * Push in the context a new amed entry.
+ * <p/>
+ * If a previous entry exists in context (same name and class), it will be removed.
+ *
+ * @param <T> type of data to set in context
+ * @param o the value to push in context
+ * @param name the name of the new entry
+ */
+ public <T> void setContextValue(T o, String name);
+
+ /**
+ * Remove from context the value with the given klazz as an unamed entry
+ *
+ * @param <T> type of data to remove from context
+ * @param klazz the klazz entry
+ */
+ public <T> void removeContextValue(Class<T> klazz);
+
+ /**
+ * Remove from context the value with the given klazz as an unamed (if name is null) or named entry
+ *
+ * @param <T> type of data to remove from context
+ * @param klazz the klazz entry
+ * @param name extra name of the entry
+ */
+
+ public <T> void removeContextValue(Class<T> klazz, String name);
+
+ /**
+ * Seek for a unamed entry in the context
+ * <p/>
+ * This is an exemple to call a method in JAXX :
+ * <p/>
+ * <code><JButton onActionPerformed='{getContextValue(Action.class).method(args[])}'/></code>
+ *
+ * @param <T> type of data to obtain from context
+ * @param clazz the class of unamed entry to seek in context
+ * @return the value of the unamed entry for the given class, or <code>null</code> if no such entry.
+ */
+ public <T> T getContextValue(Class<T> clazz);
+
+ /**
+ * Seek for a named entry in the context
+ *
+ * @param <T> type of data to obtain from context
+ * @param clazz the class of named entry to seek in context
+ * @param name the name of the entry to seek in context
+ * @return the value of the named entry for the given class, or <code>null</code> if no such entry.
+ */
+ public <T> T getContextValue(Class<T> clazz, String name);
+
+ /**
+ * Return parent's container corresponding to the Class clazz
+ *
+ * @param <O> type of container to obtain from context
+ * @param clazz clazz desired
+ * @return parent's container
+ */
+ public <O extends Container> O getParentContainer(Class<O> clazz);
+
+ /**
+ * Return parent's container corresponding to the Class clazz
+ *
+ * @param <O> type of container to obtain from context
+ * @param top the top container
+ * @param clazz desired
+ * @return parent's container
+ */
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXContextEntryDef.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,119 @@
+package jaxx.runtime.context;
+
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * To qualify an entry in a {@link JAXXContext}.
+ * <p/>
+ * Use the factory methods <code>newDef</code> and <code>newListDef</code< to obtain new instances.
+ *
+ * @param <O> type of the entry associated to the definition
+ * @author chemit
+ */
+public class JAXXContextEntryDef<O> implements java.io.Serializable {
+
+ /** name of the entry, can be nuill for a unamed entry. */
+ protected String name;
+
+ /** class of the entry, can not be null */
+ protected Class<O> klass;
+
+ private static final long serialVersionUID = 1L;
+
+ public static <O> JAXXContextEntryDef<O> newDef(Class<O> klass) {
+ return newDef(null, klass);
+ }
+
+ public static <O> JAXXContextEntryDef<O> newDef(String name, Class<O> klass) {
+ return new JAXXContextEntryDef<O>(name, klass);
+ }
+
+ public static <O> JAXXContextEntryDef<List<O>> newListDef() {
+ return newListDef(null);
+ }
+
+ @SuppressWarnings({"unchecked"})
+ public static <O> JAXXContextEntryDef<List<O>> newListDef(String name) {
+ JAXXContextEntryDef contextEntryDef = new JAXXContextEntryDef<List<O>>(name, JAXXContextEntryDef.<O>castList());
+ contextEntryDef.klass = List.class;
+ return contextEntryDef;
+ }
+
+
+ public String getName() {
+ return name;
+ }
+
+ public Class<O> getKlass() {
+ return klass;
+ }
+
+ public O getContextValue(JAXXContext context) {
+ return context.getContextValue(klass, name);
+ }
+
+ public void removeContextValue(JAXXContext context) {
+ context.removeContextValue(klass, name);
+ }
+
+ public void setContextValue(JAXXContext context, O value) {
+ context.setContextValue(value, name);
+ }
+
+ @Override
+ public String toString() {
+ return super.toString() + "<" + klass + ":" + name + ">";
+ }
+
+ protected JAXXContextEntryDef(Class<O> klass) {
+ this(null, klass);
+ }
+
+ protected JAXXContextEntryDef(String name, Class<O> klass) {
+ if (klass == null) {
+ throw new IllegalArgumentException("class can not be null");
+ }
+ this.name = name;
+ this.klass = klass;
+ }
+
+ @SuppressWarnings({"unchecked"})
+ protected static <O> Class<List<O>> castList() {
+ return (Class<List<O>>) Collections.emptyList().getClass();
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof JAXXContextEntryDef)) {
+ return false;
+ }
+ JAXXContextEntryDef that = (JAXXContextEntryDef) o;
+ return klass.equals(that.klass) && !(name != null ? !name.equals(that.name) : that.name != null);
+
+ }
+
+ @Override
+ public int hashCode() {
+ int result = (name != null ? name.hashCode() : 0);
+ return 31 * result + klass.hashCode();
+ }
+
+ public boolean accept(Class<?> klass, String name) {
+ if (klass == Object.class && this.klass != Object.class) {
+ // try on name only
+ return (this.name != null && name != null && this.name.equals(name));
+ }
+ return klass.isAssignableFrom(this.klass) && (this.name == null && name == null
+ || (this.name != null && name != null && this.name.equals(name)));
+ }
+
+ public boolean accept2(Class<?> klass, String name) {
+ return !(klass == Object.class && this.klass != Object.class) &&
+ this.klass.isAssignableFrom(klass) && (this.name == null &&
+ name == null || (this.name != null && name != null && this.name.equals(name)));
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXContextEntryDef.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/JAXXInitialContext.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,105 @@
+package jaxx.runtime.context;
+
+import java.awt.Container;
+import java.util.Map.Entry;
+
+/**
+ * An initial context to be inject in a {@link JAXXObject}.
+ * <p/>
+ * The method {@link #add(Object)} register a simple value.
+ * <p/>
+ * The method {@link #add(String, Object)} register a named value.
+ * <p/>
+ * The method {@link #to(JAXXContext)} inject in the {@link JAXXObject} the values registred in the initial context.
+ * <p/>
+ * The initial context is also a "limited" {@link JAXXContext}, since we can only use the two methods
+ * <p/>
+ * {@link #getContextValue(Class)} or {@link #getContextValue(Class, String)}.
+ *
+ * @see JAXXContext
+ */
+public class JAXXInitialContext extends DefaultJAXXContext {
+
+ public JAXXInitialContext() {
+ super();
+ }
+
+ /**
+ * Register a simple (none named) value in the context.
+ *
+ * @param value the value to be registred in the context
+ * @return the instance of the context
+ */
+ public JAXXInitialContext add(Object value) {
+ return add((String) null, value);
+ }
+
+ /**
+ * Register a named value in the context.
+ *
+ * @param name the name of the value
+ * @param value the value to registred
+ * @return the instance of the context
+ */
+ public JAXXInitialContext add(String name, Object value) {
+ super.setContextValue(value, name);
+ return this;
+ }
+
+ /**
+ * Register a named (or not) value in the context.
+ *
+ * @param <O> type of data to add
+ * @param def definition of entry
+ * @param value the value to registred
+ * @return the instance of the context
+ */
+ public <O> JAXXInitialContext add(JAXXContextEntryDef<O> def, O value) {
+ def.setContextValue(this, value);
+ return this;
+ }
+
+ /**
+ * Inject all the registed values into the {@link JAXXObject}
+ *
+ * @param dst the object to fill.
+ */
+ public void to(JAXXContext dst) {
+ if (parentContext != null) {
+ dst.setContextValue(parentContext);
+ }
+ for (Entry<JAXXContextEntryDef<?>, Object> entry : data.entrySet()) {
+ dst.setContextValue(entry.getValue(), entry.getKey().getName());
+ }
+ }
+
+ @Override
+ public void setContextValue(Object o) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public void setContextValue(Object o, String name) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <T> void removeContextValue(Class<T> klazz, String name) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Class<O> clazz) {
+ throw new RuntimeException("not implemented");
+ }
+
+ @Override
+ public <O extends Container> O getParentContainer(Object top, Class<O> clazz) {
+ throw new RuntimeException("not implemented");
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/context/JAXXInitialContext.java
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/DataBinding.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -9,6 +9,7 @@
* track of which data bindings are in effect.
*/
public class DataBinding {
+
private String id;
public DataBinding(String id) {
@@ -28,4 +29,4 @@
public int hashCode() {
return id.hashCode();
}
-}
\ No newline at end of file
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Pseudoclasses.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -10,12 +10,12 @@
import java.util.WeakHashMap;
public class Pseudoclasses {
+
public static final String NO_PSEUDOCLASS = "no pseudoclass";
-
private static Map<Object, Map<String, List<PropertyValue>>> properties = new WeakHashMap<Object, Map<String, List<PropertyValue>>>();
+ private static class PropertyValue implements Comparable<PropertyValue> {
- private static class PropertyValue implements Comparable<PropertyValue> {
private Object value;
private int id;
@@ -32,6 +32,7 @@
return id;
}
+ @Override
public int compareTo(PropertyValue o) {
return getId() - o.getId();
}
@@ -41,14 +42,14 @@
if (!(o instanceof PropertyValue)) {
return false;
}
- PropertyValue value = (PropertyValue) o;
- if (value.getId() != getId()) {
+ PropertyValue that = (PropertyValue) o;
+ if (that.getId() != getId()) {
return false;
}
- if (value.getValue() == null) {
+ if (that.getValue() == null) {
return getValue() == null;
}
- return value.getValue().equals(getValue());
+ return that.getValue().equals(getValue());
}
@Override
@@ -118,8 +119,9 @@
parent.applyDataBinding(((DataBinding) value).getId());
}
return value;
- } else
+ } else {
return currentValue;
+ }
}
public static Object removeProperty(JAXXObject parent, Object object, String property, Object oldValue, Object currentValue, int id) {
@@ -134,8 +136,9 @@
propertyRemoved(object, property, wrap(oldValue), id);
value = getCurrentValue(object, property);
return value;
- } else
+ } else {
return currentValue;
+ }
}
public static Object wrap(boolean value) {
@@ -173,4 +176,4 @@
public static Object wrap(Object value) {
return value;
}
-}
\ No newline at end of file
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/Rule.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.css;
+
+import java.util.Map;
+
+public class Rule implements java.io.Serializable, Comparable<Rule> {
+
+ public static final String INLINE_ATTRIBUTE = "<inline attribute>";
+ public static final String DATA_BINDING = "<data binding>";
+ private Selector[] selectors;
+ private Map<String, String> properties;
+ private static final long serialVersionUID = 1L;
+
+ public Rule(Selector[] selectors, Map<String, String> properties) {
+ this.selectors = selectors;
+ java.util.Arrays.sort(selectors);
+ this.properties = properties;
+ }
+
+ public Rule(Selector[] selectors, String[] keys, String[] values) {
+ this.selectors = selectors;
+ java.util.Arrays.sort(selectors);
+ this.properties = new java.util.HashMap<String, String>();
+ if (keys.length != values.length) {
+ throw new IllegalArgumentException("keys and values must have the same number of entries");
+ }
+ for (int i = 0; i < keys.length; i++) {
+ properties.put(keys[i], values[i]);
+ }
+ }
+
+ public Selector[] getSelectors() {
+ return selectors;
+ }
+
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public int compareTo(Rule o) {
+ return selectors[0].compareTo(o.selectors[0]); // they are already sorted so we only need to compare the highest-ranked from each one
+ }
+
+ @Override
+ public String toString() {
+ return "Rule[" + java.util.Arrays.asList(selectors) + ", " + properties + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Rule.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/Selector.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,92 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.css;
+
+public class Selector implements java.io.Serializable, Comparable<Selector> {
+
+ public static final int NEVER_APPLIES = 0;
+ public static final int PSEUDOCLASS_APPLIES_INHERIT_ONLY = 1;
+ public static final int PSEUDOCLASS_APPLIES = 2;
+ public static final int ALWAYS_APPLIES_INHERIT_ONLY = 3;
+ public static final int ALWAYS_APPLIES = 4;
+ private String javaClassName;
+ private String styleClass;
+ private String pseudoClass;
+ private String id;
+ private boolean inline;
+ private static final long serialVersionUID = 1L;
+
+ public Selector(String javaClassName, String styleClass, String pseudoClass, String id) {
+ this(javaClassName, styleClass, pseudoClass, id, false);
+ }
+
+ public Selector(String javaClassName, String styleClass, String pseudoClass, String id, boolean inline) {
+ this.javaClassName = javaClassName;
+ this.styleClass = styleClass;
+ this.pseudoClass = pseudoClass;
+ this.id = id;
+ this.inline = inline;
+ }
+
+ public String getJavaClassName() {
+ return javaClassName;
+ }
+
+ public String getStyleClass() {
+ return styleClass;
+ }
+
+ public String getPseudoClass() {
+ return pseudoClass;
+ }
+
+ public String getId() {
+ return id;
+ }
+
+ public boolean isInline() {
+ return inline;
+ }
+
+ @Override
+ public int compareTo(Selector selector) {
+ if (inline && !selector.inline) {
+ return 1;
+ }
+ if (!inline && selector.inline) {
+ return -1;
+ }
+ if (pseudoClass != null && selector.pseudoClass == null) {
+ return 1;
+ }
+ if (pseudoClass == null && selector.pseudoClass != null) {
+ return -1;
+ }
+ if (id != null && selector.id == null) {
+ return 1;
+ }
+ if (id == null && selector.id != null) {
+ return -1;
+ }
+ if (styleClass != null && selector.styleClass == null) {
+ return 1;
+ }
+ if (styleClass == null && selector.styleClass != null) {
+ return -1;
+ }
+ if (javaClassName != null && selector.javaClassName == null) {
+ return 1;
+ }
+ if (javaClassName == null && selector.javaClassName != null) {
+ return -1;
+ }
+ return 0;
+ }
+
+ @Override
+ public String toString() {
+ return "Selector[" + javaClassName + ", " + styleClass + ", " + pseudoClass + ", " + id + "]";
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Selector.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/css/Stylesheet.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.css;
+
+public class Stylesheet implements java.io.Serializable {
+
+ private Rule[] rules;
+ private static final long serialVersionUID = 1L;
+
+ public Stylesheet() {
+ rules = new Rule[0];
+ }
+
+ public Stylesheet(Rule[] rules) {
+ this.rules = rules;
+ java.util.Arrays.sort(rules);
+ }
+
+ public Rule[] getRules() {
+ return rules;
+ }
+
+ public void add(Rule newRule) {
+ Rule[] oldRules = rules;
+ rules = new Rule[oldRules.length + 1];
+ System.arraycopy(oldRules, 0, rules, 0, oldRules.length);
+ rules[rules.length - 1] = newRule;
+ java.util.Arrays.sort(rules);
+ }
+
+ public void add(Rule[] newRules) {
+ Rule[] oldRules = rules;
+ rules = new Rule[oldRules.length + newRules.length];
+ System.arraycopy(oldRules, 0, rules, 0, oldRules.length);
+ System.arraycopy(newRules, 0, rules, oldRules.length, newRules.length);
+ java.util.Arrays.sort(rules);
+ }
+
+ @Override
+ public String toString() {
+ return "Stylesheet" + java.util.Arrays.asList(rules);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/css/Stylesheet.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/HBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/HBoxBeanInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class HBoxBeanInfo extends SimpleBeanInfo {
+
+ @Override
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", HBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", HBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", HBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", HBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/JaxxHelpBroker.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -19,7 +19,7 @@
import javax.swing.AbstractButton;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.SwingUtil;
import org.apache.commons.logging.Log;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/LocaleListCellRenderer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -20,7 +20,7 @@
public static final Log log = LogFactory.getLog(LocaleListCellRenderer.class);
private static final long serialVersionUID = 1L;
- protected Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
+ protected final Map<Locale, Icon> cache = new HashMap<Locale, Icon>();
protected boolean showIcon;
protected boolean showText;
@@ -51,11 +51,21 @@
public String getText(Locale locale) {
String text = null;
if (showText) {
- text = locale.getDisplayName(Locale.getDefault());
+ text = getSafeText(locale);
}
return text;
}
+ public Icon getIcon(Locale locale) {
+ if (!showIcon) {
+ return null;
+ }
+ synchronized (cache) {
+ Icon icon = getSafeIcon(locale);
+ return icon;
+ }
+ }
+
public String getToolTipText(Locale locale) {
String tip = locale.getDisplayName(Locale.getDefault());
return tip;
@@ -81,10 +91,12 @@
firePropertyChange("showText", old, showText);
}
- public synchronized Icon getIcon(Locale locale) {
- if (!showIcon) {
- return null;
- }
+ public String getSafeText(Locale locale) {
+ String text = locale.getDisplayName(Locale.getDefault());
+ return text;
+ }
+
+ public synchronized Icon getSafeIcon(Locale locale) {
Icon icon = cache.get(locale);
if (icon != null) {
return icon;
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/beaninfos/VBoxBeanInfo.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/VBoxBeanInfo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.runtime.swing;
+
+import javax.swing.JPanel;
+import javax.swing.SwingConstants;
+import java.beans.BeanInfo;
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.beans.SimpleBeanInfo;
+
+public class VBoxBeanInfo extends SimpleBeanInfo {
+
+ @Override
+ public BeanInfo[] getAdditionalBeanInfo() {
+ try {
+ return new BeanInfo[]{Introspector.getBeanInfo(JPanel.class)};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+
+ @Override
+ public PropertyDescriptor[] getPropertyDescriptors() {
+ try {
+ PropertyDescriptor spacing = new PropertyDescriptor("spacing", VBox.class);
+ spacing.setBound(true);
+
+ PropertyDescriptor margin = new PropertyDescriptor("margin", VBox.class);
+ margin.setBound(true);
+
+ PropertyDescriptor horizontalAlignment = new PropertyDescriptor("horizontalAlignment", VBox.class);
+ horizontalAlignment.setBound(true);
+ horizontalAlignment.setValue("enumerationValues", new Object[]{
+ "left", SwingConstants.LEFT, "SwingConstants.LEFT",
+ "center", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "right", SwingConstants.RIGHT, "SwingConstants.RIGHT"
+ });
+
+ PropertyDescriptor verticalAlignment = new PropertyDescriptor("verticalAlignment", VBox.class);
+ verticalAlignment.setBound(true);
+ verticalAlignment.setValue("enumerationValues", new Object[]{
+ "top", SwingConstants.TOP, "SwingConstants.TOP",
+ "middle", SwingConstants.CENTER, "SwingConstants.CENTER",
+ "bottom", SwingConstants.BOTTOM, "SwingConstants.BOTTOM"
+ });
+
+ return new PropertyDescriptor[]{spacing, margin, horizontalAlignment, verticalAlignment};
+ } catch (IntrospectionException e) {
+ throw new RuntimeException(e);
+ }
+ }
+}
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeContextHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,150 @@
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.JTree;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+
+/**
+ * To help getting and setting navigation tree objects from a {@link JAXXContext}.
+ * <p/>
+ * There is six types of data which can be hold in a context :
+ * <ul>
+ * <li>tree : the tree </li>
+ * <li>tree model : the navigation tree model</li>
+ * <li>tree handler : the navigation tree handler</li>
+ * <li>selected path : the navigation path of the selected node</li>
+ * <li>selected node : the selected node</li>
+ * <li>selected bean : the selected bean</li>
+ * </ul>
+ *
+ * To make possible the use of more than one navigation tree system in a same
+ * context, we <b>MUST</b> distinguish the context entries definition. For this
+ * purpose, entries definition are normalized and prefixed by a unique {@link #prefix}.
+ * <p/>
+ * Here is the keys mapping :
+ * <ul>
+ * <li>tree : {@code prefix + "-tree"}</li>
+ * <li>tree model : {@code prefix + "-tree-model"}</li>
+ * <li>tree handler : {@code prefix + "-tree-handler"}</li>
+ * <li>selected path : {@code prefix + "-selected-path"}</li>
+ * <li>selected node : {@code prefix + "-selected-node"}</li>
+ * <li>selected bean : {@code prefix + "-selected-bean"}</li>
+ * </ul>
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeContextHelper {
+
+ protected final String prefix;
+ protected JAXXContextEntryDef<String> selectedPathContextEntry;
+ protected JAXXContextEntryDef<Object> selectedBeanContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeNode> selectedNodeContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeModel> treeModelContextEntry;
+ protected JAXXContextEntryDef<NavigationTreeHandler> treeHandlerContextEntry;
+ protected JAXXContextEntryDef<JTree> treeContextEntry;
+
+ public NavigationTreeContextHelper(String prefix) {
+ this.prefix = prefix;
+ treeContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree", JTree.class);
+ treeModelContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-model", NavigationTreeModel.class);
+ treeHandlerContextEntry = JAXXContextEntryDef.newDef(prefix + "-tree-handler", NavigationTreeHandler.class);
+ selectedBeanContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-bean", Object.class);
+ selectedNodeContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-node", NavigationTreeNode.class);
+ selectedPathContextEntry = JAXXContextEntryDef.newDef(prefix + "-selected-path", String.class);
+ }
+
+ public String getPrefix() {
+ return prefix;
+ }
+
+ public JTree getTree(JAXXContext context) {
+ JTree r = getTreeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeModel getTreeModel(JAXXContext context) {
+ NavigationTreeModel r = getTreeModelContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeHandler getTreeHandler(JAXXContext context) {
+ NavigationTreeHandler r = getTreeHandlerContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public String getSelectedPath(JAXXContext context) {
+ String r = getSelectedPathContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public NavigationTreeNode getSelectedNode(JAXXContext context) {
+ NavigationTreeNode r = getSelectedNodeContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public Object getSelectedBean(JAXXContext context) {
+ Object r = getSelectedBeanContextEntry().getContextValue(context);
+ return r;
+ }
+
+ public void setTreeModel(JAXXContext context, NavigationTreeModel model) {
+ getTreeModelContextEntry().setContextValue(context, model);
+ }
+
+ public void setTree(JAXXContext context, JTree tree) {
+ getTreeContextEntry().setContextValue(context, tree);
+ }
+
+ public void setTreeHandler(JAXXContext context, NavigationTreeHandler handler) {
+ getTreeHandlerContextEntry().setContextValue(context, handler);
+ }
+
+ public void setSelectedPath(JAXXContext context, String path) {
+ if (path == null) {
+ getSelectedPathContextEntry().removeContextValue(context);
+ } else {
+ getSelectedPathContextEntry().setContextValue(context, path);
+ }
+ }
+
+ public void setSelectedNode(JAXXContext context, NavigationTreeNode node) {
+ if (node == null) {
+ getSelectedNodeContextEntry().removeContextValue(context);
+ } else {
+ getSelectedNodeContextEntry().setContextValue(context, node);
+ }
+ }
+
+ public void setSelectedBean(JAXXContext context, Object bean) {
+ if (bean == null) {
+ getSelectedBeanContextEntry().removeContextValue(context);
+ } else {
+ getSelectedBeanContextEntry().setContextValue(context, bean);
+ }
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeModel> getTreeModelContextEntry() {
+ return treeModelContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeHandler> getTreeHandlerContextEntry() {
+ return treeHandlerContextEntry;
+ }
+
+ protected JAXXContextEntryDef<Object> getSelectedBeanContextEntry() {
+ return selectedBeanContextEntry;
+ }
+
+ protected JAXXContextEntryDef<NavigationTreeNode> getSelectedNodeContextEntry() {
+ return selectedNodeContextEntry;
+ }
+
+ protected JAXXContextEntryDef<String> getSelectedPathContextEntry() {
+ return selectedPathContextEntry;
+ }
+
+ protected JAXXContextEntryDef<JTree> getTreeContextEntry() {
+ return treeContextEntry;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeContextHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandler.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,275 @@
+package jaxx.runtime.swing.navigation;
+
+import java.awt.Component;
+import javax.swing.event.TreeSelectionEvent;
+import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeSelectionModel;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * The handler of a navigation tree.
+ *
+ * This is also the selection model to use, since we must check before moving
+ * from a node we can not just listen selection model changed, we must control
+ * it.
+ *
+ * @author tony
+ * @since 1.7.2
+ */
+public abstract class NavigationTreeHandler extends DefaultTreeSelectionModel {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandler.class);
+
+ /**
+ * Strategy of instanciation of ui.
+ * <p/>
+ * For a given {@code node}, the method {@link #getId(NavigationTreeNode)}
+ * returns the id of ui to use.
+ */
+ public enum Strategy {
+
+ /**
+ * instanciate a ui for a node
+ */
+ PER_NODE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getFullPath();
+ }
+ },
+ /**
+ * instanciate only one a ui for a type,nodes will share the instanciation
+ */
+ PER_UI_TYPE {
+
+ @Override
+ public String getId(NavigationTreeNode node) {
+ return node.getUIClass().getName();
+ }
+ };
+
+ public abstract String getId(NavigationTreeNode node);
+ }
+ /**
+ * UI which contains navigation tree
+ */
+ protected JAXXContext context;
+ /**
+ * UI Instanciation strategy
+ */
+ protected Strategy strategy;
+ /**
+ * JAXXContext access helper.
+ *
+ * @since 1.7.2
+ */
+ protected NavigationTreeContextHelper contextHelper;
+
+ protected NavigationTreeHandler(String contextPrefix, JAXXObject context, Strategy strategy) {
+ this.contextHelper = new NavigationTreeContextHelper(contextPrefix);
+ this.context = context;
+ this.strategy = strategy;
+ addTreeSelectionListener(new TreeSelectionListener() {
+
+ @Override
+ public void valueChanged(TreeSelectionEvent event) {
+ if (event.getOldLeadSelectionPath() != null && event.getOldLeadSelectionPath().equals(event.getPath())) {
+ // do not treate this if no path changed
+ return;
+ }
+ NavigationTreeNode node = (NavigationTreeNode) event.getPath().getLastPathComponent();
+ selectNodeUI(node);
+ }
+ });
+ }
+
+ /**
+ * @return le modèle de navigation associé
+ */
+ protected abstract NavigationTreeModel getNavigationTreeModel();
+
+ /**
+ * @return le composent actuellement visible associé au noeud courant ou
+ * au noeud précédent lors d'un changement de noeud.
+ */
+ protected abstract Component getCurrentUI();
+
+ /**
+ * @param node le noeud associé à l'ui à retrouver
+ * @return l'ui associé au novueau noeud sélectionné
+ */
+ protected abstract Component getUI(NavigationTreeNode node);
+
+ /**
+ * @param component le composent actuellement visible
+ * @return <code>true</code> si le composent a bien été fermé, <code>false</code> sinon
+ * @throws Exception if any
+ */
+ protected abstract boolean closeUI(Component component) throws Exception;
+
+ /**
+ * Instancie une nouvelle ui associé à un noeud de l'arbre de navigation
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return la nouvelle ui associée au noeud
+ * @throws Exception if any
+ */
+ protected abstract Component createUI(NavigationTreeNode node) throws Exception;
+
+ /**
+ * Ouvre l'ui associée au noeud sélectionné dans l'arbre de navigation.
+ *
+ * @param newUI l'ui associé au noeud sélectionné à ouvrir
+ * @param node le node de l'ui a ouvrir
+ * @throws Exception if any
+ */
+ protected abstract void openUI(Component newUI, NavigationTreeNode node) throws Exception;
+
+ /**
+ * Traitement des exceptions.
+ *
+ * @param e l'erreur recontrée (ou null si pas d"erreur)
+ */
+ protected abstract void treateError(Exception e);
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ public NavigationTreeContextHelper getContextHelper() {
+ return contextHelper;
+ }
+
+ @Override
+ public void setSelectionPath(TreePath path) {
+ if (path.equals(getSelectionPath())) {
+ // stay on same node, can skip
+ if (log.isDebugEnabled()) {
+ log.debug("skip stay on path " + path);
+ }
+ return;
+ }
+ Component component = getCurrentUI();
+
+ try {
+ if (!closeUI(component)) {
+ if (log.isDebugEnabled()) {
+ log.debug("changing node canceled!");
+ }
+ // can not changed current node
+ return;
+ }
+ } catch (Exception ex) {
+ treateError(ex);
+ return;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("will select path " + path);
+ }
+ // ok can safely select the new path
+ super.setSelectionPath(path);
+ }
+
+ protected void selectNodeUI(NavigationTreeNode node) {
+
+ try {
+
+ String path = node.getFullPath();
+
+ if (log.isTraceEnabled()) {
+ log.trace(path);
+ }
+
+ Component newUI = getUI(node);
+
+ // now, we are free to open the ui associated with the selected node in navigation
+
+ // get the bean associated with the node
+ Object data = getNavigationTreeModel().getBean(path);
+
+ // save it in context (must be done before init ui)
+ addSelectedBeanInContext(node, data);
+
+ if (newUI == null) {
+
+ // a new ui instance is required
+ newUI = createUI(node);
+ }
+
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // save in context current node context path
+ helper.setSelectedPath(ctxt, node.getFullPath());
+
+ // save in context current node
+ helper.setSelectedNode(ctxt, node);
+
+ // really open the ui associated with the selected node
+ openUI(newUI, node);
+
+ } catch (Exception e) {
+ // remove data from context
+
+ // if any error, go back to previvous node
+ treateError(e);
+ }
+ }
+
+ /**
+ * Prepare le context a utiliser pour initialiser une nouvelle ui.
+ *
+ * @param node le noeud associé à l'ui à créer
+ * @return le context à utiliser pour instancier l'ui
+ * @throws Exception if any
+ */
+ protected JAXXContext createUIContext(NavigationTreeNode node) throws Exception {
+
+ if (node.getUIHandlerClass() == null) {
+ if (log.isWarnEnabled()) {
+ log.warn("no action associated with ui " + node.getUIClass());
+ }
+ // no action associated, just
+ return getContext();
+ }
+
+ JAXXAction action = node.getUIHandlerClass().newInstance();
+
+ // init context with
+ JAXXInitialContext uiContext = action.init(getContext());
+ return uiContext;
+ }
+
+ protected void addSelectedBeanInContext(NavigationTreeNode node, Object data) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("find data for contextPath <" + node.getFullPath() + "> : " + (data == null ? null : data.getClass()));
+ }
+ JAXXContext ctxt = getContext();
+ NavigationTreeContextHelper helper = getContextHelper();
+
+ // remove previous selected bean
+ //TODO-TC-20091004 should have an automatic clean context method while
+ // quiting a node ?
+ helper.setSelectedBean(ctxt, null);
+
+ if (data != null) {
+
+ helper.setSelectedBean(ctxt, data);
+ //FIXME-TC-20091004 : should really remove this, this is not context safe
+ //todo should we not use this to avoid conflict in context ?
+ //context.setContextValue(data);
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHandlerWithCardLayout.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,100 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.swing.CardLayout2;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JPanel;
+import java.awt.Component;
+
+/**
+ * Simple {@link NavigationTreeHandler} implementation with a {@link CardLayout2} to manage components to
+ * associated with tree's nodes.
+ * <p/>
+ * For each node, the ui associated has a constraints in a cardlayout which is the node context path.
+ * <p/>
+ * A single container managed by the cardlayout is used to display the components associated with tree's nodes.
+ *
+ * @author chemit
+ */
+public abstract class NavigationTreeHandlerWithCardLayout extends NavigationTreeHandler {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHandlerWithCardLayout.class);
+
+ /**
+ * All components associated with a tree's node is displayed in a single container.
+ *
+ * @return the containter of components
+ */
+ protected abstract JPanel getContentContainer();
+
+ /**
+ * the cardlayout managing components associated with tree node. The constraints
+ * of each component is the node contextPath.
+ *
+ * @return the layout used to display components associated with tree's nodes.
+ */
+ protected abstract CardLayout2 getContentLayout();
+
+ public NavigationTreeHandlerWithCardLayout(String contextPrefix, JAXXObject context, Strategy strategy) {
+ super(contextPrefix, context, strategy);
+ if (getContentContainer() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentContainer' in ui " + context);
+ }
+ if (getContentLayout() == null) {
+ throw new IllegalArgumentException("could not have a null 'contentLayout' in ui " + context);
+ }
+ }
+
+ @Override
+ protected Component getCurrentUI() {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ return layout.getVisibleComponent(container);
+ }
+
+ @Override
+ protected Component getUI(NavigationTreeNode node) {
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ String constraints = strategy.getId(node);
+ return layout.contains(constraints) ? layout.getComponent(container, constraints) : null;
+ }
+
+ @Override
+ protected void openUI(Component newUI, NavigationTreeNode node) throws Exception {
+
+ CardLayout2 layout = getContentLayout();
+ JPanel container = getContentContainer();
+ // switch layout
+ String constraints = strategy.getId(node);
+ layout.show(container, constraints);
+ }
+
+ @Override
+ protected boolean closeUI(Component component) throws Exception {
+ // by default, we says that component was succesfull closed
+ return true;
+ }
+
+ @Override
+ protected Component createUI(NavigationTreeNode node) throws Exception {
+
+ JAXXContext uiContext = createUIContext(node);
+
+ JAXXObject newUI = node.getUIClass().getConstructor(JAXXContext.class).newInstance(uiContext);
+
+ if (log.isDebugEnabled()) {
+ log.debug("instanciate new ui " + newUI);
+ }
+ String constraints = strategy.getId(node);
+ getContentContainer().add((Component) newUI, constraints);
+ return (Component) newUI;
+ }
+}
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHandlerWithCardLayout.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeHelper.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,141 @@
+package jaxx.runtime.swing.navigation;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.regex.Pattern;
+import javax.swing.JTree;
+import javax.swing.tree.TreePath;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Helper object associated to a given navigation tree system.
+ *
+ * To helper is context safe (base on a {@link NavigationTreeContextHelper}.
+ *
+ * @author chemit
+ * @since 1.7.2
+ * @see NavigationTreeModel
+ */
+public abstract class NavigationTreeHelper extends NavigationTreeContextHelper {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeHelper.class);
+
+ /**
+ * Create the tree model.
+ *
+ * @param context the context to associate with fresh model
+ * @return the new model build with data from the given context
+ */
+ public abstract NavigationTreeModel createTreeModel(JAXXContext context);
+
+ /**
+ * Create the tree handler.
+ *
+ * @param context the context to associate with fresh handler
+ * @return the new handler
+ */
+ public abstract NavigationTreeHandler createTreeHandler(JAXXObject context);
+
+ public NavigationTreeHelper(String contextPrefix) {
+ super(contextPrefix);
+ }
+
+ public Object getContextValue(JAXXContext context, String path) throws InvocationTargetException, NoSuchMethodException, IllegalAccessException {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.getBean(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex) {
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+ return treeModel.findNode(path, regex);
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, String regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ public NavigationTreeNode findNode(JAXXContext context, String path, Pattern regex, String suffix) {
+
+ NavigationTreeModel treeModel = getSafeTreeModel(context);
+
+ NavigationTreeNode navigationTreeNode = treeModel.findNode(path, regex);
+ if (navigationTreeNode != null && suffix != null) {
+ navigationTreeNode = treeModel.findNode(navigationTreeNode, suffix);
+ }
+ return navigationTreeNode;
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation à partir de son path.
+ *
+ * @param context le contexte applicatif
+ * @param path le path absolue du noeud dans l'arbre
+ */
+ public void selectNode(JAXXContext context, String path) {
+ NavigationTreeNode node = findNode(context, path);
+ if (log.isDebugEnabled()) {
+ log.debug(path + " :: " + node);
+ }
+ if (node != null) {
+ selectNode(context, node);
+ }
+ }
+
+ /**
+ * Sélection d'un noeud dans l'arbre de navigation.
+ *
+ * @param context le contexte applicatif
+ * @param node le noeud à sélectionner dans l'arbre
+ */
+ public void selectNode(JAXXContext context, NavigationTreeNode node) {
+
+
+ NavigationTreeModel navigationModel = getSafeTreeModel(context);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ TreePath path = new TreePath(navigationModel.getPathToRoot(node));
+ JTree tree = getSafeTree(context);
+ tree.setSelectionPath(path);
+ tree.scrollPathToVisible(path);
+ }
+
+ public NavigationTreeModel getSafeTreeModel(JAXXContext context) throws NullPointerException {
+ NavigationTreeModel treeModel = getTreeModel(context);
+ if (treeModel == null) {
+ throw new NullPointerException("could not find tree model with key " + getTreeModelContextEntry() + " in context " + context);
+ }
+ return treeModel;
+ }
+
+ public JTree getSafeTree(JAXXContext context) throws NullPointerException {
+ JTree tree = getTree(context);
+ if (tree == null) {
+ throw new NullPointerException("could not find tree with key " + getTreeContextEntry() + " in context " + context);
+ }
+ return tree;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeHelper.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModel.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,246 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.context.JAXXContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import java.util.Enumeration;
+import java.util.StringTokenizer;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Model of the tree used for a navigation tree.
+ * <p/>
+ * Il est composé de {@link NavigationTreeNode}
+ *
+ * @author chemit
+ * @since 1.7.2
+ */
+public class NavigationTreeModel extends DefaultTreeModel {
+
+ static private final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModel.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see NavigationTreeNode#getNodePath()
+ * @see NavigationTreeNode#getFullPath()
+ */
+ protected final String pathSeparator;
+ /**
+ * Context to retrieve beans
+ */
+ private JAXXContext context;
+
+ public NavigationTreeModel(String pathSeparator, JAXXContext context) {
+ super(null);
+ this.pathSeparator = pathSeparator;
+ this.context = context;
+ }
+
+ @Override
+ public NavigationTreeNode getRoot() {
+ return (NavigationTreeNode) super.getRoot();
+ }
+
+ /**
+ * Search from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by dot.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the root node, or <code>null</code> if not find.
+ */
+ public NavigationTreeNode findNode(String path) {
+ return findNode(getRoot(), path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node fi the given <code>regex</code> is not null.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, String regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from the root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ * <p/>
+ * Example :
+ * <p/>
+ * <pre>$root.child1.leaf1</pre>
+ *
+ * @param path the fully path of the searched node.
+ * @param regex a optional regex to apply to path before searching
+ * @return the node matching the fully context from the root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(String path, Pattern regex) {
+ return findNode(getRoot(), path, regex);
+ }
+
+ /**
+ * Search from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path) {
+ return findNode(root, path, (Pattern) null);
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes)
+ * {@link NavigationTreeNode#navigationPath} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, String regex) {
+ return findNode(root, path, regex == null ? null : Pattern.compile(regex));
+ }
+
+ /**
+ * Apply first the regex pattern to obtain the searched node.
+ * <p/>
+ * Search then from a given root node a node named by his fully path (concatenation of nodes
+ * {@link NavigationTreeNode#path} valued separated by {@link #pathSeparator}.
+ *
+ * @param root root node to be used
+ * @param path the fully path of the searched node.
+ * @param regex a previous regex to apply to path : must have a matches
+ * @return the node matching the fully context from the given root node, or <code>null</code> if not found.
+ */
+ public NavigationTreeNode findNode(NavigationTreeNode root, String path, Pattern regex) {
+ if (regex != null) {
+ Matcher matcher = regex.matcher(path);
+ if (!matcher.matches() || matcher.groupCount() < 1) {
+ log.warn("no matching regex " + regex + " to " + path);
+ return null;
+ }
+ path = matcher.group(1);
+ if (log.isDebugEnabled()) {
+ log.debug("matching regex " + regex + " : " + path);
+ }
+ }
+ StringTokenizer stk = new StringTokenizer(path, pathSeparator);
+ NavigationTreeNode result = root;
+ // pas the first token (matches the root node)
+ if (root.isRoot() && stk.hasMoreTokens()) {
+ String rootPath = stk.nextToken();
+ if (!rootPath.equals(root.getNodePath())) {
+ return null;
+ }
+ }
+ while (stk.hasMoreTokens()) {
+ result = result.getChild(stk.nextToken());
+ }
+ return result;
+ }
+
+ public JAXXContext getContext() {
+ return context;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node from given navigation path.
+ *
+ * @param navigationPath the current context path of the node
+ * @return the value associated in context with the given navigation path
+ */
+ public Object getBean(String navigationPath) {
+ Object result;
+ NavigationTreeNode node = findNode(navigationPath, (Pattern) null);
+ result = getBean(node);
+ return result;
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param node the current node
+ * @return the value associated in context with the given node.
+ */
+ public Object getBean(NavigationTreeNode node) {
+ if (node == null) {
+ return null;
+ //fixme should throw a NPE exception
+ //throw new NullPointerException("node can not be null");
+ }
+ return node.getBean(getContext());
+ }
+
+ @Override
+ public void nodeChanged(TreeNode node) {
+ nodeChanged(node, false);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ @Override
+ public void nodeStructureChanged(TreeNode node) {
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep reload
+ reload(n, true);
+ super.nodeStructureChanged(node);
+ if (log.isDebugEnabled()) {
+ log.debug(node);
+ }
+ }
+
+ public void nodeChanged(TreeNode node, boolean deep) {
+
+ NavigationTreeNode n = (NavigationTreeNode) node;
+ //TC-20091004 never launch a deep clean, since we do a deep nodeChanged.
+ reload(n, deep);
+ super.nodeChanged(node);
+ }
+
+ protected void reload(NavigationTreeNode node) {
+ reload(node, false);
+ }
+
+ protected void reload(NavigationTreeNode node, boolean deep) {
+ if (node == null) {
+ return;
+ }
+ node.reload(getContext());
+
+ if (deep) {
+ Enumeration<?> childs = node.children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode o = (NavigationTreeNode) childs.nextElement();
+ reload(o, true);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModel.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeModelBuilder.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,242 @@
+package jaxx.runtime.swing.navigation;
+
+import java.util.Enumeration;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import jaxx.runtime.decorator.Decorator;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * This object is design to build a {@link NavigationTreeModel}.
+ *
+ * @author chemit
+ * @since 17.2
+ */
+public class NavigationTreeModelBuilder {
+
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeModelBuilder.class);
+ /**
+ * The model dealed by the builder.
+ *
+ * <b>Note:</b> It is a good idea to keep only one instance of the model.
+ * If reset is required, should empty the model but not reinstanciate it.
+ */
+ protected NavigationTreeModel model;
+ /**
+ * default ui class to use if node does not define an ui class
+ */
+ protected Class<? extends JAXXObject> defaultUIClass;
+ /**
+ * [optional] default action class
+ */
+ protected Class<? extends JAXXAction> defaultUIHandlerClass;
+
+ public NavigationTreeModelBuilder(String pathSeparator, JAXXContext context, Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass) {
+ this(defaultUIClass, defaultUIHandlerClass, new NavigationTreeModel(pathSeparator, context));
+ }
+
+ public NavigationTreeModelBuilder(Class<? extends JAXXObject> defaultUIClass, Class<? extends JAXXAction> defaultUIHandlerClass, NavigationTreeModel model) {
+ this.defaultUIClass = defaultUIClass;
+ this.defaultUIHandlerClass = defaultUIHandlerClass;
+ this.model = model;
+ }
+
+ public NavigationTreeModel getModel() {
+ return model;
+ }
+
+ public NavigationTreeNode buildEmptyRoot(JAXXContextEntryDef<?> entryDef, String contextName) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, null);
+ addI18nNodeRenderer(node, "");
+ return addChildNode(null, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, String libelle,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryPath);
+ addI18nNodeRenderer(node, libelle);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ JAXXContextEntryDef<?> entryDef,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, entryDef);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ public NavigationTreeNode build(NavigationTreeNode parentNode, Decorator<?> decorator,
+ String entryPath,
+ String contextName,
+ Class<? extends JAXXObject> uiClass,
+ Class<? extends JAXXAction> actionClass) {
+ NavigationTreeNode node = new NavigationTreeNode(model.pathSeparator, contextName, null, entryPath);
+ addDecoratorNodeRenderer(node, decorator);
+ addNodeJaxxClasses(node, uiClass, actionClass);
+ return addChildNode(parentNode, node);
+ }
+
+ protected NavigationTreeNode addChildNode(NavigationTreeNode parentNode, NavigationTreeNode node) {
+
+ if (node.getUIClass() == null) {
+ // no ui is associated with this node, use the default one
+ node.setUIClass(defaultUIClass);
+ }
+
+ if (node.getUIHandlerClass() == null) {
+ // no ui handler associated with this node, use the default one
+ node.setUIHandlerClass(defaultUIHandlerClass);
+ }
+ if (parentNode == null) {
+ model.setRoot(node);
+ } else {
+ parentNode.add(node);
+ }
+ model.nodeStructureChanged(parentNode);
+ return node;
+ }
+
+ public NavigationTreeNode removeChildNode(NavigationTreeNode node) {
+ NavigationTreeNode parentNode = node.getParent();
+ model.removeNodeFromParent(node);
+ return parentNode;
+ }
+
+ public void addI18nNodeRenderer(NavigationTreeNode node, String libelle) {
+ node.setRenderer(new NavigationTreeNodeRendererI18nImpl(libelle));
+ }
+
+ public void addDecoratorNodeRenderer(NavigationTreeNode node, Decorator<?> decorator) {
+ node.setRenderer(new NavigationTreeNodeRendererDecoratorImpl(decorator));
+ }
+
+ public void addNodeJaxxClasses(
+ NavigationTreeNode node,
+ Class<? extends JAXXObject> uIClass,
+ Class<? extends JAXXAction> uIHandlerClass) {
+ node.setUIClass(uIClass);
+ node.setUIHandlerClass(uIHandlerClass);
+ }
+
+ public void printModel(NavigationTreeNode node) {
+ if (node == null) {
+ return;
+ }
+ log.info("node " + node.getFullPath() + ", jxpath: " + node.getJaxxContextEntryPath() + ", entryContextDef: " + node.getJaxxContextEntryDef());
+ if (log.isDebugEnabled()) {
+ log.debug("node userObject" + node.getUserObject());
+ log.debug("value from node " + node.getBean(getModel().getContext()));
+ log.debug("value from model " + getModel().getBean(node));
+ }
+ Enumeration<?> children = node.children();
+ while (children.hasMoreElements()) {
+ printModel((NavigationTreeNode) children.nextElement());
+ }
+ }
+
+ public static abstract class ChildBuilder<O> {
+
+ protected NavigationTreeModelBuilder builder;
+
+ protected ChildBuilder(NavigationTreeModelBuilder builder) {
+ this.builder = builder;
+ }
+
+ protected abstract void init(Class<? extends O> klass);
+
+ protected abstract Decorator<? extends O> getDecorator(O child);
+
+ protected abstract String getJXPath(O child);
+
+ protected abstract String getNavigationPath(O child);
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, java.util.Collection<? extends O> beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.isEmpty()) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+
+ public void build(NavigationTreeNode parent, boolean cacheValues, Class<? extends O> klass, O[] beans, Class<? extends JAXXObject> ui, Class<? extends JAXXAction> actionClass) {
+
+ if (beans == null || beans.length == 0) {
+ // no bean to treate
+ return;
+ }
+
+ init(klass);
+
+ NavigationTreeNode node;
+
+ for (O o : beans) {
+ node = builder.build(parent, getDecorator(o), getJXPath(o), getNavigationPath(o), ui, actionClass);
+ if (cacheValues) {
+ // cache the bean value to improve performance
+ node.setBean(o);
+ }
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeModelBuilder.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNode.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,424 @@
+package jaxx.runtime.swing.navigation;
+
+import java.util.Enumeration;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreeNode;
+import jaxx.runtime.JAXXAction;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
+import jaxx.runtime.JAXXObject;
+import org.apache.commons.jxpath.JXPathContext;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+/**
+ * Node of the {@link NavigationTreeModel}.
+ *
+ * Each node is associated with :
+ * <ul>
+ * <li> a {@code bean} coming from a {@link JAXXContext} </li>
+ * <li> a {@code uiClass} to build the associated ui </li>
+ * </ul>
+ * <p/>
+ * To retrieve the bean from the context, there is a huge logic in the
+ * method {@link #getBean(JAXXContext)}.
+ *
+ * In few words, if the {@link #jaxxContextEntryDef} is defined, it means
+ * that the object is taken from the {@code context}.
+ * <p/>
+ * Otherwise, find the first ancestor with an context entry and retrieve from
+ * here the bean.
+ * <p/>
+ * Then go down to the initial node by applying the jxpath expressions
+ * {@link #jaxxContextEntryPath} of each node on road back.
+ * <p/>
+ *
+ * To identify easly a node, each node has a {@link #path} and a
+ * {@link #fullPath} (full path from root node).
+ * <p/>
+ *
+ * To display the node we use a {@link NavigationTreeNodeRenderer} which is in
+ * fact the {@link #userObject}, the object can be synch with the bean via the
+ * {@link NavigationTreeNodeRenderer#reload(java.lang.Object)} method.
+ *
+ * @author chemit
+ * @see NavigationTreeModel
+ * @see NavigationTreeNodeRenderer
+ * @since 1.7.2
+ */
+public class NavigationTreeNode extends DefaultMutableTreeNode {
+
+ private static final long serialVersionUID = 1L;
+ /**
+ * Logger
+ */
+ static private final Log log = LogFactory.getLog(NavigationTreeNode.class);
+ /**
+ * The path separator used to build the {@link #fullPath}.
+ *
+ * @see #path
+ * @see #fullPath
+ */
+ protected final String pathSeparator;
+ /**
+ * The node path.
+ * <p/>
+ * Used to build the {@link #fullPath} which gives a unique identifier of the
+ * node.
+ * @see #pathSeparator
+ * @see #fullPath
+ */
+ protected String path;
+ /**
+ * The full path for the node from the rood node.
+ * <p/>
+ * This path is build by appending nodes {@link #path} from the root node
+ * to this node, between each path we introduce the {@link #pathSeparator}.
+ * <p>
+ * Exemple :
+ * <pre>
+ * root
+ * $root
+ * `-- child1
+ * `-- child2
+ * </pre>
+ * will given {@code $root/child1/child2}.
+ * @see #pathSeparator
+ * @see #path
+ */
+ protected String fullPath;
+ /**
+ * The UI class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIClass} will be used while
+ * building the model.
+ */
+ protected Class<? extends JAXXObject> uIClass;
+ /**
+ * The UI handler class associated with the node.
+ * <p/>
+ * This class can be {@code null}, in that case, the
+ * {@link NavigationTreeModelBuilder#defaultUIHandlerClass} will be used
+ * while building the model.
+ */
+ protected Class<? extends JAXXAction> uIHandlerClass;
+ /**
+ * The context entry definition to retrieve the bean.
+ *
+ * <b>Note:</b> If not set - the {@code bean} will be retrieve on a ancestor
+ * node.
+ */
+ protected JAXXContextEntryDef<?> jaxxContextEntryDef;
+ /**
+ * The jxPath to process to obtain real {@code bean} from the data retrieve
+ * in the context.
+ *
+ * <b>Note:</b> If not set -no jxpath will be apply on the bean from context.
+ */
+ protected String jaxxContextEntryPath;
+ /**
+ * The bean associated with the node ( the value can be obtain via the
+ * method {@link #getBean(JAXXContext)} or directly set via method
+ * {@link #setBean(Object)}.
+ * <p/>
+ * cache of bean associated with bean to improve performance
+ */
+ protected transient Object bean;
+ /**
+ * The type of the related bean associated with the node.
+ * <p/>
+ * Note: This type is here to override the NodeRenderer internalClass, since
+ * we could need to override this data.
+ * <p/>
+ * If this property is let to null, then we will use the NodeRenderer one
+ */
+ protected Class<?> internalClass;
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, Object jaxxContextEntryDef) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ if (jaxxContextEntryDef instanceof JAXXContextEntryDef<?>) {
+ this.jaxxContextEntryDef = ((JAXXContextEntryDef<?>) jaxxContextEntryDef);
+ } else if (jaxxContextEntryDef instanceof String) {
+ this.jaxxContextEntryPath = (String) jaxxContextEntryDef;
+ } else if (jaxxContextEntryDef != null) {
+ // wrong context definition type
+ throw new IllegalArgumentException("to define a context link, must be a String (jxpath) or a " + JAXXContextEntryDef.class + ", but was " + jaxxContextEntryDef);
+ }
+ }
+
+ public NavigationTreeNode(String pathSeparator, String navigationPath, JAXXContextEntryDef<?> jaxxContextEntryDef, String jaxxContextEntryPath) {
+ super();
+ this.pathSeparator = pathSeparator;
+ this.path = navigationPath;
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ /**
+ *
+ * @return the text node renderer (store in {@link #userObject} property.
+ */
+ public NavigationTreeNodeRenderer getRenderer() {
+ NavigationTreeNodeRenderer render = null;
+ Object o = getUserObject();
+ if (o != null && o instanceof NavigationTreeNodeRenderer) {
+ render = (NavigationTreeNodeRenderer) o;
+ }
+ return render;
+ }
+
+ public void setRenderer(NavigationTreeNodeRenderer renderer) {
+ // clear all cache
+ bean = null;
+ setUserObject(renderer);
+ }
+
+ public String getPathSeparator() {
+ return pathSeparator;
+ }
+
+ public String getNodePath() {
+ return path;
+ }
+
+ public void setNodePath(String navigationPath) {
+ this.path = navigationPath;
+ }
+
+ public Class<? extends JAXXObject> getUIClass() {
+ return uIClass;
+ }
+
+ public void setUIClass(Class<? extends JAXXObject> uIClass) {
+ this.uIClass = uIClass;
+ }
+
+ public void setInternalClass(Class<?> internalClass) {
+ this.internalClass = internalClass;
+ }
+
+ public Class<? extends JAXXAction> getUIHandlerClass() {
+ return uIHandlerClass;
+ }
+
+ public void setUIHandlerClass(Class<? extends JAXXAction> uIHandlerClass) {
+ this.uIHandlerClass = uIHandlerClass;
+ }
+
+ public JAXXContextEntryDef<?> getJaxxContextEntryDef() {
+ return jaxxContextEntryDef;
+ }
+
+ public void setJaxxContextEntryDef(JAXXContextEntryDef<?> jaxxContextEntryDef) {
+ this.jaxxContextEntryDef = jaxxContextEntryDef;
+ }
+
+ public String getJaxxContextEntryPath() {
+ return jaxxContextEntryPath;
+ }
+
+ public void setJaxxContextEntryPath(String jaxxContextEntryPath) {
+ this.jaxxContextEntryPath = jaxxContextEntryPath;
+ }
+
+ public Class<?> getInternalClass() {
+ if (internalClass == null && getRenderer() != null) {
+ return getRenderer().getInternalClass();
+ }
+ return internalClass;
+ }
+
+ /** @return the fully context path of the node from the root node to this. */
+ public String getFullPath() {
+ if (fullPath == null) {
+ StringBuilder sb = new StringBuilder();
+ for (TreeNode treeNode : getPath()) {
+ NavigationTreeNode myNode = (NavigationTreeNode) treeNode;
+ sb.append(pathSeparator).append(myNode.getNodePath());
+ }
+ fullPath = sb.substring(1);
+ }
+ return fullPath;
+ }
+
+ @Override
+ public NavigationTreeNode getChildAt(int index) {
+ return (NavigationTreeNode) super.getChildAt(index);
+ }
+
+ @Override
+ public NavigationTreeNode getParent() {
+ return (NavigationTreeNode) super.getParent();
+ }
+
+ /**
+ * @param path the name of the {@link #path} to be matched in the cild of this node.
+ * @return the child of this node with given {@link # path} value.
+ */
+ public NavigationTreeNode getChild(String path) {
+ Enumeration<?> childs = children();
+ while (childs.hasMoreElements()) {
+ NavigationTreeNode son = (NavigationTreeNode) childs.nextElement();
+ if (path.equals(son.getNodePath())) {
+ return son;
+ }
+ }
+ return null;
+ }
+
+ public Object getBean() {
+ return bean;
+ }
+
+ public void setBean(Object bean) {
+ this.bean = bean;
+ }
+
+ public void reload(JAXXContext context) {
+
+ // clear bean cache
+ bean = null;
+
+ // clear context navigation cache
+ fullPath = null;
+
+ NavigationTreeNodeRenderer renderer = getRenderer();
+ if (renderer == null) {
+ // this can't be !
+ throw new NullPointerException("could not find the renderer for node " + this);
+ }
+
+ Object b = getBean(context);
+
+ renderer.reload(b);
+ }
+
+ /**
+ * Obtain the associated bean value from context corresponding to node
+ *
+ * @param context the context to seek
+ * @return the value associated in context with the given context path
+ */
+ public Object getBean(JAXXContext context) {
+ if (bean != null) {
+ // use cached bean
+ return bean;
+ }
+ Object result;
+ if (getJaxxContextEntryDef() != null && jaxxContextEntryPath == null) {
+ // the node maps directly a value in context, with no jxpath resolving
+ result = getJaxxContextEntryDef().getContextValue(context);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+ // find the first ancestor node with a context def
+ NavigationTreeNode parentNode = getFirstAncestorWithDef();
+ if (parentNode == null) {
+ log.warn("could not find a ancestor node with a definition of a context entry from node (" + this + ")");
+ // todo must be an error
+ // no parent found
+ return null;
+ }
+ Object parentBean = parentNode.getJaxxContextEntryDef().getContextValue(context);
+ if (parentBean == null) {
+ // must be an error no bean found
+ log.warn("could not find a bean attached in context from context entry definition " + parentNode.getJaxxContextEntryDef());
+ return null;
+ }
+ if (parentNode.jaxxContextEntryPath != null) {
+ // apply the jxpath on parentBean
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ parentBean = jxcontext.getValue(parentNode.jaxxContextEntryPath);
+ }
+ // save in cache
+ parentNode.setBean(parentBean);
+ if (this == parentNode) {
+ // current node is the node matching the context entry value and no jxpath is found
+ return parentBean;
+ }
+ if (jaxxContextEntryPath == null) {
+ // todo must be an error
+ log.warn("must find a jaxxContextEntryPath on node (" + this + ")");
+ return null;
+ }
+ String jxpathExpression = computeJXPath(jaxxContextEntryPath, parentNode);
+ if (jxpathExpression == null) {
+ /// todo must be an error
+ log.warn("could not build jxpath from node " + parentNode + " to " + this);
+ // could not retreave the jxpath...
+ return null;
+ }
+ if (jxpathExpression.startsWith("[")) {
+ // special case when we want to access a collection
+ jxpathExpression = '.' + jxpathExpression;
+ }
+ if (log.isDebugEnabled()) {
+ log.debug("jxpath : " + jxpathExpression);
+ }
+ JXPathContext jxcontext = JXPathContext.newContext(parentBean);
+ result = jxcontext.getValue(jxpathExpression);
+ // save in cache
+ setBean(result);
+ return result;
+ }
+
+ /**
+ * @return the first ancestor with a none null {@link #jaxxContextEntryDef}
+ * or <code>null</code> if none find..
+ */
+ protected NavigationTreeNode getFirstAncestorWithDef() {
+ if (jaxxContextEntryDef != null) {
+ // find a node with a direct link with the context
+ return this;
+ }
+ // the node is not linked to context
+ // seek in his parent
+ NavigationTreeNode ancestor = getParent();
+ return ancestor == null ? null : ancestor.getFirstAncestorWithDef();
+ }
+
+ protected String computeJXPath(String expr, NavigationTreeNode parentNode) {
+ if (parentNode == this) {
+ // reach the parent limit node, return the expr computed
+ return expr;
+ }
+ int firstIndex = expr.indexOf("..");
+ int lastIndex = expr.lastIndexOf("..");
+ if (firstIndex == -1) {
+ // this is a error, since current node is not parent limit node,
+ // we must find somewhere a way to go up in nodes
+ throw new IllegalArgumentException(expr + " should contains at least one \"..\"");
+ }
+ if (firstIndex != 0) {
+ // this is a error, the ../ must be at the beginning of the expression
+ throw new IllegalArgumentException("\"..\" must be at the beginning but was : " + expr);
+ }
+ NavigationTreeNode ancestor = getParent();
+ if (firstIndex == lastIndex) {
+ // found only one go up, so must be substitute by the parent node context
+ String newExpr = expr.substring(2);
+ //String newExpr = expr.substring(expr.startsWith("../") ? 3 : 2);
+ if (getParent().equals(parentNode)) {
+ // parent node is the final parent node, so no substitution needed
+ return newExpr;
+ }
+ // ancestor must have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath == null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node (" + ancestor + ") must have a jaxxContextEntryPath definition, but was not ");
+ }
+ newExpr = ancestor.jaxxContextEntryPath + newExpr;
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+ // have more than one go up, so the ancestor node can not have a jaxxContextEntryPath
+ if (ancestor.jaxxContextEntryPath != null) {
+ throw new IllegalArgumentException("with the expression " + expr + ", the ancestor node can not have a jaxxContextEntryPath definition");
+ }
+ // substitute the last ..[/] and delegate to ancestor
+ String newExpr = expr.substring(0, lastIndex - 1) + expr.substring(lastIndex + (expr.charAt(lastIndex + 3) == '/' ? 3 : 2));
+ return ancestor.computeJXPath(newExpr, parentNode);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNode.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRenderer.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,44 @@
+package jaxx.runtime.swing.navigation;
+
+import javax.swing.tree.TreeCellRenderer;
+
+/**
+ * Text Renderer of a {@link NavigationTreeNode}.
+ * <p/>
+ * This object will be placed as the {@link NavigationTreeNode#userObject} of
+ * nodes.
+ * <p/>
+ *
+ * In that way, we can use the {@link #toString()} value to render the node
+ * without writing any {@link TreeCellRenderer}.
+ * <p/>
+ * To rebuild the renderer text of a node use the method {@link #reload(Object)}
+ * with the {@code bean} provides by the model for the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public interface NavigationTreeNodeRenderer extends java.io.Serializable {
+
+ /**
+ *
+ * @return the render value of the node
+ */
+ @Override
+ String toString();
+
+ /**
+ *
+ * Can override the the node internal class for display purpose.
+ *
+ * @return the type of data to be displayed.
+ */
+ Class<?> getInternalClass();
+
+ /**
+ * Reload the render value from the {@code bean} of node.
+ *
+ * @param bean the bean associated to the node to render
+ */
+ void reload(Object bean);
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRenderer.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererDecoratorImpl.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,53 @@
+package jaxx.runtime.swing.navigation;
+
+import jaxx.runtime.decorator.Decorator;
+
+/**
+ * Decorator Renderer of a {@link NavigationTreeNode}.
+ *
+ * Apply a {@link Decorator} to the {@code bean} associated to the node.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererDecoratorImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Decorator
+ */
+ protected final Decorator<?> decorator;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererDecoratorImpl(Decorator<?> decorator) {
+ this.internalClass = decorator.getInternalClass();
+ this.decorator = decorator;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object bean) {
+ try {
+ text = decorator.toString(bean);
+
+ } catch (Exception e) {
+ text = "";
+ }
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererDecoratorImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/NavigationTreeNodeRendererI18nImpl.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,48 @@
+package jaxx.runtime.swing.navigation;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * I18n label Renderer of a {@link NavigationTreeNode}.
+ *
+ * Just apply a i18n translation on the given {@link #libelle}.
+ *
+ * @author chemit
+ * @since 1.7.2, replace {@code NavigationUtil#NodeRenderer} which disappear soon...
+ */
+public class NavigationTreeNodeRendererI18nImpl implements NavigationTreeNodeRenderer {
+
+ private static final long serialVersionUID = -1L;
+ /**
+ * Static i18n label to render
+ */
+ protected final String libelle;
+ /**
+ * internal class of representing data
+ */
+ protected final Class<?> internalClass;
+ /**
+ * last renderered value
+ */
+ protected String text;
+
+ public NavigationTreeNodeRendererI18nImpl(String libelle) {
+ this.libelle = libelle;
+ this.internalClass = String.class;
+ }
+
+ @Override
+ public String toString() {
+ return text;
+ }
+
+ @Override
+ public void reload(Object data) {
+ text = _(libelle);
+ }
+
+ @Override
+ public Class<?> getInternalClass() {
+ return internalClass;
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/NavigationTreeNodeRendererI18nImpl.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/tree/package.html)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,12 @@
+<html>
+ <body>
+ <h1>JAXX - tree utilities</h1>
+
+ This package contains all the classes of the navigation tree framework.
+
+ <p>
+ Replace the previous framework from package
+ <code>jaxx.runtime.swing.navigation</code>
+ </p>
+ </body>
+</html>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/navigation/package.html
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationAction.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,7 +1,7 @@
package jaxx.runtime.swing.wizard;
import javax.swing.SwingWorker;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardOperationActionThread.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -4,7 +4,7 @@
import java.beans.PropertyChangeListener;
import java.util.Date;
import javax.swing.SwingWorker.StateValue;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.JAXXContext;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Modified: branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/main/java/jaxx/runtime/swing/wizard/WizardUILancher.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -2,8 +2,8 @@
import java.awt.Window;
import javax.swing.ImageIcon;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.JAXXObject;
import org.apache.commons.beanutils.ConstructorUtils;
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,117 +0,0 @@
-/*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
-package jaxx.runtime;
-
-import jaxx.runtime.DefaultApplicationContext.AutoLoad;
-import jaxx.runtime.DefaultApplicationContext.MethodAccess;
-import org.junit.After;
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-/**
- *
- * @author tony
- */
-public class DefaultApplicationContextTest {
-
- static int helloCount;
- static int helloGetCount;
-
- @AutoLoad
- @MethodAccess(methodName = "hello", target = String.class)
- public static class Hello {
-
- public Hello() {
- helloCount++;
- }
-
- public String hello(String name) {
- helloGetCount++;
- return "hello " + name;
- }
- }
- DefaultApplicationContext context;
-
- @BeforeClass
- public static void setUpClass() throws Exception {
- helloCount = 0;
- helloGetCount = 0;
- }
-
- @AfterClass
- public static void tearDownClass() throws Exception {
- }
-
- @Before
- public void setUp() {
- context = new DefaultApplicationContext();
- assertEquals(0, helloCount);
- assertEquals(0, helloGetCount);
- }
-
- @After
- public void tearDown() {
- context = null;
- helloCount = helloGetCount = 0;
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testAutoLoadNamed() {
- context.getContextValue(Hello.class, "fakeName");
- }
-
- @Test
- public void testAutoLoad() {
- Hello hello = context.getContextValue(Hello.class);
- assertNotNull(hello);
- assertEquals(1, helloCount);
-
- Hello hello2 = context.getContextValue(Hello.class);
- assertNotNull(hello2);
- assertEquals(1, helloCount);
- assertEquals(hello, hello2);
- }
-
- @Test
- public void testForward() {
- context.getContextValue(Hello.class);
- assertEquals(1, helloCount);
- String response = context.getContextValue(String.class, "John");
- assertNotNull(response);
- assertEquals(1, helloGetCount);
- assertEquals(new Hello().hello("John"), response);
- }
-
- @Test
- public void testRemove() {
- String response;
-
- context.getContextValue(Hello.class);
- assertEquals(1, helloCount);
- assertEquals(1, context.forwards.size());
- response = context.getContextValue(String.class, "John");
- assertNotNull(response);
-
- context.removeContextValue(Hello.class);
- assertEquals(0, context.forwards.size());
- response = context.getContextValue(String.class, "John");
- assertEquals(1, helloCount);
- assertNull(response);
-
- // reinstanciate the service
- context.getContextValue(Hello.class);
- assertEquals(2, helloCount);
- assertEquals(1, context.forwards.size());
-
- // no effect with a name
- context.removeContextValue(Hello.class, "fake");
- assertEquals(1, context.forwards.size());
- context.getContextValue(Hello.class);
- assertEquals(2, helloCount);
- }
-}
\ No newline at end of file
Deleted: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,299 +0,0 @@
-package jaxx.runtime;
-
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import java.awt.Container;
-import java.util.Map;
-
-/** @author chemit */
-public class DefaultJAXXContextTest {
-
- DefaultJAXXContext ctxt;
-
- @Before
- public void initContext() throws Exception {
-
- // instanciate a new empty context
- ctxt = new DefaultJAXXContext();
- }
-
- @Test(expected = IllegalStateException.class)
- public void testParentContainerFail_IllegalStateException() throws Exception {
- ctxt.getParentContainer(Container.class);
- }
-
- @Test(expected = IllegalStateException.class)
- public void testParentContainerFail_IllegalStateException2() throws Exception {
- ctxt.getParentContainer("null", Container.class);
- }
-
-
- @Test(expected = IllegalArgumentException.class)
- public void testParentContainerFail_IllegalArgumentException() throws Exception {
-
- // attach a fake ui (which is NOT a Container)
- ctxt.setUi(new MyJAXXObject());
- ctxt.getParentContainer(Container.class);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParentContainerFail_IllegalArgumentException2() throws Exception {
-
- // attach a fake ui (which is NOT a Container)
- ctxt.setUi(new MyJAXXObject());
- ctxt.getParentContainer(null, Container.class);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void testParentContainerFail_IllegalArgumentException3() throws Exception {
-
- // attach a fake ui (which is NOT a Container)
- ctxt.setUi(new MyJAXXObject());
- ctxt.getParentContainer("null", Container.class);
- }
-
- @Test
- public void testGetParentContext() throws Exception {
- JAXXContext expected, result;
- expected = null;
- result = ctxt.getContextValue(JAXXContext.class);
- Assert.assertEquals(expected, result);
-
- DefaultJAXXContext parentContext = new DefaultJAXXContext();
-
- ctxt.setContextValue(parentContext);
-
- expected = parentContext;
- result = ctxt.getContextValue(JAXXContext.class);
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValue() throws Exception {
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
-
- expected = "yo";
- ctxt.setContextValue(expected);
- result = ctxt.getContextValue(String.class);
- Assert.assertEquals(expected, result);
-
- expected = "ya";
- ctxt.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
-
- expected = "yi";
- ctxt.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValueInParentContext() throws Exception {
-
- // attach parent context
- JAXXContext parentContext = new DefaultJAXXContext();
- ctxt.setContextValue(parentContext);
-
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
-
- expected = "yo";
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- parentContext.setContextValue(expected);
- result = ctxt.getContextValue(String.class);
- Assert.assertEquals(expected, result);
-
- expected = "ya";
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertNull(result);
- parentContext.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
-
- expected = "yi";
- result = ctxt.getContextValue(String.class, "second");
- parentContext.setContextValue(expected, "second");
- Assert.assertEquals("ya", result);
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValue2() throws Exception {
-
- // attach parent context
- JAXXContext parentContext = new DefaultJAXXContext();
- ctxt.setContextValue(parentContext);
-
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- result = ctxt.getContextValue(String.class, "yo");
- Assert.assertNull(result);
-
- expected = "yo";
- ctxt.setContextValue(expected, "yo");
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- result = ctxt.getContextValue(String.class, "yo");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testSetGetContextValueInParentParentContext() throws Exception {
-
- // attach parent parent context
- JAXXContext parentParentContext = new DefaultJAXXContext();
- JAXXContext parentContext = new DefaultJAXXContext();
- parentContext.setContextValue(parentParentContext);
- ctxt.setContextValue(parentContext);
-
- String expected;
- String result;
-
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
-
- expected = "yo";
- result = ctxt.getContextValue(String.class);
- Assert.assertNull(result);
- parentParentContext.setContextValue(expected);
- result = ctxt.getContextValue(String.class);
- Assert.assertEquals(expected, result);
-
- expected = "ya";
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertNull(result);
- parentParentContext.setContextValue(expected, "second");
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
-
- expected = "yi";
- result = ctxt.getContextValue(String.class, "second");
- parentParentContext.setContextValue(expected, "second");
- Assert.assertEquals("ya", result);
- result = ctxt.getContextValue(String.class, "second");
- Assert.assertEquals(expected, result);
- }
-
- @Test
- public void testEntrySet() throws Exception {
- Object o = new Object();
-
- ctxt.setContextValue(o);
-
- Assert.assertEquals(1, ctxt.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.setContextValue(o, "named");
-
- Assert.assertEquals(2, ctxt.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.removeContextValue(Object.class);
- Assert.assertEquals(1, ctxt.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.removeContextValue(Object.class);
- Assert.assertEquals(1, ctxt.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
-
- ctxt.removeContextValue(Object.class, "named");
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
-
- }
-
- @Test
- public void testEntrySetWithParent() throws Exception {
-
- DefaultJAXXContext parentContext = new DefaultJAXXContext();
-
- ctxt.setContextValue(parentContext);
-
- class Object2 {
-
- }
- Object o = new Object2();
-
- parentContext.setContextValue(o);
-
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(1, parentContext.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
-
- parentContext.setContextValue(o, "named");
-
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(2, parentContext.data.size());
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
-
- parentContext.removeContextValue(Object2.class);
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(1, parentContext.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
-
- parentContext.removeContextValue(Object2.class);
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(1, parentContext.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
-
- ctxt.removeContextValue(Object2.class, "named");
- Assert.assertEquals(0, ctxt.data.size());
- Assert.assertEquals(0, parentContext.data.size());
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
- Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
-
- }
-
- private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject {
-
- public Object getObjectById(String id) {
- return null;
- }
-
- public Map<String, Object> get$objectMap() {
- return null;
- }
-
- public void applyDataBinding(String id) {
- }
-
- public void removeDataBinding(String id) {
- }
-
- public JAXXContext getDelegateContext() {
- return null;
- }
-
- public void processDataBinding(String dest) {
- }
-
- public void firePropertyChange(String name, Object oldValue, Object newValue) {
- }
-
- }
-}
Copied: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultApplicationContextTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,113 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.context.DefaultApplicationContext.AutoLoad;
+import jaxx.runtime.context.DefaultApplicationContext.MethodAccess;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+/**
+ *
+ * @author tony
+ */
+public class DefaultApplicationContextTest {
+
+ static int helloCount;
+ static int helloGetCount;
+
+ @AutoLoad
+ @MethodAccess(methodName = "hello", target = String.class)
+ public static class Hello {
+
+ public Hello() {
+ helloCount++;
+ }
+
+ public String hello(String name) {
+ helloGetCount++;
+ return "hello " + name;
+ }
+ }
+ DefaultApplicationContext context;
+
+ @BeforeClass
+ public static void setUpClass() throws Exception {
+ helloCount = 0;
+ helloGetCount = 0;
+ }
+
+ @AfterClass
+ public static void tearDownClass() throws Exception {
+ }
+
+ @Before
+ public void setUp() {
+ context = new DefaultApplicationContext();
+ assertEquals(0, helloCount);
+ assertEquals(0, helloGetCount);
+ }
+
+ @After
+ public void tearDown() {
+ context = null;
+ helloCount = helloGetCount = 0;
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testAutoLoadNamed() {
+ context.getContextValue(Hello.class, "fakeName");
+ }
+
+ @Test
+ public void testAutoLoad() {
+ Hello hello = context.getContextValue(Hello.class);
+ assertNotNull(hello);
+ assertEquals(1, helloCount);
+
+ Hello hello2 = context.getContextValue(Hello.class);
+ assertNotNull(hello2);
+ assertEquals(1, helloCount);
+ assertEquals(hello, hello2);
+ }
+
+ @Test
+ public void testForward() {
+ context.getContextValue(Hello.class);
+ assertEquals(1, helloCount);
+ String response = context.getContextValue(String.class, "John");
+ assertNotNull(response);
+ assertEquals(1, helloGetCount);
+ assertEquals(new Hello().hello("John"), response);
+ }
+
+ @Test
+ public void testRemove() {
+ String response;
+
+ context.getContextValue(Hello.class);
+ assertEquals(1, helloCount);
+ assertEquals(1, context.forwards.size());
+ response = context.getContextValue(String.class, "John");
+ assertNotNull(response);
+
+ context.removeContextValue(Hello.class);
+ assertEquals(0, context.forwards.size());
+ response = context.getContextValue(String.class, "John");
+ assertEquals(1, helloCount);
+ assertNull(response);
+
+ // reinstanciate the service
+ context.getContextValue(Hello.class);
+ assertEquals(2, helloCount);
+ assertEquals(1, context.forwards.size());
+
+ // no effect with a name
+ context.removeContextValue(Hello.class, "fake");
+ assertEquals(1, context.forwards.size());
+ context.getContextValue(Hello.class);
+ assertEquals(2, helloCount);
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultApplicationContextTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java (from rev 1560, branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/DefaultJAXXContextTest.java)
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java (rev 0)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -0,0 +1,300 @@
+package jaxx.runtime.context;
+
+import jaxx.runtime.*;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.awt.Container;
+import java.util.Map;
+
+/** @author chemit */
+public class DefaultJAXXContextTest {
+
+ DefaultJAXXContext ctxt;
+
+ @Before
+ public void initContext() throws Exception {
+
+ // instanciate a new empty context
+ ctxt = new DefaultJAXXContext();
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testParentContainerFail_IllegalStateException() throws Exception {
+ ctxt.getParentContainer(Container.class);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testParentContainerFail_IllegalStateException2() throws Exception {
+ ctxt.getParentContainer("null", Container.class);
+ }
+
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParentContainerFail_IllegalArgumentException() throws Exception {
+
+ // attach a fake ui (which is NOT a Container)
+ ctxt.setUi(new MyJAXXObject());
+ ctxt.getParentContainer(Container.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParentContainerFail_IllegalArgumentException2() throws Exception {
+
+ // attach a fake ui (which is NOT a Container)
+ ctxt.setUi(new MyJAXXObject());
+ ctxt.getParentContainer(null, Container.class);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testParentContainerFail_IllegalArgumentException3() throws Exception {
+
+ // attach a fake ui (which is NOT a Container)
+ ctxt.setUi(new MyJAXXObject());
+ ctxt.getParentContainer("null", Container.class);
+ }
+
+ @Test
+ public void testGetParentContext() throws Exception {
+ JAXXContext expected, result;
+ expected = null;
+ result = ctxt.getContextValue(JAXXContext.class);
+ Assert.assertEquals(expected, result);
+
+ DefaultJAXXContext parentContext = new DefaultJAXXContext();
+
+ ctxt.setContextValue(parentContext);
+
+ expected = parentContext;
+ result = ctxt.getContextValue(JAXXContext.class);
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValue() throws Exception {
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+
+ expected = "yo";
+ ctxt.setContextValue(expected);
+ result = ctxt.getContextValue(String.class);
+ Assert.assertEquals(expected, result);
+
+ expected = "ya";
+ ctxt.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+
+ expected = "yi";
+ ctxt.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValueInParentContext() throws Exception {
+
+ // attach parent context
+ JAXXContext parentContext = new DefaultJAXXContext();
+ ctxt.setContextValue(parentContext);
+
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+
+ expected = "yo";
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ parentContext.setContextValue(expected);
+ result = ctxt.getContextValue(String.class);
+ Assert.assertEquals(expected, result);
+
+ expected = "ya";
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertNull(result);
+ parentContext.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+
+ expected = "yi";
+ result = ctxt.getContextValue(String.class, "second");
+ parentContext.setContextValue(expected, "second");
+ Assert.assertEquals("ya", result);
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValue2() throws Exception {
+
+ // attach parent context
+ JAXXContext parentContext = new DefaultJAXXContext();
+ ctxt.setContextValue(parentContext);
+
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ result = ctxt.getContextValue(String.class, "yo");
+ Assert.assertNull(result);
+
+ expected = "yo";
+ ctxt.setContextValue(expected, "yo");
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ result = ctxt.getContextValue(String.class, "yo");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testSetGetContextValueInParentParentContext() throws Exception {
+
+ // attach parent parent context
+ JAXXContext parentParentContext = new DefaultJAXXContext();
+ JAXXContext parentContext = new DefaultJAXXContext();
+ parentContext.setContextValue(parentParentContext);
+ ctxt.setContextValue(parentContext);
+
+ String expected;
+ String result;
+
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+
+ expected = "yo";
+ result = ctxt.getContextValue(String.class);
+ Assert.assertNull(result);
+ parentParentContext.setContextValue(expected);
+ result = ctxt.getContextValue(String.class);
+ Assert.assertEquals(expected, result);
+
+ expected = "ya";
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertNull(result);
+ parentParentContext.setContextValue(expected, "second");
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+
+ expected = "yi";
+ result = ctxt.getContextValue(String.class, "second");
+ parentParentContext.setContextValue(expected, "second");
+ Assert.assertEquals("ya", result);
+ result = ctxt.getContextValue(String.class, "second");
+ Assert.assertEquals(expected, result);
+ }
+
+ @Test
+ public void testEntrySet() throws Exception {
+ Object o = new Object();
+
+ ctxt.setContextValue(o);
+
+ Assert.assertEquals(1, ctxt.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.setContextValue(o, "named");
+
+ Assert.assertEquals(2, ctxt.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.removeContextValue(Object.class);
+ Assert.assertEquals(1, ctxt.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.removeContextValue(Object.class);
+ Assert.assertEquals(1, ctxt.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object.class, "named"));
+
+ ctxt.removeContextValue(Object.class, "named");
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object.class, "named"));
+
+ }
+
+ @Test
+ public void testEntrySetWithParent() throws Exception {
+
+ DefaultJAXXContext parentContext = new DefaultJAXXContext();
+
+ ctxt.setContextValue(parentContext);
+
+ class Object2 {
+
+ }
+ Object o = new Object2();
+
+ parentContext.setContextValue(o);
+
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(1, parentContext.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
+
+ parentContext.setContextValue(o, "named");
+
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(2, parentContext.data.size());
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
+
+ parentContext.removeContextValue(Object2.class);
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(1, parentContext.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
+
+ parentContext.removeContextValue(Object2.class);
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(1, parentContext.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(o, ctxt.getContextValue(Object2.class, "named"));
+
+ ctxt.removeContextValue(Object2.class, "named");
+ Assert.assertEquals(0, ctxt.data.size());
+ Assert.assertEquals(0, parentContext.data.size());
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class));
+ Assert.assertEquals(null, ctxt.getContextValue(Object2.class, "named"));
+
+ }
+
+ private static class MyJAXXObject extends DefaultJAXXContext implements JAXXObject {
+
+ public Object getObjectById(String id) {
+ return null;
+ }
+
+ public Map<String, Object> get$objectMap() {
+ return null;
+ }
+
+ public void applyDataBinding(String id) {
+ }
+
+ public void removeDataBinding(String id) {
+ }
+
+ public JAXXContext getDelegateContext() {
+ return null;
+ }
+
+ public void processDataBinding(String dest) {
+ }
+
+ public void firePropertyChange(String name, Object oldValue, Object newValue) {
+ }
+
+ }
+}
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/context/DefaultJAXXContextTest.java
___________________________________________________________________
Added: svn:mergeinfo
+
Property changes on: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java
===================================================================
--- branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/tree/NavigationTreeModelTest.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-runtime/src/test/java/jaxx/runtime/swing/navigation/NavigationTreeModelTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,8 +1,11 @@
-package jaxx.runtime.swing.tree;
+package jaxx.runtime.swing.navigation;
-import jaxx.runtime.DefaultJAXXContext;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXContextEntryDef;
+import jaxx.runtime.swing.navigation.NavigationTreeNode;
+import jaxx.runtime.swing.navigation.NavigationTreeModel;
+import jaxx.runtime.swing.navigation.NavigationTreeModelBuilder;
+import jaxx.runtime.context.DefaultJAXXContext;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXContextEntryDef;
import org.junit.Assert;
import org.junit.Test;
@@ -82,7 +85,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
* as a bean.
* <p/>
* Tree is like this
@@ -202,7 +205,7 @@
}
/**
- * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.JAXXContext, String)} with an entry point
+ * Test the {@link NavigationTreeModel#getJAXXContextValue(jaxx.runtime.context.JAXXContext, String)} with an entry point
* as a list.
* <p/>
* Tree is like this
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/I18nEditor.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -30,19 +30,26 @@
<String id='selectedToolTipText' javaBean='null'/>
<String id='notSelectedToolTipText' javaBean='null'/>
+ <Border id='popupBorder' javaBean='new TitledBorder(_("i18neditor.popup.title"))'/>
+
<Boolean id='showText' javaBean='Boolean.TRUE'/>
<Boolean id='showIcon' javaBean='Boolean.TRUE'/>
+ <Boolean id='showPopupText' javaBean='Boolean.TRUE'/>
+ <Boolean id='showPopupIcon' javaBean='Boolean.TRUE'/>
<Boolean id='popupVisible' javaBean='Boolean.FALSE'/>
<java.util.List id='locales' javaBean='null' genericType='Locale'/>
<Locale id='selectedLocale' javaBean='Locale.getDefault()'/>
- <jaxx.runtime.swing.LocaleListCellRenderer id='renderer' javaBean='new LocaleListCellRenderer(showIcon , showText)' showIcon='{isShowIcon()}' showText='{isShowText()}'/>
+ <jaxx.runtime.swing.LocaleListCellRenderer id='renderer'
+ showIcon='{isShowIcon()}'
+ showText='{isShowText()}'
+ javaBean='new LocaleListCellRenderer(showIcon , showText)'/>
<!-- popup to change sorted property-->
<JPopupMenu id='popup'
- border='{new TitledBorder(_("i18neditor.popup.title"))}'
+ border='{getPopupBorder()}'
onPopupMenuWillBecomeInvisible='button.setSelected(false)'
onPopupMenuCanceled='button.setSelected(false)'>
<JLabel id='popupLabel' enabled='false' text='i18neditor.empty.locales'/>
@@ -74,6 +81,9 @@
public static final String SELECTED_LOCALE_PROPERTY = "selectedLocale";
public static final String SHOW_ICON_PROPERTY = "showIcon";
public static final String SHOW_TEXT_PROPERTY = "showText";
+public static final String SHOW_POPUP_ICON_PROPERTY = "showPopupIcon";
+public static final String SHOW_POPUP_TEXT_PROPERTY = "showPopupText";
+public static final String POPUP_BORDER_PROPERTY = "popupBorder";
public static final String POPUP_VISIBLE_PROPERTY = "popupVisible";
@Override
@@ -82,9 +92,8 @@
if (log.isDebugEnabled()) {
log.debug(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
}
- log.info(name+" <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
+ log.info(name + " <old:"+evt.getOldValue()+" - new:"+evt.getNewValue()+">");
if (LOCALES_PROPERTY.equals(name)) {
- Locale oldLocale = getSelectedLocale();
java.util.Collection<?> newLocales = (java.util.Collection<?>) evt.getNewValue();
// mise a jour de la popup
boolean oldShowText = renderer.isShowText();
@@ -94,8 +103,8 @@
for (Object o : newLocales) {
Locale l = (Locale) o;
boolean selected = l.equals(selectedLocale);
- String text = renderer.getText(l);
- Icon icon = renderer.getIcon(l);
+ String text = isShowPopupText() ? renderer.getText(l) : null;
+ Icon icon = isShowPopupIcon() ? renderer.getIcon(l) : null;
JRadioButtonMenuItem b = new JRadioButtonMenuItem(text, icon, selected);
popup.add(b);
b.addActionListener(this);
@@ -120,6 +129,18 @@
processDataBinding("button.text");
return;
}
+ if (SHOW_POPUP_ICON_PROPERTY.equals(name)) {
+ rebuildPopup();
+ return;
+ }
+ if (SHOW_POPUP_TEXT_PROPERTY.equals(name)) {
+ rebuildPopup();
+ return;
+ }
+ if (POPUP_BORDER_PROPERTY.equals(name)) {
+ popup.setBorder((Border)evt.getNewValue());
+ return;
+ }
if (POPUP_VISIBLE_PROPERTY.equals(name)) {
Boolean newValue = (Boolean) evt.getNewValue();
if (newValue == null || !newValue) {
@@ -165,6 +186,26 @@
setLocales(java.util.Arrays.asList(org.nuiton.i18n.I18n.getLoader().getLocales()));
}
+protected void rebuildPopup() {
+ log.debug("start rebuild");
+ try {
+ for (Component c : popup.getComponents()) {
+ if (c instanceof JRadioButtonMenuItem) {
+ JRadioButtonMenuItem b = (JRadioButtonMenuItem) c;
+ Locale l = (Locale) b.getClientProperty("locale");
+ String text = isShowPopupText() ? renderer.getSafeText(l) : null;
+ Icon icon = isShowPopupIcon() ? renderer.getSafeIcon(l) : null;
+ b.setIcon(icon);
+ b.setText(text);
+ log.debug("text=" + text);
+ log.debug("icon=" + icon);
+ }
+ }
+ } finally {
+ popup.invalidate();
+ }
+}
+
protected String getTip(Locale l) {
boolean selected = l.equals(selectedLocale);
String tip = selected ? getSelectedTip(l):getNotSelectedTip(l);
@@ -197,9 +238,10 @@
@Override
public void run() {
getPopup().pack();
+ JToggleButton invoker = getButton();
Dimension dim = getPopup().getPreferredSize();
- JToggleButton invoker = getButton();
- getPopup().show(invoker, (int) (invoker.getPreferredSize().getWidth() - dim.getWidth()), invoker.getHeight());
+ Dimension invokerDim = invoker.getSize();
+ getPopup().show(invoker, (int) (invokerDim.getWidth() - dim.getWidth()), invoker.getHeight());
// getPopup().setVisible(true);
}
};
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/java/jaxx/runtime/swing/editor/config/ConfigUIBuilder.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -32,8 +32,8 @@
import javax.swing.JOptionPane;
import javax.swing.JRootPane;
import javax.swing.KeyStroke;
-import jaxx.runtime.JAXXContext;
-import jaxx.runtime.JAXXInitialContext;
+import jaxx.runtime.context.JAXXContext;
+import jaxx.runtime.context.JAXXInitialContext;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.swing.editor.config.model.CategoryModel;
@@ -59,7 +59,7 @@
* @param defaultCategory la categorie a selectionner
* @return l'ui instanciate
*/
- public static ConfigUI newConfigUI(jaxx.runtime.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
+ public static ConfigUI newConfigUI(jaxx.runtime.context.JAXXContext parentContext, final ConfigUIModel model, String defaultCategory) {
JAXXContext tx = new JAXXInitialContext().add(parentContext).add(model);
final ConfigUI ui = new ConfigUI(tx);
Deleted: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-en_GB.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,70 +0,0 @@
-aboutframe.about=About
-aboutframe.license=License
-aboutframe.ok=OK
-aboutframe.thirdparty=Third party
-columnselector.action.tip=Select the columns
-config.action.quit=Quit
-config.action.quit.tip=Quit the configuration editor
-config.action.reset=Cancel
-config.action.reset.tip=Cancel the modifications for the category
-config.action.save=Save
-config.action.save.tip=Save the modifications for the category
-config.category.saved=The category '%1$s' was modified \:
-config.choice.cancel=Cancel
-config.choice.continue=Continue
-config.choice.doNotSave=Do not save
-config.choice.ok=Ok
-config.choice.save=Save
-config.defaultValue=Default value
-config.defaultValue.tip=Default value of the option
-config.descrition=Description
-config.error.category.already.exists=category with name '%1$s' does already exist\!
-config.error.category.not.found=category with name '%1$s' does not exist\!
-config.key=Key
-config.key.tip=Key of the option
-config.message.quit.invalid.category=The category '%1$s' is not valid\!
-config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
-config.modified=Option was modified (previous value \: %1$s)
-config.no.option.selected=< No selected option >
-config.option.final=This option can not be modified
-config.option.label=Option '%1$s' (%2$s)
-config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' >
-config.title=Preferences
-config.title.need.confirm=A confirmation is required
-config.title.will.reload.application=The application need to be restarted
-config.unmodifiable=Can not be modified
-config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
-config.value=Value
-config.value.tip=Value of the option
-entitycombobox.action.reset.tip=Reset the selected value
-entitycombobox.action.sort.tip=Change the sorted property
-entitycombobox.popup.label=Object '%1$s'
-entitycombobox.popup.title=Change the sorted property
-entitycombobox.sort.off=Click to activate the sort on this property
-entitycombobox.sort.on=This is the property actually used
-entitycombobox.unknown.type=Object of unkown type
-errorUI.action.close=Close
-errorUI.message=An error wad detected...
-errorUI.title=Error...
-i18neditor.empty.locales=< No locale to select >
-i18neditor.popup.title=Change language
-i18neditor.selected=Selected language \: %1$s
-i18neditor.unselected=Select this langage \: %1$s
-memorywidget.memory=%d/%dMb
-numbereditor..=.
-numbereditor.0=0
-numbereditor.1=1
-numbereditor.2=2
-numbereditor.3=3
-numbereditor.4=4
-numbereditor.5=5
-numbereditor.6=6
-numbereditor.7=7
-numbereditor.8=8
-numbereditor.9=9
-numbereditor.action.reset.tip=Reset
-numbereditor.action.show.tip=Show numeric panel
-numbereditor.clearAll=C
-numbereditor.clearOne=CE
-numbereditor.toggleSign=+/-
-timeeditor.H=H
Deleted: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-runtime-swing-widget-fr_FR.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,71 +0,0 @@
-aboutframe.about=\u00C0 propos
-aboutframe.license=Licence
-aboutframe.ok=OK
-aboutframe.thirdparty=Tierce partie
-columnselector.action.tip=S\u00E9lectionner les colonnes
-config.action.quit=Quitter
-config.action.quit.tip=Quitter l'\u00E9diteur de configuration
-config.action.reset=Annuler
-config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
-config.action.save=Enregistrer
-config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
-config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
-config.choice.cancel=Annuler
-config.choice.continue=Continuer
-config.choice.doNotSave=Ne pas enregistrer
-config.choice.ok=Ok
-config.choice.save=Enregistrer
-config.defaultValue=Valeur par d\u00E9faut
-config.defaultValue.tip=Valeur par d\u00E9faut de l'option
-config.descrition=Description
-config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\!
-config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\!
-config.key=Clef
-config.key.tip=Clef de l'option
-config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
-config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
-config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
-config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
-config.option.final=Option non modifiable
-config.option.label=Option '%1$s' (%2$s)
-config.option.modified=Valeur modifi\u00E9e < nouvelle valeur \: '%1$s' - ancienne valeur \: '%2$s' >
-config.option.valid=Valeur non valide
-config.title=Pr\u00E9f\u00E9rences
-config.title.need.confirm=Une confirmation de votre part est requise...
-config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
-config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
-config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
-config.value=Valeur
-config.value.tip=Valeur de l'option
-entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
-entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
-entitycombobox.popup.label=Objet '%1$s'
-entitycombobox.popup.title=Modifier le tri
-entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s'
-entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s'
-entitycombobox.unknown.type=Objet de type inconnu
-errorUI.action.close=Fermer
-errorUI.message=Une erreur est survenue \!
-errorUI.title=Erreur...
-i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
-i18neditor.popup.title=Changer de langue
-i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
-i18neditor.unselected=Pour utiliser cette langue \: %1$s
-memorywidget.memory=%d/%dMo
-numbereditor..=.
-numbereditor.0=0
-numbereditor.1=1
-numbereditor.2=2
-numbereditor.3=3
-numbereditor.4=4
-numbereditor.5=5
-numbereditor.6=6
-numbereditor.7=7
-numbereditor.8=8
-numbereditor.9=9
-numbereditor.action.reset.tip=R\u00E9initialiser
-numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
-numbereditor.clearAll=C
-numbereditor.clearOne=CE
-numbereditor.toggleSign=+/-
-timeeditor.H=H
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-en_GB.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,70 +1,70 @@
-aboutframe.about=
-aboutframe.license=
-aboutframe.ok=
-aboutframe.thirdparty=
-columnselector.action.tip=
-config.action.quit=
-config.action.quit.tip=
-config.action.reset=
-config.action.reset.tip=
-config.action.save=
-config.action.save.tip=
-config.category.saved=
-config.choice.cancel=
-config.choice.continue=
-config.choice.doNotSave=
-config.choice.ok=
-config.choice.save=
-config.defaultValue=
-config.defaultValue.tip=
-config.descrition=
-config.error.category.already.exists=
-config.error.category.not.found=
-config.key=
-config.key.tip=
-config.message.quit.invalid.category=
-config.message.quit.valid.and.modified.category=
-config.modified=
-config.no.option.selected=
-config.option.final=
-config.option.label=
-config.option.modified=
-config.title=
-config.title.need.confirm=
-config.title.will.reload.application=
-config.unmodifiable=
-config.unvalid=
-config.value=
-config.value.tip=
-entitycombobox.action.reset.tip=
-entitycombobox.action.sort.tip=
-entitycombobox.popup.label=
-entitycombobox.popup.title=
-entitycombobox.sort.off=
-entitycombobox.sort.on=
-entitycombobox.unknown.type=
-errorUI.action.close=
-errorUI.message=
-errorUI.title=
-i18neditor.empty.locales=
-i18neditor.popup.title=
-i18neditor.selected=
-i18neditor.unselected=
-memorywidget.memory=
-numbereditor..=
-numbereditor.0=
-numbereditor.1=
-numbereditor.2=
-numbereditor.3=
-numbereditor.4=
-numbereditor.5=
-numbereditor.6=
-numbereditor.7=
-numbereditor.8=
-numbereditor.9=
-numbereditor.action.reset.tip=
-numbereditor.action.show.tip=
-numbereditor.clearAll=
-numbereditor.clearOne=
-numbereditor.toggleSign=
-timeeditor.H=
+aboutframe.about=About
+aboutframe.license=License
+aboutframe.ok=OK
+aboutframe.thirdparty=Third party
+columnselector.action.tip=Select the columns
+config.action.quit=Quit
+config.action.quit.tip=Quit the configuration editor
+config.action.reset=Cancel
+config.action.reset.tip=Cancel the modifications for the category
+config.action.save=Save
+config.action.save.tip=Save the modifications for the category
+config.category.saved=The category '%1$s' was modified \:
+config.choice.cancel=Cancel
+config.choice.continue=Continue
+config.choice.doNotSave=Do not save
+config.choice.ok=Ok
+config.choice.save=Save
+config.defaultValue=Default value
+config.defaultValue.tip=Default value of the option
+config.descrition=Description
+config.error.category.already.exists=category with name '%1$s' does already exist\!
+config.error.category.not.found=category with name '%1$s' does not exist\!
+config.key=Key
+config.key.tip=Key of the option
+config.message.quit.invalid.category=The category '%1$s' is not valid\!
+config.message.quit.valid.and.modified.category=The category '%1$s' has some modified options \:
+config.modified=Option was modified (previous value \: %1$s)
+config.no.option.selected=< No selected option >
+config.option.final=This option can not be modified
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Value is modified < original value \: '%1$s' - new value \: '%2$s' >
+config.title=Preferences
+config.title.need.confirm=A confirmation is required
+config.title.will.reload.application=The application need to be restarted
+config.unmodifiable=Can not be modified
+config.unvalid=Option is not valid \! (previous value \: %1$s, required type \: %2$s)
+config.value=Value
+config.value.tip=Value of the option
+entitycombobox.action.reset.tip=Reset the selected value
+entitycombobox.action.sort.tip=Change the sorted property
+entitycombobox.popup.label=Object '%1$s'
+entitycombobox.popup.title=Change the sorted property
+entitycombobox.sort.off=Click to activate the sort on this property
+entitycombobox.sort.on=This is the property actually used
+entitycombobox.unknown.type=Object of unkown type
+errorUI.action.close=Close
+errorUI.message=An error wad detected...
+errorUI.title=Error...
+i18neditor.empty.locales=< No locale to select >
+i18neditor.popup.title=Change language
+i18neditor.selected=Selected language \: %1$s
+i18neditor.unselected=Select this langage \: %1$s
+memorywidget.memory=%d/%dMb
+numbereditor..=.
+numbereditor.0=0
+numbereditor.1=1
+numbereditor.2=2
+numbereditor.3=3
+numbereditor.4=4
+numbereditor.5=5
+numbereditor.6=6
+numbereditor.7=7
+numbereditor.8=8
+numbereditor.9=9
+numbereditor.action.reset.tip=Reset
+numbereditor.action.show.tip=Show numeric panel
+numbereditor.clearAll=C
+numbereditor.clearOne=CE
+numbereditor.toggleSign=+/-
+timeeditor.H=H
Modified: branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties
===================================================================
--- branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/jaxx-widgets/src/main/resources/i18n/jaxx-widgets-fr_FR.properties 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,70 +1,71 @@
-aboutframe.about=
-aboutframe.license=
-aboutframe.ok=
-aboutframe.thirdparty=
-columnselector.action.tip=
-config.action.quit=
-config.action.quit.tip=
-config.action.reset=
-config.action.reset.tip=
-config.action.save=
-config.action.save.tip=
-config.category.saved=
-config.choice.cancel=
-config.choice.continue=
-config.choice.doNotSave=
-config.choice.ok=
-config.choice.save=
-config.defaultValue=
-config.defaultValue.tip=
-config.descrition=
-config.error.category.already.exists=
-config.error.category.not.found=
-config.key=
-config.key.tip=
-config.message.quit.invalid.category=
-config.message.quit.valid.and.modified.category=
-config.modified=
-config.no.option.selected=
-config.option.final=
-config.option.label=
-config.option.modified=
-config.title=
-config.title.need.confirm=
-config.title.will.reload.application=
-config.unmodifiable=
-config.unvalid=
-config.value=
-config.value.tip=
-entitycombobox.action.reset.tip=
-entitycombobox.action.sort.tip=
-entitycombobox.popup.label=
-entitycombobox.popup.title=
-entitycombobox.sort.off=
-entitycombobox.sort.on=
-entitycombobox.unknown.type=
-errorUI.action.close=
-errorUI.message=
-errorUI.title=
-i18neditor.empty.locales=
-i18neditor.popup.title=
-i18neditor.selected=
-i18neditor.unselected=
-memorywidget.memory=
-numbereditor..=
-numbereditor.0=
-numbereditor.1=
-numbereditor.2=
-numbereditor.3=
-numbereditor.4=
-numbereditor.5=
-numbereditor.6=
-numbereditor.7=
-numbereditor.8=
-numbereditor.9=
-numbereditor.action.reset.tip=
-numbereditor.action.show.tip=
-numbereditor.clearAll=
-numbereditor.clearOne=
-numbereditor.toggleSign=
-timeeditor.H=
+aboutframe.about=\u00C0 propos
+aboutframe.license=Licence
+aboutframe.ok=OK
+aboutframe.thirdparty=Tierce partie
+columnselector.action.tip=S\u00E9lectionner les colonnes
+config.action.quit=Quitter
+config.action.quit.tip=Quitter l'\u00E9diteur de configuration
+config.action.reset=Annuler
+config.action.reset.tip=Annuler les modifications de cette cat\u00E9gorie
+config.action.save=Enregistrer
+config.action.save.tip=Sauver les modifications de cette cat\u00E9gorie
+config.category.saved=La cat\u00E9gorie '%1$s' a \u00E9t\u00E9 modifi\u00E9e \:
+config.choice.cancel=Annuler
+config.choice.continue=Continuer
+config.choice.doNotSave=Ne pas enregistrer
+config.choice.ok=Ok
+config.choice.save=Enregistrer
+config.defaultValue=Valeur par d\u00E9faut
+config.defaultValue.tip=Valeur par d\u00E9faut de l'option
+config.descrition=Description
+config.error.category.already.exists=La cat\u00E9gorie de nom '%1$s' existe d\u00E9j\u00E0\!
+config.error.category.not.found=La cat\u00E9gorie de nom '%1$s' n'existe pas\!
+config.key=Clef
+config.key.tip=Clef de l'option
+config.message.quit.invalid.category=La cat\u00E9gorie '%1$s' n'est pas valide\!
+config.message.quit.valid.and.modified.category=La cat\u00E9gorie '%1$s' poss\u00E8dent des options modifi\u00E9es \:
+config.modified=Option modifi\u00E9e (valeur originale \: %1$s)
+config.no.option.selected=< Pas d'option s\u00E9lectionn\u00E9e >
+config.option.final=Option non modifiable
+config.option.label=Option '%1$s' (%2$s)
+config.option.modified=Valeur modifi\u00E9e < nouvelle valeur \: '%1$s' - ancienne valeur \: '%2$s' >
+config.option.valid=Valeur non valide
+config.title=Pr\u00E9f\u00E9rences
+config.title.need.confirm=Une confirmation de votre part est requise...
+config.title.will.reload.application=L'application doit \u00EAtre red\u00E9marrer...
+config.unmodifiable=Ne peut pas \u00EAtre modifi\u00E9
+config.unvalid=Option non valide (valeur originale \: %1$s, type requis \: %2$s)
+config.value=Valeur
+config.value.tip=Valeur de l'option
+entitycombobox.action.reset.tip=R\u00E9initialiser la valeur de la liste d\u00E9roulante
+entitycombobox.action.sort.tip=Modifier le tri de la liste d\u00E9roulante
+entitycombobox.popup.label=Objet '%1$s'
+entitycombobox.popup.title=Modifier le tri
+entitycombobox.sort.off=Cliquer pour activer le tri sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.sort.on=Le tri est effectu\u00E9 sur la propri\u00E9t\u00E9 '%1$s'
+entitycombobox.unknown.type=Objet de type inconnu
+errorUI.action.close=Fermer
+errorUI.message=Une erreur est survenue \!
+errorUI.title=Erreur...
+i18neditor.empty.locales=< Aucune locale \u00E0 s\u00E9lectionner >
+i18neditor.popup.title=Changer de langue
+i18neditor.selected=Langue actuellement utilis\u00E9e \: %1$s
+i18neditor.unselected=Pour utiliser cette langue \: %1$s
+memorywidget.memory=%d/%dMo
+numbereditor..=.
+numbereditor.0=0
+numbereditor.1=1
+numbereditor.2=2
+numbereditor.3=3
+numbereditor.4=4
+numbereditor.5=5
+numbereditor.6=6
+numbereditor.7=7
+numbereditor.8=8
+numbereditor.9=9
+numbereditor.action.reset.tip=R\u00E9initialiser
+numbereditor.action.show.tip=Afficher le pav\u00E9 num\u00E9rique
+numbereditor.clearAll=C
+numbereditor.clearOne=CE
+numbereditor.toggleSign=+/-
+timeeditor.H=H
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/AbstractJaxxMojo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -117,7 +117,9 @@
* @since 1.3
*/
protected String helpsetIndexI18nSuffix;
- protected boolean skip;
+ /**
+ *
+ */
protected ClassLoader cl;
@Override
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxGeneratorMojo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -18,35 +18,39 @@
*##%*/
package org.nuiton.jaxx.plugin;
-import jaxx.beaninfos.BeanInfoUtil;
-import jaxx.compiler.CompilerOptions;
+import jaxx.compiler.CompilerConfiguration;
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.runtime.JAXXContext;
-import jaxx.tags.TagManager;
+import jaxx.compiler.beans.BeanInfoUtil;
+import jaxx.compiler.decorators.CompiledObjectDecorator;
+import jaxx.compiler.decorators.HelpRootCompiledObjectDecorator;
+import jaxx.compiler.tags.TagManager;
+import jaxx.runtime.context.JAXXContext;
+
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.model.Resource;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
-import org.codehaus.plexus.util.DirectoryScanner;
+import org.apache.maven.project.MavenProject;
+import org.nuiton.io.FileUpdaterHelper;
+import org.nuiton.io.MirroredFileUpdater;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
-import java.lang.reflect.Modifier;
import java.net.MalformedURLException;
+import java.util.Map;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
import java.util.Properties;
import java.util.Set;
-import jaxx.compiler.CompiledObjectDecorator;
-import jaxx.compiler.HelpRootCompiledObjectDecorator;
-import org.apache.maven.artifact.Artifact;
-import org.apache.maven.model.Resource;
-import org.apache.maven.project.MavenProject;
-import org.nuiton.io.FileUpdaterHelper;
-import org.nuiton.io.MirroredFileUpdater;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
/**
* Classe permettant de transformer des sources jaxx vers du source java.
@@ -57,62 +61,72 @@
* @requiresDependencyResolution compile
* @requiresProject
*/
-public class JaxxGeneratorMojo extends AbstractJaxxMojo {
+public class JaxxGeneratorMojo extends AbstractJaxxMojo implements CompilerConfiguration {
/**
- * Le compilateur à utiliser (par défaut celui de Swing)
- *
- * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.SwingCompiler"
+ * Default includes to use, if none provided
*/
- protected String compilerFQN;
+ private static final String[] INCLUDES = {"**\\/*.jaxx"};
/**
- * Le compilateur à utiliser (par défaut celui de Swing)
+ * Repertoire sources des fichiers jaxx a generer.
*
- * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
+ * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
*/
- protected String validatorFQN;
+ protected File src;
/**
- * chemin du repertoire de generation des resources.
+ * pour filter les fichiers a traiter
*
- * @parameter expression="${jaxx.outResource}" default-value="${basedir}/target/generated-sources/resources"
+ * @parameter expression="${jaxx.includes}"
*/
- protected File outResource;
+ protected String[] includes;
/**
- * chemin du repertoire de compilation des resources.
+ * pour filter les fichiers a ne pas traiter
*
- * @parameter expression="${jaxx.outClass}" default-value="${basedir}/target/classes"
+ * @parameter expression="${jaxx.excludes}"
*/
- protected File outClass;
+ protected String[] excludes;
/**
- * Repertoire sources des fichiers jaxx a generer.
+ * Le compilateur à utiliser (par défaut celui de Swing)
*
- * @parameter expression="${jaxx.src}" default-value="${maven.src.dir}/main/java"
+ * @parameter expression="${jaxx.compilerFQN}" default-value="jaxx.compiler.JAXXCompiler"
*/
- protected File src;
+ protected String compilerFQN;
/**
- * pour optimizer le code compile ou genere ?
+ * Le compilateur à utiliser (par défaut celui de Swing)
*
- * @parameter expression="${jaxx.optimize}" default-value="false"
+ * @parameter expression="${jaxx.validatorFQN}" default-value="jaxx.runtime.validator.swing.SwingValidator"
*/
- protected boolean optimize;
+ protected String validatorFQN;
/**
- * les options de la compilation
+ * the name of implementation of {@link jaxx.runtime.context.JAXXContext}
+ * to be used on {@link jaxx.runtime.JAXXObject}.
+ * <p/>
+ * Must not be abstract.
*
- * @parameter expression="${jaxx.javaOpts}"
+ * @parameter expression="${jaxx.jaxxContextFQN}" default-value="jaxx.runtime.context.DefaultJAXXContext"
+ * @required
*/
- protected String javaOpts = null;
+ protected String jaxxContextFQN;
/**
- * pour filter les fichiers a traiter
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
*
- * @parameter expression="${jaxx.includes}"
+ * @parameter expression="${jaxx.defaultErrorUIFQN}"
+ *
+ * @see jaxx.runtime.validator.swing.SwingValidator
*/
- protected String[] includes;
+ protected String defaultErrorUIFQN;
/**
- * pour filter les fichiers a ne pas traiter
+ * the FQN of the ui to use for error notification.
+ * <p/>
+ * If not given, will use the one defined in validator
*
- * @parameter expression="${jaxx.excludes}"
+ * @parameter expression="${jaxx.defaultDecoratorFQN}" default-value="jaxx.compiler.decorators.DefaultCompiledObjectDecorator"
+ *
+ * @see jaxx.compiler.CompiledObjectDecorator
*/
- protected String[] excludes;
+ protected String defaultDecoratorFQN;
/**
* flag to include in compiler classpath the java sources directories (src and outJava).
* <p/>
@@ -156,6 +170,19 @@
*/
protected boolean force;
/**
+ * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
+ *
+ * @parameter expression="${jaxx.testPhase}" default-value="false"
+ * @since 1.6.0
+ */
+ protected boolean testPhase;
+ /**
+ * pour optimizer le code compile ou genere ?
+ *
+ * @parameter expression="${jaxx.optimize}" default-value="false"
+ */
+ protected boolean optimize;
+ /**
* flag to add logger to each generated jaxx file.
* <p/>
* By default, always add it.
@@ -172,16 +199,6 @@
*/
protected boolean resetAfterCompile;
/**
- * the name of implementation of {@link jaxx.runtime.JAXXContext}
- * to be used on {@link jaxx.runtime.JAXXObject}.
- * <p/>
- * Must not be abstract.
- *
- * @parameter expression="${jaxx.jaxxContextImplementorClass}" default-value="jaxx.runtime.DefaultJAXXContext"
- * @required
- */
- protected String jaxxContextImplementorClass;
- /**
* extra path to be added in {@link java.beans.Introspector#setBeanInfoSearchPath(java.lang.String[])}.
* <p/>
* add beanInfoSearchPath to be registred by {@link BeanInfoUtil#addJaxxBeanInfoPath(java.lang.String[])}
@@ -197,39 +214,10 @@
/**
* list of fqn of class toimport for all generated jaxx files
*
- * @parameter expression="${jaxx.extraImports}"
- *
- * @deprecated Prefer use of extraImportList as a string, so
- * could be use in properties section.
- */
- protected String[] extraImports;
- /**
- * list of fqn of class toimport for all generated jaxx files
- *
* @parameter expression="${jaxx.extraImportList}"
*/
protected String extraImportList;
/**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultErrorUIFQN}"
- *
- * @see jaxx.runtime.validator.swing.SwingValidator
- */
- protected String defaultErrorUIFQN;
- /**
- * the FQN of the ui to use for error notification.
- * <p/>
- * If not given, will use the one defined in validator
- *
- * @parameter expression="${jaxx.defaultDecorator}" default-value="jaxx.compiler.DefaultCompiledObjectDecorator"
- *
- * @see jaxx.compiler.CompiledObjectDecorator
- */
- protected String defaultDecoratorFQN;
- /**
* a flag to use UIManager to retreave icons.
*
* @parameter expression="${jaxx.useUIManagerForIcon}" default-value="false"
@@ -264,27 +252,41 @@
*/
protected String helpBrokerFQN;
/**
- * A flag to mark themojo to be used in a test phase. This will permits to add generated sources in test compile roots.
*
- * @parameter expression="${jaxx.testPhase}" default-value="false"
- * @since 1.6.0
*/
- protected boolean testPhase;
protected String[] files;
- private static final String[] INCLUDES = {"**\\/*.jaxx"};
- protected CompilerOptions options;
+ /**
+ *
+ */
protected MirroredFileUpdater updater;
+ /**
+ *
+ */
private Class<?> defaultErrorUIClass;
+ /**
+ *
+ */
private Class<?> validatorClass;
+ /**
+ *
+ */
private Class<? extends CompiledObjectDecorator> defaultDecoratorClass;
+ /**
+ *
+ */
+ private Class<? extends JAXXContext> jaxxContextClass;
+ /**
+ *
+ */
private Class<? extends JAXXCompiler> compilerClass;
+ /**
+ *
+ */
+ private String[] extraImports;
@SuppressWarnings("unchecked")
@Override
public boolean init() throws Exception {
- if (skip) {
- return true;
- }
if (generateHelp) {
// check there is some bundle
@@ -292,24 +294,7 @@
throw new MojoFailureException("you must set the helpIdStore property.");
}
}
- skip = false;
- checkJaxxContextImplementorClass();
-
- if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
- // register extra path
- BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
- }
- if (!outResource.exists()) {
- outResource.mkdirs();
- }
-
- if (!outJava.exists()) {
- outJava.mkdirs();
- }
-
- fixCompileSourceRoots();
-
if (addSourcesToClassPath || addProjectClassPath) {
cl = initClassLoader(project, getLog());
Thread.currentThread().setContextClassLoader(cl);
@@ -318,55 +303,44 @@
//cl = Thread.currentThread().getContextClassLoader();
}
-
compilerClass = (Class<? extends JAXXCompiler>) Class.forName(compilerFQN, false, cl);
defaultDecoratorClass = (Class<? extends CompiledObjectDecorator>) Class.forName(defaultDecoratorFQN, false, cl);
-
- // check the validator class is correct
+ jaxxContextClass = (Class<? extends JAXXContext>) Class.forName(jaxxContextFQN, false, cl);
+ if (!JAXXContext.class.isAssignableFrom(jaxxContextClass)) {
+ throw new MojoExecutionException("jaxxContextFQN must be an implementation of " + JAXXContext.class + " but was : " + jaxxContextClass);
+ }
validatorClass = Class.forName(validatorFQN, false, cl);
if (defaultErrorUIFQN != null && !defaultErrorUIFQN.trim().isEmpty()) {
defaultErrorUIClass = Class.forName(defaultErrorUIFQN, false, cl);
}
- DirectoryScanner ds;
- ds = new DirectoryScanner();
- ds.setBasedir(src);
- boolean noIncludes = includes == null || includes.length == 0;
- ds.setIncludes(noIncludes ? INCLUDES : includes);
+ if (beanInfoSearchPath != null && beanInfoSearchPath.length > 0) {
+ // register extra path
+ BeanInfoUtil.addJaxxBeanInfoPath(beanInfoSearchPath);
+ }
- if (excludes != null && excludes.length > 0) {
- ds.setExcludes(excludes);
+ if (!outJava.exists()) {
+ outJava.mkdirs();
}
- ds.scan();
- String[] filesFind = ds.getIncludedFiles();
- if (verbose) {
- getLog().info("jaxx - discover " + filesFind.length + " jaxx file(s). ");
+ fixCompileSourceRoots();
+
+ boolean noIncludes = includes == null || includes.length == 0;
+
+ if (noIncludes) {
+ includes = INCLUDES;
}
-
updater = FileUpdaterHelper.newJaxxFileUpdater(src, outJava);
- if (force) {
- // we will regenerate all files
- this.files = filesFind;
- } else {
- // filter files
- List<String> listFiles = new ArrayList<String>();
+ Map<File, String[]> result = new HashMap<File, String[]>();
+ getFilesToTreateForRoots(includes, excludes, Arrays.asList(src.getAbsolutePath()), result, force ? null : updater);
- for (String file : filesFind) {
- if (updater.isFileUpToDate(new File(src, file))) {
- if (verbose) {
- getLog().info("jaxx - skip file [" + file + "].");
- }
- } else {
- if (verbose) {
- getLog().info("jaxx - detect modify file [" + file + "].");
- }
- listFiles.add(file);
- }
- }
- this.files = listFiles.toArray(new String[listFiles.size()]);
+ this.files = result.get(src);
+
+ if (files == null || files.length == 0) {
+ getLog().warn("No files to treate.");
+ return false;
}
if (extraImportList != null && !extraImportList.isEmpty()) {
@@ -379,9 +353,7 @@
getLog().info("extra imports " + java.util.Arrays.toString(imports));
}
extraImports = imports;
-
}
- options = toCompilerOptions();
if (verbose) {
printInit();
@@ -391,12 +363,7 @@
@Override
public void doAction() throws MojoExecutionException {
- if (skip) {
- if (verbose) {
- getLog().info("jaxx - skip!");
- }
- return;
- }
+
getLog().info("jaxx - detects " + this.files.length + " modify jaxx file(s). ");
try {
@@ -404,7 +371,7 @@
// force compiler init from here, not in a static block
TagManager.reset(verbose);
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, options);
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.newLaunchor(src, files, this);
boolean success = launchor.compile();
getLog().info("jaxx - generate " + launchor.getCompilerCount() + " file(s). ");
@@ -432,43 +399,121 @@
}
}
- public CompilerOptions toCompilerOptions() {
- CompilerOptions result = new CompilerOptions();
- result.setClassPath(src.getPath());
- if (javaOpts != null && !"".equals(javaOpts)) {
- result.setJavacOpts(javaOpts);
- }
- result.setCompilerClass(compilerClass);
- result.setValidatorFQN(validatorFQN);
- result.setValidatorClass(validatorClass);
- result.setKeepJavaFiles(true);
- result.setOptimize(optimize);
- result.setJavacTargetDirectory(outClass);
- result.setTargetDirectory(outJava);
- result.setVerbose(verbose);
- result.setI18nable(i18nable);
- result.setAddLogger(addLogger);
- result.setProfile(profile);
- result.setResetAfterCompile(resetAfterCompile);
- result.setJaxxContextImplementorClass(jaxxContextImplementorClass);
- result.setExtraImports(extraImports);
- result.setDefaultErrorUI(defaultErrorUIClass);
- result.setUseUIManagerForIcon(useUIManagerForIcon);
- result.setDefaultDecoratorClass(defaultDecoratorClass);
- result.setGenerateHelp(generateHelp);
- result.setHelpBrokerFQN(helpBrokerFQN);
- result.setHelpsetTitleI18nSuffix(helpsetTitleI18nSuffix);
- result.setHelpsetIndexI18nSuffix(helpsetIndexI18nSuffix);
- result.setHelpsetTocI18nSuffix(helpsetTocI18nSuffix);
- result.setHelpSetName(helpSetName);
- result.setHelpsetI18nPrefix(helpsetI18nPrefix);
+ @Override
+ public File getTargetDirectory() {
+ return outJava;
+ }
- if (cl != null) {
- result.setClassLoader(cl);
- }
- return result;
+ @Override
+ public boolean getOptimize() {
+ return optimize;
}
+ @Override
+ public boolean isI18nable() {
+ return i18nable;
+ }
+
+ @Override
+ public boolean isUseUIManagerForIcon() {
+ return useUIManagerForIcon;
+ }
+
+ @Override
+ public boolean isAddLogger() {
+ return addLogger;
+ }
+
+ @Override
+ public Class<? extends JAXXContext> getJaxxContextClass() {
+ return jaxxContextClass;
+ }
+
+ @Override
+ public String[] getExtraImports() {
+ return extraImports;
+ }
+
+ @Override
+ public boolean isResetAfterCompile() {
+ return resetAfterCompile;
+ }
+
+ @Override
+ public boolean isOptimize() {
+ return optimize;
+ }
+
+ @Override
+ public Class<?> getDefaultErrorUI() {
+ return defaultErrorUIClass;
+ }
+
+ @Override
+ public ClassLoader getClassLoader() {
+ return cl;
+ }
+
+ @Override
+ public Class<? extends JAXXCompiler> getCompilerClass() {
+ return compilerClass;
+ }
+
+ @Override
+ public Class<? extends CompiledObjectDecorator> getDefaultDecoratorClass() {
+ return defaultDecoratorClass;
+ }
+
+ @Override
+ public boolean isProfile() {
+ return profile;
+ }
+
+ @Override
+ public boolean isGenerateHelp() {
+ return generateHelp;
+ }
+
+ @Override
+ public String getHelpBrokerFQN() {
+ return helpBrokerFQN;
+ }
+
+ @Override
+ public String getHelpsetIndexI18nSuffix() {
+ return helpsetIndexI18nSuffix;
+ }
+
+ @Override
+ public String getHelpsetTitleI18nSuffix() {
+ return helpsetTitleI18nSuffix;
+ }
+
+ @Override
+ public String getHelpsetTocI18nSuffix() {
+ return helpsetTocI18nSuffix;
+ }
+
+ @Override
+ public String getHelpSetName() {
+ return helpSetName;
+ }
+
+ @Override
+ public String getHelpsetI18nPrefix() {
+ return helpsetI18nPrefix;
+ }
+
+ @Override
+ public Class<?> getValidatorClass() {
+ return validatorClass;
+ }
+
+ @Override
+ public String toString() {
+ return ToStringBuilder.reflectionToString(this, ToStringStyle.MULTI_LINE_STYLE);
+ }
+
protected void fixCompileSourceRoots() {
if (project == null) {
// no project defined, can not fix anything
@@ -491,7 +536,7 @@
}
protected void printInit() {
- getLog().info(options.toString());
+ getLog().info(toString());
getLog().info("includes : " + Arrays.toString(includes));
for (String file : files) {
getLog().info("will generate " + file);
@@ -514,24 +559,6 @@
}
}
- protected void checkJaxxContextImplementorClass() {
- if (jaxxContextImplementorClass == null) {
- throw new IllegalArgumentException("jaxxContextImplementor can not be null");
- }
- try {
- Class<?> jaxxContextImplementor = Class.forName(jaxxContextImplementorClass);
- if (!JAXXContext.class.isAssignableFrom(jaxxContextImplementor)) {
- throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' does not implements " + JAXXContext.class);
- }
- if (Modifier.isAbstract(jaxxContextImplementor.getModifiers())) {
- throw new IllegalArgumentException("jaxxContextImplementor '" + jaxxContextImplementor + "' can not be abstract.");
-
- }
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException("could not find jaxxContextImplementor class : " + jaxxContextImplementorClass);
- }
- }
-
protected void generateHelp() throws IOException {
Set<String> helpIds = HelpRootCompiledObjectDecorator.getHelpIds();
if (helpIds.isEmpty()) {
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/main/java/org/nuiton/jaxx/plugin/JaxxHelpGeneratorMojo.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -209,12 +209,7 @@
@Override
public boolean init() throws Exception {
- if (skip) {
- return true;
- }
-
if (!helpIdStore.exists()) {
- skip = true;
getLog().info("no helpIdStore to react at " + helpIdStore);
return false;
}
@@ -239,7 +234,6 @@
target.mkdirs();
}
-
helpIds = new SortedProperties();
InputStream stream = new FileInputStream(helpIdStore);
@@ -252,24 +246,15 @@
// no ids detected
getLog().warn("no helpIds detected, will skip.");
- skip = true;
return false;
}
- skip = false;
return true;
}
@Override
public void doAction() throws Exception {
- if (skip) {
- if (verbose) {
- getLog().info("jaxx - skip!");
- }
- return;
- }
-
if (i18nable) {
List<URL> lUrls = new java.util.ArrayList<URL>();
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Bug1750Test.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,6 @@
package org.nuiton.jaxx.plugin;
-import jaxx.Base64Coder;
+import jaxx.runtime.Base64Coder;
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerLaunchor;
import jaxx.runtime.JAXXObjectDescriptor;
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/CompilerTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -2,8 +2,7 @@
import jaxx.compiler.JAXXCompiler;
import jaxx.compiler.JAXXCompilerLaunchor;
-import jaxx.runtime.DefaultJAXXContext;
-import jaxx.runtime.JAXXContext;
+import jaxx.runtime.context.DefaultJAXXContext;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.logging.SystemStreamLog;
@@ -162,31 +161,31 @@
@Test
public void ErrorJaxxContextImplementorClass() throws Exception {
JaxxGeneratorMojo mojo = getMojo();
- mojo.jaxxContextImplementorClass = null;
+ mojo.jaxxContextFQN = null;
try {
mojo.init();
fail();
- } catch (IllegalArgumentException e) {
+ } catch (NullPointerException e) {
assertTrue(true);
}
- mojo.jaxxContextImplementorClass = String.class.getName();
+ mojo.jaxxContextFQN = String.class.getName();
try {
mojo.init();
fail();
- } catch (IllegalArgumentException e) {
+ } catch (MojoExecutionException e) {
assertTrue(true);
}
+//
+// mojo.jaxxContextFQN = JAXXContext.class.getName();
+// try {
+// mojo.init();
+// fail();
+// } catch (IllegalArgumentException e) {
+// assertTrue(true);
+// }
- mojo.jaxxContextImplementorClass = JAXXContext.class.getName();
- try {
- mojo.init();
- fail();
- } catch (IllegalArgumentException e) {
- assertTrue(true);
- }
-
- mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName();
+ mojo.jaxxContextFQN = DefaultJAXXContext.class.getName();
mojo.init();
assertTrue(true);
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/JaxxBaseTest.java 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,6 +1,6 @@
package org.nuiton.jaxx.plugin;
-import jaxx.runtime.DefaultJAXXContext;
+import jaxx.runtime.context.DefaultJAXXContext;
import org.nuiton.util.FileUtil;
import java.io.File;
@@ -8,7 +8,8 @@
import org.nuiton.plugin.AbstractMojoTest;
import static org.junit.Assert.*;
-/** Base test case for a jaxx:generate goal.
+/**
+ * Base test case for a jaxx:generate goal.
*
* Use {@link AbstractMojoTest} from {@code maven-helper-plugin}.
*
@@ -26,10 +27,10 @@
@Override
protected void setUpMojo(JaxxGeneratorMojo mojo, File pomFile) throws Exception {
super.setUpMojo(mojo, pomFile);
- mojo.jaxxContextImplementorClass = DefaultJAXXContext.class.getName();
- mojo.compilerFQN = jaxx.compiler.SwingCompiler.class.getName();
+ mojo.jaxxContextFQN = DefaultJAXXContext.class.getName();
+ mojo.compilerFQN = jaxx.compiler.JAXXCompiler.class.getName();
mojo.validatorFQN = jaxx.runtime.validator.swing.SwingValidator.class.getName();
- mojo.defaultDecoratorFQN = jaxx.compiler.DefaultCompiledObjectDecorator.class.getName();
+ mojo.defaultDecoratorFQN = jaxx.compiler.decorators.DefaultCompiledObjectDecorator.class.getName();
}
protected void checkPattern(JaxxGeneratorMojo mojo, String pattern, boolean required, String... files) throws IOException {
@@ -52,6 +53,10 @@
}
protected void assertNumberJaxxFiles(int expectedNbFiles) {
- assertEquals(expectedNbFiles, getMojo().files.length);
+ if (expectedNbFiles == 0) {
+ assertTrue(getMojo().files == null || getMojo().files.length == 0);
+ } else {
+ assertEquals(expectedNbFiles, getMojo().files.length);
+ }
}
}
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1722Test/Bug_1722.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1750Test/Bug_1750.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<resetAfterCompile>false</resetAfterCompile>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Bug1751Test/Bug_1751.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<i18nable>true</i18nable>
<force>true</force>
<verbose>true</verbose>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/CSSTests.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>false</i18nable>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClassReferences.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/ClassReferences/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ClientProperty.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>false</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/ErrorJaxxContextImplementorClass.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,8 +14,8 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
- <jaxxContextImplementorClass>java.lang.String</jaxxContextImplementorClass>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
+ <jaxxContextFQN>java.lang.String</jaxxContextFQN>
<force>true</force>
</configuration>
</plugin>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Errors.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/errors/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Force.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/force/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Icon.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<i18nable>false</i18nable>
<force>true</force>
<verbose>true</verbose>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Initializers.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/Initializers/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/InnerClasses.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/InnerClasses/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/NoLog.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>false</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/OverridingDataBindings.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/OverridingDataBindings/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/Script.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/Script/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/CompilerTest/SpecialSubclassing/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/WithLog.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>true</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemDuplicateValues.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,8 +1,8 @@
-<JList>
+<JAXXList>
<item value='1'/>
<item value='2'/>
<item value='2'/>
<item value='3'/>
<item value='3'/>
<item value='3'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/errors/ItemNoValue.jaxx 2009-10-07 14:22:07 UTC (rev 1562)
@@ -1,4 +1,4 @@
-<JList>
+<JAXXList>
<item label='This item doesn&t have a value'/>
<item label='Neither does this one'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorErrors.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -15,7 +15,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerValidatorTest/ValidatorOk.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/DecoratorTest/Decorator.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<addLogger>false</addLogger>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<verbose>true</verbose>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<includes>
<value>**/Evolution74Test/ok/*.jaxx</value>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nText.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nTitle.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/I18nTest/I18nToolTipText.xml 2009-10-07 14:22:07 UTC (rev 1562)
@@ -14,7 +14,7 @@
<configuration>
<src>${basedir}/target/test-classes</src>
<outJava>${basedir}/target/it-generated-sources/java</outJava>
- <outResource>${basedir}/target/it-generated-sources/resources</outResource>
+ <!--outResource>${basedir}/target/it-generated-sources/resources</outResource-->
<force>true</force>
<i18nable>true</i18nable>
<includes>
Modified: branches/jaxx-2.X/src/site/rst/JAXXContext.rst
===================================================================
--- branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-06 04:59:00 UTC (rev 1561)
+++ branches/jaxx-2.X/src/site/rst/JAXXContext.rst 2009-10-07 14:22:07 UTC (rev 1562)
@@ -13,7 +13,7 @@
Le besoin initial de ce développement est de pouvoir facilement intégrer un context applicatif dans JAXX et de pouvoir
l'utiliser dans les fichiers JAXX pour injecter par exemple des données dans les widgets.
-jaxx.runtime.JAXXContext
+jaxx.runtime.context.JAXXContext
========================
Il s'agit du contrat de base du context applicatif.
@@ -32,7 +32,7 @@
Le nom qui est facultatif permet de pouvoir distinguer plusieurs données d'un même type dans le context. Si le nom
n'est pas utilisé pour caractériser une données on fixera alors sa valeur à *null*.
-Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.JAXXContextEntryDef*.
+Afin de pouvoir caractériser les entrées dans le context, une classe a été définie *jaxx.runtime.context.JAXXContextEntryDef*.
Les méthodes de lecture
***********************
@@ -87,7 +87,7 @@
Cette entrée spéciale ne sera pas stockée avec les autres entrées afin d'optimiser les algorithmes d'injection et de
restitution.
-jaxx.runtime.JAXXInitialContext
+jaxx.runtime.context.JAXXInitialContext
*******************************
On a implanté un second type de context qui lui peut servir à l'initialisation des JAXXObject.
1
0
Author: tchemit
Date: 2009-10-06 06:59:00 +0200 (Tue, 06 Oct 2009)
New Revision: 1561
Added:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx
Removed:
branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/
Modified:
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java
branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.jaxx
branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.jaxx
Log:
[Evolution #74] : pouvoir generer les classes swing (JComboBox, JList,...)
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/SwingInitializer.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -39,38 +39,47 @@
// TagManager.registerTag("java.awt.*", "ButtonGroup", new DefaultObjectHandler(ClassDescriptorLoader.getClassDescriptor(JAXXButtonGroup.class)));
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(Application.class), ApplicationHandler.class);
+
+ // check boxes
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBox.class), JCheckBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JCheckBoxMenuItem.class), JCheckBoxHandler.class);
- //TC-20091005 : JAXXComboBox and JComboBox are not the same
-// TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JComboBoxHandler.class);
-// TagManager.registerTag("javax.swing.*", "JComboBox", new JComboBoxHandler(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class)));
+
+ // combo boxes
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JComboBox.class), JComboBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(EnumEditor.class), JComboBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(LocaleEditor.class), JComboBoxHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXComboBox.class), JAXXComboBoxHandler.class);
+ // radio boxes
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
+
+ // Lists
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JList.class), JListHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JAXXListHandler.class);
+
+ // Trees
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTree.class), JTreeHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JAXXTreeHandler.class);
+
+ // Windows
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JDialog.class), JWindowHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JFrame.class), JWindowHandler.class);
+ TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
+
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JInternalFrame.class), JInternalFrameHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXList.class), JListHandler.class);
- TagManager.registerTag("javax.swing.*", "JList", new JListHandler(ClassDescriptorLoader.getClassDescriptor(JAXXList.class)));
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JMenu.class), JMenuHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPasswordField.class), JPasswordFieldHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JPopupMenu.class), JPopupMenuHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JProgressBar.class), JProgressBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButton.class), JRadioButtonHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JRadioButtonMenuItem.class), JRadioButtonHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JScrollPane.class), JScrollPaneHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSlider.class), JSliderHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSpinner.class), JSpinnerHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JSplitPane.class), JSplitPaneHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTabbedPane.class), JTabbedPaneHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JTextComponent.class), JTextComponentHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToggleButton.class), JRadioButtonHandler.class);
TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JToolBar.class), JToolBarHandler.class);
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class), JTreeHandler.class);
- TagManager.registerTag("javax.swing.*", "JTree", new JTreeHandler(ClassDescriptorLoader.getClassDescriptor(JAXXTree.class)));
- TagManager.registerBean(ClassDescriptorLoader.getClassDescriptor(JWindow.class), JWindowHandler.class);
TagManager.registerDefaultNamespace("JEditorPane", "javax.swing.*");
TagManager.registerDefaultNamespace("JFormattedTextField", "javax.swing.*");
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.swing;
+
+import jaxx.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptor;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXList;
+import jaxx.tags.DefaultComponentHandler;
+import jaxx.types.TypeManager;
+import org.w3c.dom.Element;
+
+import javax.swing.event.ListSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXListHandler extends DefaultComponentHandler {
+ public JAXXListHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectedIndex", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedIndices", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValue", ListSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectedValues", ListSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = list.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = list.getId() + "$items";
+ //TODO Add the correct generic type
+ list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ list.appendAdditionCode(listName + ".add(" + id + ");");
+ }
+ list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXListHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java (rev 0)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2006 Ethan Nicholas. All rights reserved.
+ * Use is subject to license terms.
+ */
+package jaxx.tags.swing;
+
+import jaxx.CompilerException;
+import jaxx.compiler.CompiledObject;
+import jaxx.compiler.JAXXCompiler;
+import jaxx.reflect.ClassDescriptor;
+import jaxx.reflect.ClassDescriptorLoader;
+import jaxx.runtime.swing.Item;
+import jaxx.runtime.swing.JAXXTree;
+import jaxx.tags.DefaultComponentHandler;
+import jaxx.types.TypeManager;
+import org.w3c.dom.Element;
+
+import javax.swing.event.TreeSelectionListener;
+import java.io.IOException;
+import java.util.List;
+
+public class JAXXTreeHandler extends DefaultComponentHandler {
+ public JAXXTreeHandler(ClassDescriptor beanClass) {
+ super(beanClass);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class);
+ }
+
+ @Override
+ protected void configureProxyEventInfo() {
+ super.configureProxyEventInfo();
+ addProxyEventInfo("getSelectionCount", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPath", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionPaths", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionRows", TreeSelectionListener.class, "selectionModel");
+ addProxyEventInfo("getSelectionValue", TreeSelectionListener.class, "selectionModel");
+ }
+
+ @Override
+ public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
+ return new CompiledItemContainer(id, getBeanClass(), compiler);
+ }
+
+ private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException {
+ for (Item item : items) {
+ String id = item.getId();
+ CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
+ compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
+ compiler.registerCompiledObject(compiledItem);
+ tree.appendAdditionCode(addMethod + "(" + id + ");");
+ createItems(tree, item.getChildren(), id + ".addChild", compiler);
+ }
+ }
+
+ @Override
+ public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
+ super.compileChildrenSecondPass(tag, compiler);
+ CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent();
+ List<Item> items = tree.getItems();
+ if (items != null && !items.isEmpty()) {
+ String listName = tree.getId() + "$items";
+ tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
+ createItems(tree, items, listName + ".add", compiler);
+ tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");");
+ }
+ }
+}
+
+
+
Property changes on: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JAXXTreeHandler.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JComboBoxHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -35,6 +35,7 @@
NodeList children = tag.getChildNodes();
if (children.getLength() > 0) {
compiler.reportError("JComboBox does not accept childs");
+ throw new CompilerException("JComboBox does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JListHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,28 +1,22 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
package jaxx.tags.swing;
import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Item;
-import jaxx.runtime.swing.JAXXList;
import jaxx.tags.DefaultComponentHandler;
-import jaxx.types.TypeManager;
import org.w3c.dom.Element;
import javax.swing.event.ListSelectionListener;
import java.io.IOException;
-import java.util.List;
+import javax.swing.JList;
+import org.w3c.dom.NodeList;
public class JListHandler extends DefaultComponentHandler {
+
public JListHandler(ClassDescriptor beanClass) {
super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXList.class);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JList.class);
}
@Override
@@ -35,27 +29,11 @@
}
@Override
- public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-
- @Override
public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
- super.compileChildrenSecondPass(tag, compiler);
- CompiledItemContainer list = (CompiledItemContainer) compiler.getOpenComponent();
- List<Item> items = list.getItems();
- if (items != null && !items.isEmpty()) {
- String listName = list.getId() + "$items";
- //TODO Add the correct generic type
- list.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
- for (Item item : items) {
- String id = item.getId();
- CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
- compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
- compiler.registerCompiledObject(compiledItem);
- list.appendAdditionCode(listName + ".add(" + id + ");");
- }
- list.appendAdditionCode(list.getId() + ".setItems(" + listName + ");");
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JList does not accept childs");
+ throw new CompilerException("JList does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java
===================================================================
--- branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-compiler/src/main/java/jaxx/tags/swing/JTreeHandler.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,28 +1,22 @@
-/*
- * Copyright 2006 Ethan Nicholas. All rights reserved.
- * Use is subject to license terms.
- */
package jaxx.tags.swing;
import jaxx.CompilerException;
-import jaxx.compiler.CompiledObject;
import jaxx.compiler.JAXXCompiler;
import jaxx.reflect.ClassDescriptor;
import jaxx.reflect.ClassDescriptorLoader;
-import jaxx.runtime.swing.Item;
-import jaxx.runtime.swing.JAXXTree;
import jaxx.tags.DefaultComponentHandler;
-import jaxx.types.TypeManager;
import org.w3c.dom.Element;
import javax.swing.event.TreeSelectionListener;
import java.io.IOException;
-import java.util.List;
+import javax.swing.JTree;
+import org.w3c.dom.NodeList;
public class JTreeHandler extends DefaultComponentHandler {
+
public JTreeHandler(ClassDescriptor beanClass) {
super(beanClass);
- ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JAXXTree.class);
+ ClassDescriptorLoader.checkSupportClass(getClass(), beanClass, JTree.class);
}
@Override
@@ -36,31 +30,11 @@
}
@Override
- public CompiledObject createCompiledObject(String id, JAXXCompiler compiler) throws CompilerException {
- return new CompiledItemContainer(id, getBeanClass(), compiler);
- }
-
- private void createItems(CompiledObject tree, List<Item> items, String addMethod, JAXXCompiler compiler) throws CompilerException {
- for (Item item : items) {
- String id = item.getId();
- CompiledObject compiledItem = new CompiledObject(id, ClassDescriptorLoader.getClassDescriptor(Item.class), compiler);
- compiledItem.setConstructorParams(TypeManager.getJavaCode(id) + ", " + TypeManager.getJavaCode(item.getLabel()) + ", " + TypeManager.getJavaCode(item.getValue()) + ", " + item.isSelected());
- compiler.registerCompiledObject(compiledItem);
- tree.appendAdditionCode(addMethod + "(" + id + ");");
- createItems(tree, item.getChildren(), id + ".addChild", compiler);
- }
- }
-
- @Override
public void compileChildrenSecondPass(Element tag, JAXXCompiler compiler) throws CompilerException, IOException {
- super.compileChildrenSecondPass(tag, compiler);
- CompiledItemContainer tree = (CompiledItemContainer) compiler.getOpenComponent();
- List<Item> items = tree.getItems();
- if (items != null && !items.isEmpty()) {
- String listName = tree.getId() + "$items";
- tree.appendAdditionCode("java.util.List<jaxx.runtime.swing.Item> " + listName + " = new java.util.ArrayList<jaxx.runtime.swing.Item>();");
- createItems(tree, items, listName + ".add", compiler);
- tree.appendAdditionCode(tree.getId() + ".setItems(" + listName + ");");
+ NodeList children = tag.getChildNodes();
+ if (children.getLength() > 0) {
+ compiler.reportError("JTree does not accept childs");
+ throw new CompilerException("JTree does not accept childs");
}
}
}
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/DemoUI.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -97,10 +97,7 @@
<JScrollPane id='navigationPane'>
<JTree id='navigation'
model='{getTreeHelper().createTreeModel(this)}'
- selectionModel="{getTreeHelper().createTreeHandler(this)}">
- <!--cellRenderer='{new NavigationTreeCellRenderer(this)}'>-->
- <!--cellRenderer='{new NavigationTreeCellRenderer(this,185)}'>-->
- </JTree>
+ selectionModel="{getTreeHelper().createTreeHandler(this)}"/>
</JScrollPane>
<JPanel id='content'/>
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/jaxx/navigation/item/ItemTreeNavigationDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -40,7 +40,7 @@
<JPanel id='demoPanel' layout='{new BorderLayout()}'>
<JSplitPane constraints='BorderLayout.CENTER'>
<JScrollPane>
- <JTree id='nav' rootVisible='{false}'>
+ <JAXXTree id='nav' rootVisible='{false}'>
<!-- Allow to diplay associated pane without value -->
<item id='stringItemParent' label='String' value='{String.class}'>
<item id='string1Item' label='String1' value='{new String("Ceci est un String")}' selected='true'/>
@@ -49,7 +49,7 @@
<item id='dateItemParent' label='Date' value='{Date.class}'>
<item id='dateItem' label='CurrentDate' value='{new Date()}'/>
</item>
- </JTree>
+ </JAXXTree>
</JScrollPane>
<!-- Card panel, only ItemNavigationPanel children is allowed -->
<ItemNavigationCardPanel id="content">
Modified: branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx
===================================================================
--- branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/jaxx-demo/src/main/java/jaxx/demo/component/swing/JListDemo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -18,62 +18,62 @@
<http://www.gnu.org/licenses/lgpl-3.0.html>.
##%*
-->
-<jaxx.demo.DemoPanel>
- <Table id='demoPanel'>
- <row>
- <cell>
- <JLabel text='Supported Swing components:'/>
- </cell>
- </row>
-
- <row>
- <cell>
- <JScrollPane>
- <JList>
- <item value='JApplet'/>
- <item value='JButton'/>
- <item value='JCheckBox'/>
- <item value='JCheckBoxMenuItem'/>
- <item value='JColorChooser'/>
- <item value='JComboBox'/>
- <item value='JDesktopPane'/>
- <item value='JDialog'/>
- <item value='JEditorPane'/>
- <item value='JFileChooser'/>
- <item value='JFormattedTextField'/>
- <item value='JFrame'/>
- <item value='JInternalFrame'/>
- <item value='JLabel'/>
- <item value='JLayeredPane'/>
- <item value='JList'/>
- <item value='JMenu'/>
- <item value='JMenuBar'/>
- <item value='JMenuItem'/>
- <item value='JOptionPane'/>
- <item value='JPanel'/>
- <item value='JPasswordField'/>
- <item value='JPopupMenu'/>
- <item value='JProgressBar'/>
- <item value='JRadioButton'/>
- <item value='JRadioButtonMenuItem'/>
- <item value='JScrollBar'/>
- <item value='JScrollPane'/>
- <item value='JSeparator'/>
- <item value='JSlider'/>
- <item value='JSpinner'/>
- <item value='JSplitPane'/>
- <item value='JTabbedPane'/>
- <item value='JTable'/>
- <item value='JTextArea'/>
- <item value='JTextField'/>
- <item value='JTextPane'/>
- <item value='JToggleButton'/>
- <item value='JToolBar'/>
- <item value='JTree'/>
- <item value='JWindow'/>
- </JList>
- </JScrollPane>
- </cell>
- </row>
- </Table>
+<jaxx.demo.DemoPanel>
+ <Table id='demoPanel'>
+ <row>
+ <cell>
+ <JLabel text='Supported Swing components:'/>
+ </cell>
+ </row>
+
+ <row>
+ <cell>
+ <JScrollPane>
+ <JAXXList>
+ <item value='JApplet'/>
+ <item value='JButton'/>
+ <item value='JCheckBox'/>
+ <item value='JCheckBoxMenuItem'/>
+ <item value='JColorChooser'/>
+ <item value='JComboBox'/>
+ <item value='JDesktopPane'/>
+ <item value='JDialog'/>
+ <item value='JEditorPane'/>
+ <item value='JFileChooser'/>
+ <item value='JFormattedTextField'/>
+ <item value='JFrame'/>
+ <item value='JInternalFrame'/>
+ <item value='JLabel'/>
+ <item value='JLayeredPane'/>
+ <item value='JList'/>
+ <item value='JMenu'/>
+ <item value='JMenuBar'/>
+ <item value='JMenuItem'/>
+ <item value='JOptionPane'/>
+ <item value='JPanel'/>
+ <item value='JPasswordField'/>
+ <item value='JPopupMenu'/>
+ <item value='JProgressBar'/>
+ <item value='JRadioButton'/>
+ <item value='JRadioButtonMenuItem'/>
+ <item value='JScrollBar'/>
+ <item value='JScrollPane'/>
+ <item value='JSeparator'/>
+ <item value='JSlider'/>
+ <item value='JSpinner'/>
+ <item value='JSplitPane'/>
+ <item value='JTabbedPane'/>
+ <item value='JTable'/>
+ <item value='JTextArea'/>
+ <item value='JTextField'/>
+ <item value='JTextPane'/>
+ <item value='JToggleButton'/>
+ <item value='JToolBar'/>
+ <item value='JTree'/>
+ <item value='JWindow'/>
+ </JAXXList>
+ </JScrollPane>
+ </cell>
+ </row>
+ </Table>
</jaxx.demo.DemoPanel>
\ No newline at end of file
Deleted: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,84 +0,0 @@
-package org.nuiton.jaxx.plugin;
-
-import jaxx.compiler.JAXXCompiler;
-import jaxx.compiler.JAXXCompilerLaunchor;
-import org.apache.maven.plugin.MojoExecutionException;
-
-import java.lang.reflect.Field;
-import java.util.Map;
-
-import org.apache.maven.plugin.logging.SystemStreamLog;
-import org.junit.Test;
-import static org.junit.Assert.*;
-
-public class ComboBoxTest extends JaxxBaseTest {
-
- @Test
- public void ok() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
- mojo.execute();
- checkPattern(mojo, "swingComboBox", true, "org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.java");
- assertNumberJaxxFiles(2);
- }
-
- @SuppressWarnings({"unchecked"})
- @Test
- public void error() throws Exception {
- JaxxGeneratorMojo mojo = getMojo();
- // init mojo to get alls files to treate
- mojo.init();
-
- assertNumberJaxxFiles(1);
-
- mojo.setLog(new SystemStreamLog() {
-
- @Override
- public boolean isErrorEnabled() {
- return false;
- }
-
- @Override
- public void error(Throwable error) {
- //do nothing
- }
-
- @Override
- public void error(CharSequence content) {
- //do nothing
- }
-
- @Override
- public void error(CharSequence content, Throwable error) {
- //do nothing
- }
- });
- Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers");
- Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount");
-
- fieldCompilers.setAccessible(true);
- fieldErrorCount.setAccessible(true);
-
-
- // execute mjo on each jaxx file to produce the error
- for (String file : mojo.files) {
- log.info("test bad file " + file);
- mojo.files = new String[]{file};
- try {
- mojo.doAction();
- // should never pass
- fail();
- } catch (MojoExecutionException e) {
- // ok jaxx compiler failed
- assertTrue(true);
-
- JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get();
- Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor);
- assertEquals(1, compilers.size());
- //JAXXCompiler compiler;
- //compiler = compilers.values().iterator().next();
- Integer nberrors = (Integer) fieldErrorCount.get(launchor);
- assertTrue(nberrors != null && nberrors > 0);
- }
- }
- }
-}
Copied: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java (from rev 1560, branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/ComboBoxTest.java)
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,98 @@
+package org.nuiton.jaxx.plugin;
+
+import jaxx.compiler.JAXXCompiler;
+import jaxx.compiler.JAXXCompilerLaunchor;
+import org.apache.maven.plugin.MojoExecutionException;
+
+import java.lang.reflect.Field;
+import java.util.Map;
+
+import org.apache.maven.plugin.logging.SystemStreamLog;
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class Evolution74Test extends JaxxBaseTest {
+
+ @Test
+ public void ok() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ mojo.execute();
+ assertNumberJaxxFiles(6);
+
+ checkPattern(mojo, "JComboBox", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.java");
+ checkPattern(mojo, "JComboBox", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.java");
+ checkPattern(mojo, "JAXXComboBox", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.java");
+ checkPattern(mojo, "JAXXComboBox", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.java");
+
+ checkPattern(mojo, "JList", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.java");
+ checkPattern(mojo, "JList", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.java");
+ checkPattern(mojo, "JAXXList", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.java");
+ checkPattern(mojo, "JAXXList", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.java");
+
+ checkPattern(mojo, "JTree", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.java");
+ checkPattern(mojo, "JTree", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.java");
+ checkPattern(mojo, "JAXXTree", false, "org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.java");
+ checkPattern(mojo, "JAXXTree", true, "org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.java");
+ }
+
+ @SuppressWarnings({"unchecked"})
+ @Test
+ public void error() throws Exception {
+ JaxxGeneratorMojo mojo = getMojo();
+ // init mojo to get alls files to treate
+ mojo.init();
+
+ assertNumberJaxxFiles(3);
+
+ mojo.setLog(new SystemStreamLog() {
+
+ @Override
+ public boolean isErrorEnabled() {
+ return false;
+ }
+
+ @Override
+ public void error(Throwable error) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content) {
+ //do nothing
+ }
+
+ @Override
+ public void error(CharSequence content, Throwable error) {
+ //do nothing
+ }
+ });
+ Field fieldCompilers = JAXXCompilerLaunchor.class.getDeclaredField("compilers");
+ Field fieldErrorCount = JAXXCompilerLaunchor.class.getDeclaredField("errorCount");
+
+ fieldCompilers.setAccessible(true);
+ fieldErrorCount.setAccessible(true);
+
+
+ // execute mjo on each jaxx file to produce the error
+ for (String file : mojo.files) {
+ log.info("test bad file " + file);
+ mojo.files = new String[]{file};
+ try {
+ mojo.doAction();
+ // should never pass
+ fail();
+ } catch (MojoExecutionException e) {
+ // ok jaxx compiler failed
+ assertTrue(true);
+
+ JAXXCompilerLaunchor launchor = JAXXCompilerLaunchor.get();
+ Map<String, JAXXCompiler> compilers = (Map<String, JAXXCompiler>) fieldCompilers.get(launchor);
+ assertEquals(1, compilers.size());
+ //JAXXCompiler compiler;
+ //compiler = compilers.values().iterator().next();
+ Integer nberrors = (Integer) fieldErrorCount.get(launchor);
+ assertTrue(nberrors != null && nberrors > 0);
+ }
+ }
+ }
+}
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/java/org/nuiton/jaxx/plugin/Evolution74Test.java
___________________________________________________________________
Added: svn:keywords
+ "Author Date Id Revision HeadURL
Added: svn:mergeinfo
+
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest1.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JList>
+<JAXXList>
<item value='Working' selected='true'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JListTest2.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JList>
+<JAXXList>
<item value='Failed!'/>
-</JList>
\ No newline at end of file
+</JAXXList>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest1.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JTree>
+<JAXXTree>
<item value='Working' selected='true'/>
-</JTree>
\ No newline at end of file
+</JAXXTree>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/CompilerTest/SpecialSubclassing/JTreeTest2.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,3 +1,3 @@
-<JTree>
+<JAXXTree>
<item value='Failed!'/>
-</JTree>
\ No newline at end of file
+</JAXXTree>
\ No newline at end of file
Property changes on: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test
___________________________________________________________________
Added: svn:mergeinfo
+
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swinglist.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JList>
+ <item value='OK'/>
+</JList>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error/swingtree.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JTree>
+ <item value='OK'/>
+</JTree>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/error.xml 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/error.xml 2009-10-06 04:59:00 UTC (rev 1561)
@@ -18,7 +18,7 @@
<force>true</force>
<verbose>true</verbose>
<includes>
- <value>**/ComboBoxTest/error/*.jaxx</value>
+ <value>**/Evolution74Test/error/*.jaxx</value>
</includes>
</configuration>
</plugin>
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/jaxxcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxcombo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,4 +1,4 @@
-<JAXXComboBox id='comboBox'>
- <item value='OK' selected='true'/>
+<JAXXComboBox>
+ <item value='OK'/>
</JAXXComboBox>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxlist.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JAXXList>
+ <item value='OK'/>
+</JAXXList>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/jaxxtree.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,4 @@
+
+<JAXXTree>
+ <item value='OK'/>
+</JAXXTree>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok/swingcombo.jaxx 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingcombo.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -1,2 +1,2 @@
-<JComboBox id='swingComboBox'/>
\ No newline at end of file
+<JComboBox/>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swinglist.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1 @@
+<JList/>
\ No newline at end of file
Added: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx (rev 0)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok/swingtree.jaxx 2009-10-06 04:59:00 UTC (rev 1561)
@@ -0,0 +1,2 @@
+
+<JTree/>
\ No newline at end of file
Modified: branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml
===================================================================
--- branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/ComboBoxTest/ok.xml 2009-10-05 19:16:52 UTC (rev 1560)
+++ branches/jaxx-2.X/maven-jaxx-plugin/src/test/resources/org/nuiton/jaxx/plugin/Evolution74Test/ok.xml 2009-10-06 04:59:00 UTC (rev 1561)
@@ -17,7 +17,7 @@
<outResource>${basedir}/target/it-generated-sources/resources</outResource>
<force>true</force>
<includes>
- <value>**/ComboBoxTest/ok/*.jaxx</value>
+ <value>**/Evolution74Test/ok/*.jaxx</value>
</includes>
</configuration>
</plugin>
1
0