checkstyle passes
git-svn-id: https://google-web-toolkit.googlecode.com/svn/trunk@30 8db76d5a-ed1c-0410-87a9-c151d255dfc7
diff --git a/user/src/com/google/gwt/core/client/GWT.java b/user/src/com/google/gwt/core/client/GWT.java
index 262d74e..0aa39a4 100644
--- a/user/src/com/google/gwt/core/client/GWT.java
+++ b/user/src/com/google/gwt/core/client/GWT.java
@@ -40,35 +40,6 @@
private static UncaughtExceptionHandler sUncaughtExceptionHandler = null;
/**
- * Returns the currently active uncaughtExceptionHandler. "Top level" methods
- * that dispatch events from the browser into user code must call this method
- * on entry to get the active handler. If the active handler is null, the
- * entry point must allow exceptions to escape into the browser. If the
- * handler is non-null, exceptions must be caught and routed to the handler.
- * See the source code for
- * <code>{@link com.google.gwt.user.client.DOM}.dispatchEvent()</code> for
- * an example of how to handle this correctly.
- *
- * @return the currently active handler, or null if no handler is active.
- */
- public static UncaughtExceptionHandler getUncaughtExceptionHandler() {
- return sUncaughtExceptionHandler;
- }
-
- /**
- * Sets a custom uncaught exception handler. See
- * {@link #getUncaughtExceptionHandler()} for details.
- *
- * @param handler the handler that should be called when an exception is about
- * to escape to the browser, or <code>null</code> to clear the
- * handler and allow exceptions to escape.
- */
- public static void setUncaughtExceptionHandler(
- UncaughtExceptionHandler handler) {
- sUncaughtExceptionHandler = handler;
- }
-
- /**
* Instantiates a class via deferred binding.
*
* <p>
@@ -92,36 +63,10 @@
* new Object() type expression of the correct rebound type.
*/
throw new RuntimeException(
- "GWT has not been properly initialized; if you are running a unit test, check that your test case extends GWTTestCase");
+ "GWT has not been properly initialized; if you are running a unit test, check that your test case extends GWTTestCase");
}
- /**
- * Gets the class name of the specified object, as would be returned by
- * <code>o.getClass().getName()</code>.
- *
- * @param o the object whose class name is being sought, or <code>null</code>
- * @return the class name of the specified object, or <code>null</code> if
- * <code>o</code> is <code>null</code>
- */
- public static native String getTypeName(Object o) /*-{
- return (o == null) ? null : o.@java.lang.Object::typeName;
- }-*/;
-
- /**
- * Determines whether or not the running program is script or bytecode.
- */
- public static boolean isScript() {
- return true;
- };
-
- /**
- * Gets the name of the running module.
- */
- public static native String getModuleName() /*-{
- return $moduleName;
- }-*/;
-
- /**
+ /**
* Gets the URL prefix of the module which should be prepended to URLs that
* are intended to be module-relative, such as RPC entry points and files in
* the module's public path.
@@ -132,11 +77,66 @@
return Impl.getModuleBaseURL();
}
+ /**
+ * Gets the name of the running module.
+ */
+ public static native String getModuleName() /*-{
+ return $moduleName;
+ }-*/;
+
+ /**
+ * Gets the class name of the specified object, as would be returned by
+ * <code>o.getClass().getName()</code>.
+ *
+ * @param o the object whose class name is being sought, or <code>null</code>
+ * @return the class name of the specified object, or <code>null</code> if
+ * <code>o</code> is <code>null</code>
+ */
+ public static native String getTypeName(Object o) /*-{
+ return (o == null) ? null : o.@java.lang.Object::typeName;
+ }-*/;
+
+ /**
+ * Returns the currently active uncaughtExceptionHandler. "Top level" methods
+ * that dispatch events from the browser into user code must call this method
+ * on entry to get the active handler. If the active handler is null, the
+ * entry point must allow exceptions to escape into the browser. If the
+ * handler is non-null, exceptions must be caught and routed to the handler.
+ * See the source code for
+ * <code>{@link com.google.gwt.user.client.DOM}.dispatchEvent()</code> for
+ * an example of how to handle this correctly.
+ *
+ * @return the currently active handler, or null if no handler is active.
+ */
+ public static UncaughtExceptionHandler getUncaughtExceptionHandler() {
+ return sUncaughtExceptionHandler;
+ };
+
+ /**
+ * Determines whether or not the running program is script or bytecode.
+ */
+ public static boolean isScript() {
+ return true;
+ }
+
/**
* Logs a message to the development shell logger in hosted mode. Calls are
* optimized out in web mode.
*/
public static void log(String message, Throwable e) {
// intentionally empty in web mode.
+ }
+
+ /**
+ * Sets a custom uncaught exception handler. See
+ * {@link #getUncaughtExceptionHandler()} for details.
+ *
+ * @param handler the handler that should be called when an exception is about
+ * to escape to the browser, or <code>null</code> to clear the
+ * handler and allow exceptions to escape.
+ */
+ public static void setUncaughtExceptionHandler(
+ UncaughtExceptionHandler handler) {
+ sUncaughtExceptionHandler = handler;
};
}
diff --git a/user/src/com/google/gwt/core/client/JavaScriptException.java b/user/src/com/google/gwt/core/client/JavaScriptException.java
index 700e8fa..b4b26b1 100644
--- a/user/src/com/google/gwt/core/client/JavaScriptException.java
+++ b/user/src/com/google/gwt/core/client/JavaScriptException.java
@@ -37,6 +37,16 @@
private final String description;
/**
+ * @param name the original JavaScript type name of the exception
+ * @param description the original JavaScript message of the exception
+ */
+ public JavaScriptException(String name, String description) {
+ super("JavaScript " + name + " exception: " + description);
+ this.name = name;
+ this.description = description;
+ }
+
+ /**
* Useful for server-side instantiation.
*
* @param message the detail message.
@@ -48,13 +58,10 @@
}
/**
- * @param name the original JavaScript type name of the exception
- * @param description the original JavaScript message of the exception
+ * @return the original JavaScript message of the exception
*/
- public JavaScriptException(String name, String description) {
- super("JavaScript " + name + " exception: " + description);
- this.name = name;
- this.description = description;
+ public String getDescription() {
+ return description;
}
/**
@@ -64,11 +71,4 @@
return name;
}
- /**
- * @return the original JavaScript message of the exception
- */
- public String getDescription() {
- return description;
- }
-
}
diff --git a/user/src/com/google/gwt/core/client/JavaScriptObject.java b/user/src/com/google/gwt/core/client/JavaScriptObject.java
index a0ef7fd..f832daf 100644
--- a/user/src/com/google/gwt/core/client/JavaScriptObject.java
+++ b/user/src/com/google/gwt/core/client/JavaScriptObject.java
@@ -29,6 +29,17 @@
*/
public class JavaScriptObject {
+ private static native boolean equalsImpl(JavaScriptObject o,
+ JavaScriptObject other) /*-{
+ return o === other;
+ }-*/;
+
+ private static native String toStringImpl(JavaScriptObject o) /*-{
+ if (o.toString)
+ return o.toString();
+ return "[object]";
+ }-*/;
+
/**
* the underlying JavaScript object.
*/
@@ -44,6 +55,17 @@
this.opaque = opaque;
}
+ public boolean equals(Object other) {
+ if (!(other instanceof JavaScriptObject)) {
+ return false;
+ }
+ return equalsImpl(this, (JavaScriptObject) other);
+ };
+
+ public int hashCode() {
+ return Impl.getHashCode(this);
+ }
+
public String toString() {
/*
* Hosted mode will marshal an explicit argument from a JavaScriptObject
@@ -53,26 +75,4 @@
*/
return toStringImpl(this);
}
-
- public boolean equals(Object other) {
- if (!(other instanceof JavaScriptObject)) {
- return false;
- }
- return equalsImpl(this, (JavaScriptObject) other);
- }
-
- public int hashCode() {
- return Impl.getHashCode(this);
- };
-
- private static native String toStringImpl(JavaScriptObject o) /*-{
- if (o.toString)
- return o.toString();
- return "[object]";
- }-*/;
-
- private static native boolean equalsImpl(JavaScriptObject o,
- JavaScriptObject other) /*-{
- return o === other;
- }-*/;
}
diff --git a/user/src/com/google/gwt/http/client/Request.java b/user/src/com/google/gwt/http/client/Request.java
index 91df0f6..da13664 100644
--- a/user/src/com/google/gwt/http/client/Request.java
+++ b/user/src/com/google/gwt/http/client/Request.java
@@ -33,6 +33,63 @@
*/
public class Request {
/**
+ * Creates a {@link Response} instance for the given JavaScript XmlHttpRequest
+ * object.
+ *
+ * @param xmlHttpRequest xmlHttpRequest object for which we need a response
+ * @return a {@link Response} object instance
+ */
+ private static Response createResponse(final JavaScriptObject xmlHttpRequest) {
+ assert (XMLHTTPRequest.isResponseReady(xmlHttpRequest));
+ Response response = new Response() {
+ public String getHeader(String header) {
+ StringValidator.throwIfEmptyOrNull("header", header);
+
+ return XMLHTTPRequest.getResponseHeader(xmlHttpRequest, header);
+ }
+
+ public Header[] getHeaders() {
+ return XMLHTTPRequest.getHeaders(xmlHttpRequest);
+ }
+
+ public String getHeadersAsString() {
+ return XMLHTTPRequest.getAllResponseHeaders(xmlHttpRequest);
+ }
+
+ public int getStatusCode() {
+ return XMLHTTPRequest.getStatusCode(xmlHttpRequest);
+ }
+
+ public String getStatusText() {
+ return XMLHTTPRequest.getStatusText(xmlHttpRequest);
+ }
+
+ public String getText() {
+ return XMLHTTPRequest.getResponseText(xmlHttpRequest);
+ }
+ };
+ return response;
+ }
+
+ /**
+ * The number of milliseconds to wait for this HTTP request to complete.
+ */
+ private final int timeoutMillis;
+
+ /*
+ * Timer used to force HTTPRequest timeouts. If the user has not requested a
+ * timeout then this field is null.
+ */
+ private final Timer timer;
+
+ /*
+ * JavaScript XmlHttpRequest object that this Java class wraps. This field is
+ * not final because we transfer ownership of it to the HTTPResponse object
+ * and set this field to null.
+ */
+ private JavaScriptObject xmlHttpRequest;
+
+ /**
* Constructs an instance of the Request object.
*
* @param xmlHttpRequest JavaScript XmlHttpRequest object instance
@@ -190,45 +247,6 @@
}
}
- /**
- * Creates a {@link Response} instance for the given JavaScript XmlHttpRequest
- * object.
- *
- * @param xmlHttpRequest xmlHttpRequest object for which we need a response
- * @return a {@link Response} object instance
- */
- private static Response createResponse(final JavaScriptObject xmlHttpRequest) {
- assert (XMLHTTPRequest.isResponseReady(xmlHttpRequest));
- Response response = new Response() {
- public String getHeader(String header) {
- StringValidator.throwIfEmptyOrNull("header", header);
-
- return XMLHTTPRequest.getResponseHeader(xmlHttpRequest, header);
- }
-
- public Header[] getHeaders() {
- return XMLHTTPRequest.getHeaders(xmlHttpRequest);
- }
-
- public String getHeadersAsString() {
- return XMLHTTPRequest.getAllResponseHeaders(xmlHttpRequest);
- }
-
- public int getStatusCode() {
- return XMLHTTPRequest.getStatusCode(xmlHttpRequest);
- }
-
- public String getStatusText() {
- return XMLHTTPRequest.getStatusText(xmlHttpRequest);
- }
-
- public String getText() {
- return XMLHTTPRequest.getResponseText(xmlHttpRequest);
- }
- };
- return response;
- }
-
/*
* Method called when this request times out.
*
@@ -244,22 +262,4 @@
callback.onError(this, new RequestTimeoutException(this, timeoutMillis));
}
-
- /**
- * The number of milliseconds to wait for this HTTP request to complete.
- */
- private final int timeoutMillis;
-
- /*
- * Timer used to force HTTPRequest timeouts. If the user has not requested a
- * timeout then this field is null.
- */
- private final Timer timer;
-
- /*
- * JavaScript XmlHttpRequest object that this Java class wraps. This field is
- * not final because we transfer ownership of it to the HTTPResponse object
- * and set this field to null.
- */
- private JavaScriptObject xmlHttpRequest;
}
diff --git a/user/src/com/google/gwt/http/client/RequestBuilder.java b/user/src/com/google/gwt/http/client/RequestBuilder.java
index 94f0c32..1daefaa 100644
--- a/user/src/com/google/gwt/http/client/RequestBuilder.java
+++ b/user/src/com/google/gwt/http/client/RequestBuilder.java
@@ -46,8 +46,6 @@
*
*/
public class RequestBuilder {
- private static final HTTPRequestImpl httpRequest = (HTTPRequestImpl) GWT.create(HTTPRequestImpl.class);
-
/**
* HTTP request method constants.
*/
@@ -73,6 +71,39 @@
*/
public static final Method POST = new Method("POST");
+ private static final HTTPRequestImpl httpRequest = (HTTPRequestImpl) GWT.create(HTTPRequestImpl.class);
+
+ /*
+ * Map of header name to value that will be added to the JavaScript
+ * XmlHttpRequest object before sending a request.
+ */
+ private Map headers;
+
+ /*
+ * HTTP method to use when opening an JavaScript XmlHttpRequest object
+ */
+ private String httpMethod;
+
+ /*
+ * Password to use when opening an JavaScript XmlHttpRequest object
+ */
+ private String password;
+
+ /*
+ * Timeout in milliseconds before the request timeouts and fails.
+ */
+ private int timeoutMillis;
+
+ /*
+ * URL to use when opening an JavaScript XmlHttpRequest object.
+ */
+ private String url;
+
+ /*
+ * User to use when opening an JavaScript XmlHttpRequest object
+ */
+ private String user;
+
/**
* Creates a builder using the parameters for configuration.
*
@@ -115,28 +146,6 @@
}
/**
- * Sets a request header with the given name and value. If a header with the
- * specified name has already been set then the new value overwrites the
- * current value.
- *
- * @param header the name of the header
- * @param value the value of the header
- *
- * @throws NullPointerException if header or value are null
- * @throws IllegalArgumentException if header or value are the empty string
- */
- public void setHeader(String header, String value) {
- StringValidator.throwIfEmptyOrNull("header", header);
- StringValidator.throwIfEmptyOrNull("value", value);
-
- if (headers == null) {
- headers = new HashMap();
- }
-
- headers.put(header, value);
- }
-
- /**
* Sends an HTTP request based on the current builder configuration. If no
* request headers have been set, the header "Content-Type" will be used with
* a value of "text/plain; charset=utf-8".
@@ -170,6 +179,28 @@
}
/**
+ * Sets a request header with the given name and value. If a header with the
+ * specified name has already been set then the new value overwrites the
+ * current value.
+ *
+ * @param header the name of the header
+ * @param value the value of the header
+ *
+ * @throws NullPointerException if header or value are null
+ * @throws IllegalArgumentException if header or value are the empty string
+ */
+ public void setHeader(String header, String value) {
+ StringValidator.throwIfEmptyOrNull("header", header);
+ StringValidator.throwIfEmptyOrNull("value", value);
+
+ if (headers == null) {
+ headers = new HashMap();
+ }
+
+ headers.put(header, value);
+ }
+
+ /**
* Sets the password to use in the request URL. This is ignored if there is no
* user specified.
*
@@ -244,35 +275,4 @@
"text/plain; charset=utf-8");
}
}
-
- /*
- * Map of header name to value that will be added to the JavaScript
- * XmlHttpRequest object before sending a request.
- */
- private Map headers;
-
- /*
- * HTTP method to use when opening an JavaScript XmlHttpRequest object
- */
- private String httpMethod;
-
- /*
- * Password to use when opening an JavaScript XmlHttpRequest object
- */
- private String password;
-
- /*
- * Timeout in milliseconds before the request timeouts and fails.
- */
- private int timeoutMillis;
-
- /*
- * URL to use when opening an JavaScript XmlHttpRequest object.
- */
- private String url;
-
- /*
- * User to use when opening an JavaScript XmlHttpRequest object
- */
- private String user;
}
diff --git a/user/src/com/google/gwt/http/client/RequestPermissionException.java b/user/src/com/google/gwt/http/client/RequestPermissionException.java
index 7048d05..1604b26 100644
--- a/user/src/com/google/gwt/http/client/RequestPermissionException.java
+++ b/user/src/com/google/gwt/http/client/RequestPermissionException.java
@@ -16,8 +16,8 @@
package com.google.gwt.http.client;
/**
- * Exception thrown when the {@link RequestBuilder} attempts to make a request to
- * a URL which violates the <a
+ * Exception thrown when the {@link RequestBuilder} attempts to make a request
+ * to a URL which violates the <a
* href="http://en.wikipedia.org/wiki/Same_origin_policy">Same-Origin Security
* Policy</a>.
*
@@ -31,6 +31,11 @@
public class RequestPermissionException extends RequestException {
/**
+ * URL which caused this exception to be thrown.
+ */
+ private final String url;
+
+ /**
* Constructs an instance of this class for the given URL.
*
* @param url the URL which can not be accessed
@@ -50,9 +55,4 @@
public String getURL() {
return url;
}
-
- /**
- * URL which caused this exception to be thrown.
- */
- private final String url;
}
diff --git a/user/src/com/google/gwt/http/client/RequestTimeoutException.java b/user/src/com/google/gwt/http/client/RequestTimeoutException.java
index 5020520..d1a5bf7 100644
--- a/user/src/com/google/gwt/http/client/RequestTimeoutException.java
+++ b/user/src/com/google/gwt/http/client/RequestTimeoutException.java
@@ -26,11 +26,21 @@
*/
public class RequestTimeoutException extends RequestException {
private static String formatMessage(int timeoutMillis) {
- return "A request timeout has expired after " + Integer.toString(timeoutMillis)
- + " ms";
+ return "A request timeout has expired after "
+ + Integer.toString(timeoutMillis) + " ms";
}
/**
+ * Time, in milliseconds, of the timeout.
+ */
+ private final int timeoutMillis;
+
+ /**
+ * Request object which experienced the timed out.
+ */
+ private final Request request;
+
+ /**
* Constructs a timeout exception for the given {@link Request}.
*
* @param request the request which timed out
@@ -53,20 +63,10 @@
/**
* Returns the request timeout value in milliseconds.
- *
+ *
* @return the request timeout value in milliseconds
*/
public int getTimeoutMillis() {
return timeoutMillis;
}
-
- /**
- * Time, in milliseconds, of the timeout.
- */
- private final int timeoutMillis;
-
- /**
- * Request object which experienced the timed out.
- */
- private final Request request;
}
diff --git a/user/src/com/google/gwt/i18n/client/ConstantsWithLookup.java b/user/src/com/google/gwt/i18n/client/ConstantsWithLookup.java
index 7f534ec..2b591b6 100644
--- a/user/src/com/google/gwt/i18n/client/ConstantsWithLookup.java
+++ b/user/src/com/google/gwt/i18n/client/ConstantsWithLookup.java
@@ -33,8 +33,8 @@
* <p>
* It is generally preferable to extend <code>Constants</code> rather than
* <code>ConstantsWithLookup</code> because <code>ConstantsWithLookup</code>
- * forces all constants to be retained in the compiled script, preventing the GWT
- * compiler from pruning unused constant accessors.
+ * forces all constants to be retained in the compiled script, preventing the
+ * GWT compiler from pruning unused constant accessors.
* </p>
*
* <h3>Required Module</h3>
@@ -52,6 +52,38 @@
*/
public interface ConstantsWithLookup extends Constants {
/**
+ * Look up <code>boolean</code> by method name.
+ *
+ * @param methodName method name
+ * @return boolean returned by method
+ */
+ public boolean getBoolean(String methodName);
+
+ /**
+ * Look up <code>double</code> by method name.
+ *
+ * @param methodName method name
+ * @return double returned by method
+ */
+ public double getDouble(String methodName);
+
+ /**
+ * Look up <code>float</code> by method name.
+ *
+ * @param methodName method name
+ * @return float returned by method
+ */
+ public float getFloat(String methodName);
+
+ /**
+ * Look up <code>int</code> by method name.
+ *
+ * @param methodName method name
+ * @return int returned by method
+ */
+ public int getInt(String methodName);
+
+ /**
* Look up <code>Map</code> by method name.
*
* @param methodName method name
@@ -74,36 +106,4 @@
* @return String[] returned by method
*/
public String[] getStringArray(String methodName);
-
- /**
- * Look up <code>int</code> by method name.
- *
- * @param methodName method name
- * @return int returned by method
- */
- public int getInt(String methodName);
-
- /**
- * Look up <code>double</code> by method name.
- *
- * @param methodName method name
- * @return double returned by method
- */
- public double getDouble(String methodName);
-
- /**
- * Look up <code>float</code> by method name.
- *
- * @param methodName method name
- * @return float returned by method
- */
- public float getFloat(String methodName);
-
- /**
- * Look up <code>boolean</code> by method name.
- *
- * @param methodName method name
- * @return boolean returned by method
- */
- public boolean getBoolean(String methodName);
}
diff --git a/user/src/com/google/gwt/i18n/client/Dictionary.java b/user/src/com/google/gwt/i18n/client/Dictionary.java
index c980543..f89d028 100644
--- a/user/src/com/google/gwt/i18n/client/Dictionary.java
+++ b/user/src/com/google/gwt/i18n/client/Dictionary.java
@@ -97,10 +97,14 @@
static void resourceErrorBadType(String name) {
throw new MissingResourceException("'" + name
- + "' is not a JavaScript object and cannot be used as a Dictionary",
- null, name);
+ + "' is not a JavaScript object and cannot be used as a Dictionary",
+ null, name);
}
+ private JavaScriptObject dict;
+
+ private String label;
+
/**
* Constructor for <code>Dictionary</code>.
*
@@ -109,14 +113,14 @@
private Dictionary(String name) {
if (name == null || "".equals(name)) {
throw new IllegalArgumentException(
- "Cannot create a Dictionary with a null or empty name");
+ "Cannot create a Dictionary with a null or empty name");
}
this.label = "Dictionary " + name;
attach(name);
if (dict == null) {
throw new MissingResourceException(
- "Cannot find JavaScript object with the name '" + name + "'", name,
- null);
+ "Cannot find JavaScript object with the name '" + name + "'", name,
+ null);
}
}
@@ -193,7 +197,4 @@
@com.google.gwt.i18n.client.Dictionary::resourceErrorBadType(Ljava/lang/String;)(name);
}
}-*/;
-
- private JavaScriptObject dict;
- private String label;
}
diff --git a/user/src/com/google/gwt/i18n/client/impl/ConstantMap.java b/user/src/com/google/gwt/i18n/client/impl/ConstantMap.java
index 2d87109..8371227 100644
--- a/user/src/com/google/gwt/i18n/client/impl/ConstantMap.java
+++ b/user/src/com/google/gwt/i18n/client/impl/ConstantMap.java
@@ -33,6 +33,10 @@
public class ConstantMap extends HashMap {
private static class DummyMapEntry implements Map.Entry {
+ private final Object key;
+
+ private final Object value;
+
DummyMapEntry(Object key, Object value) {
this.key = key;
this.value = value;
@@ -49,13 +53,12 @@
public Object setValue(Object arg0) {
throw new UnsupportedOperationException();
}
-
- private final Object key;
- private final Object value;
}
private class OrderedConstantSet extends ArrayList implements Set {
private class ImmutableIterator implements Iterator {
+ private final Iterator base;
+
ImmutableIterator(Iterator base) {
this.base = base;
}
@@ -71,13 +74,10 @@
public void remove() {
throw new UnsupportedOperationException("Immutable set");
}
-
- private final Iterator base;
}
public void clear() {
- throw new UnsupportedOperationException(
- "Immutable set");
+ throw new UnsupportedOperationException("Immutable set");
}
public Iterator iterator() {
@@ -86,6 +86,12 @@
}
}
+ private OrderedConstantSet entries;
+
+ private final OrderedConstantSet keys = new OrderedConstantSet();
+
+ private OrderedConstantSet values;
+
public void clear() {
throw unsupported("clear");
}
@@ -132,10 +138,6 @@
private UnsupportedOperationException unsupported(String operation) {
return new UnsupportedOperationException(operation
- + " not supported on a constant map");
+ + " not supported on a constant map");
}
-
- private OrderedConstantSet entries;
- private final OrderedConstantSet keys = new OrderedConstantSet();
- private OrderedConstantSet values;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java b/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java
index 46e9ee8..a143d97 100644
--- a/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableImplCreator.java
@@ -50,8 +50,7 @@
JClassType constantsWithLookupClass;
try {
constantsClass = oracle.getType(LocalizableGenerator.CONSTANTS_NAME);
- constantsWithLookupClass = oracle
- .getType(LocalizableGenerator.CONSTANTS_WITH_LOOKUP_NAME);
+ constantsWithLookupClass = oracle.getType(LocalizableGenerator.CONSTANTS_WITH_LOOKUP_NAME);
messagesClass = oracle.getType(LocalizableGenerator.MESSAGES_NAME);
} catch (NotFoundException e) {
// Should never happen in practice.
@@ -63,8 +62,7 @@
// Make sure the interface being rebound extends either Constants or
// Messages.
- boolean assignableToConstants = constantsClass
- .isAssignableFrom(targetClass);
+ boolean assignableToConstants = constantsClass.isAssignableFrom(targetClass);
boolean assignableToMessages = messagesClass.isAssignableFrom(targetClass);
if (!assignableToConstants && !assignableToMessages) {
// Let the implementation generator handle this interface.
@@ -73,8 +71,7 @@
// Make sure that they don't try to extend both Messages and Constants.
if (assignableToConstants && assignableToMessages) {
- throw error(logger, name
- + " cannot extend both Constants and Messages");
+ throw error(logger, name + " cannot extend both Constants and Messages");
}
// Make sure that the type being rebound is in fact an interface.
@@ -87,11 +84,11 @@
resource = ResourceFactory.getBundle(targetClass, locale);
} catch (MissingResourceException e) {
throw error(
- logger,
- "Localization failed; there must be at least one properties file accessible through the classpath in package '"
- + packageName
- + "' whose base name is '"
- + ResourceFactory.getResourceName(targetClass) + "'");
+ logger,
+ "Localization failed; there must be at least one properties file accessible through the classpath in package '"
+ + packageName
+ + "' whose base name is '"
+ + ResourceFactory.getResourceName(targetClass) + "'");
} catch (IllegalArgumentException e) {
// A bad key can generate an illegal argument exception.
throw error(logger, e.getMessage());
@@ -109,21 +106,21 @@
PrintWriter pw = context.tryCreate(logger, packageName, className);
if (pw != null) {
ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(
- packageName, className);
+ packageName, className);
factory.addImplementedInterface(targetClass.getQualifiedSourceName());
SourceWriter writer = factory.createSourceWriter(context, pw);
// Now that we have all the information set up, process the class
if (constantsWithLookupClass.isAssignableFrom(targetClass)) {
ConstantsWithLookupImplCreator c = new ConstantsWithLookupImplCreator(
- logger, writer, targetClass, resource, context.getTypeOracle());
+ logger, writer, targetClass, resource, context.getTypeOracle());
c.emitClass(logger);
} else if (constantsClass.isAssignableFrom(targetClass)) {
ConstantsImplCreator c = new ConstantsImplCreator(logger, writer,
- targetClass, resource, context.getTypeOracle());
+ targetClass, resource, context.getTypeOracle());
c.emitClass(logger);
} else {
MessagesImplCreator messages = new MessagesImplCreator(logger, writer,
- targetClass, resource, context.getTypeOracle());
+ targetClass, resource, context.getTypeOracle());
messages.emitClass(logger);
}
context.commit(logger, pw);
@@ -132,6 +129,11 @@
}
/**
+ * The Dictionary/value bindings used to determine message contents.
+ */
+ private AbstractResource messageBindings;
+
+ /**
* Constructor for <code>AbstractLocalizableImplCreator</code>.
*
* @param writer writer
@@ -185,13 +187,13 @@
}
String localeString;
if (messageBindings.getLocale() == null
- || messageBindings.getLocale().toString().equals("")) {
+ || messageBindings.getLocale().toString().equals("")) {
localeString = "default";
} else {
localeString = messageBindings.getLocale().toString();
}
String info = "When locale is '" + localeString + "', property '" + key
- + "' has the value '" + value + "'";
+ + "' has the value '" + value + "'";
TreeLogger branch = logger.branch(TreeLogger.TRACE, info, null);
methodCreator.createMethodFor(branch, method, value);
}
@@ -208,7 +210,7 @@
if (id.length > 0) {
if (id[0].length == 0) {
logger.log(TreeLogger.WARN, method
- + " had a mislabeled gwt.key, using method name as key", null);
+ + " had a mislabeled gwt.key, using method name as key", null);
} else {
String tag = id[0][0];
return tag;
@@ -216,9 +218,4 @@
}
return method.getName();
}
-
- /**
- * The Dictionary/value bindings used to determine message contents.
- */
- private AbstractResource messageBindings;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableMethodCreator.java b/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableMethodCreator.java
index 22ee2c6..c94f323 100644
--- a/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableMethodCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/AbstractLocalizableMethodCreator.java
@@ -42,15 +42,6 @@
}
/**
- * Get the resources associated with this class.
- *
- * @return associated resources.
- */
- protected AbstractResource getResources() {
- return ((ConstantsImplCreator) currentCreator).getResourceBundle();
- }
-
- /**
* Gets the associated locale.
*
* @return the locale
@@ -58,4 +49,13 @@
protected Locale getLocale() {
return getResources().getLocale();
}
+
+ /**
+ * Get the resources associated with this class.
+ *
+ * @return associated resources.
+ */
+ protected AbstractResource getResources() {
+ return ((ConstantsImplCreator) currentCreator).getResourceBundle();
+ }
}
diff --git a/user/src/com/google/gwt/i18n/rebind/ConstantsImplCreator.java b/user/src/com/google/gwt/i18n/rebind/ConstantsImplCreator.java
index ac2b42b..68a7baa 100644
--- a/user/src/com/google/gwt/i18n/rebind/ConstantsImplCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/ConstantsImplCreator.java
@@ -34,6 +34,11 @@
*/
class ConstantsImplCreator extends AbstractLocalizableImplCreator {
/**
+ * Does a Map need to be generated in order to store complex results?
+ */
+ private boolean needCache = false;
+
+ /**
* Constructor for <code>ConstantsImplCreator</code>.
*
* @param logger logger to print errors
@@ -56,16 +61,16 @@
JType floatClass = oracle.parse(float.class.getName());
JType booleanClass = oracle.parse(boolean.class.getName());
register(stringClass, new SimpleValueMethodCreator(this,
- SimpleValueMethodCreator.STRING));
+ SimpleValueMethodCreator.STRING));
register(mapClass, new ConstantsMapMethodCreator(this));
register(intClass, new SimpleValueMethodCreator(this,
- SimpleValueMethodCreator.INT));
+ SimpleValueMethodCreator.INT));
register(doubleClass, new SimpleValueMethodCreator(this,
- SimpleValueMethodCreator.DOUBLE));
+ SimpleValueMethodCreator.DOUBLE));
register(floatClass, new SimpleValueMethodCreator(this,
- SimpleValueMethodCreator.FLOAT));
+ SimpleValueMethodCreator.FLOAT));
register(booleanClass, new SimpleValueMethodCreator(this,
- SimpleValueMethodCreator.BOOLEAN));
+ SimpleValueMethodCreator.BOOLEAN));
register(stringArrayClass, new ConstantsStringArrayMethodCreator(this));
} catch (NotFoundException e) {
@@ -75,6 +80,31 @@
}
}
+ protected void classEpilog() {
+ if (isNeedCache()) {
+ getWriter().println(
+ "java.util.Map cache = new java.util.HashMap();".toString());
+ }
+ }
+
+ /**
+ * Create the method body associated with the given method. Arguments are
+ * arg0...argN.
+ */
+ protected void emitMethodBody(TreeLogger logger, JMethod method)
+ throws UnableToCompleteException {
+ checkConstantMethod(logger, method);
+ delegateToCreator(logger, method);
+ }
+
+ boolean isNeedCache() {
+ return needCache;
+ }
+
+ void setNeedCache(boolean needCache) {
+ this.needCache = needCache;
+ }
+
/**
* Checks that the method has the right structure to implement
* <code>Constant</code>.
@@ -88,34 +118,4 @@
throw error(logger, s);
}
}
-
- /**
- * Create the method body associated with the given method. Arguments are
- * arg0...argN.
- */
- protected void emitMethodBody(TreeLogger logger, JMethod method)
- throws UnableToCompleteException {
- checkConstantMethod(logger, method);
- delegateToCreator(logger, method);
- }
-
- protected void classEpilog() {
- if (isNeedCache()) {
- getWriter().println(
- "java.util.Map cache = new java.util.HashMap();".toString());
- }
- }
-
- boolean isNeedCache() {
- return needCache;
- }
-
- void setNeedCache(boolean needCache) {
- this.needCache = needCache;
- }
-
- /**
- * Does a Map need to be generated in order to store complex results?
- */
- private boolean needCache = false;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/ConstantsWithLookupImplCreator.java b/user/src/com/google/gwt/i18n/rebind/ConstantsWithLookupImplCreator.java
index c3f2ded..c8e0103 100644
--- a/user/src/com/google/gwt/i18n/rebind/ConstantsWithLookupImplCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/ConstantsWithLookupImplCreator.java
@@ -31,6 +31,10 @@
import java.util.Map;
class ConstantsWithLookupImplCreator extends ConstantsImplCreator {
+ final JMethod[] allInterfaceMethods;
+
+ private final Map namesToMethodCreators = new HashMap();
+
ConstantsWithLookupImplCreator(TreeLogger logger, SourceWriter writer,
JClassType localizableClass, AbstractResource messageBindings,
TypeOracle oracle) throws UnableToCompleteException {
@@ -40,7 +44,7 @@
// Boolean
JType booleanType = oracle.parse(boolean.class.getName());
LookupMethodCreator booleanMethod = new LookupMethodCreator(this,
- booleanType) {
+ booleanType) {
public void printReturnTarget() {
println("return target.booleanValue();");
}
@@ -54,7 +58,7 @@
// Double
JType doubleType = oracle.parse(double.class.getName());
LookupMethodCreator doubleMethod = new LookupMethodCreator(this,
- doubleType) {
+ doubleType) {
public void printReturnTarget() {
println("return target.doubleValue();");
}
@@ -96,12 +100,12 @@
// Map
JType mapType = oracle.parse(Map.class.getName());
namesToMethodCreators.put("getMap",
- new LookupMethodCreator(this, mapType));
+ new LookupMethodCreator(this, mapType));
// String
JType stringType = oracle.parse(String.class.getName());
LookupMethodCreator stringMethod = new LookupMethodCreator(this,
- stringType) {
+ stringType) {
public String returnTemplate() {
return "String answer = {0}();\n cache.put(\"{0}\",answer);return answer;";
}
@@ -111,7 +115,7 @@
// String Array
JType stringArray = oracle.getArrayType(stringType);
namesToMethodCreators.put("getStringArray", new LookupMethodCreator(this,
- stringArray));
+ stringArray));
setNeedCache(true);
allInterfaceMethods = getAllInterfaceMethods(localizableClass);
@@ -121,6 +125,25 @@
}
/**
+ * Create the method body associated with the given method. Arguments are
+ * arg0...argN.
+ */
+ protected void emitMethodBody(TreeLogger logger, JMethod method)
+ throws UnableToCompleteException {
+ checkMethod(logger, method);
+ if (method.getParameters().length == 1) {
+ String name = method.getName();
+ AbstractMethodCreator c = (AbstractMethodCreator) namesToMethodCreators.get(name);
+ if (c != null) {
+ c.createMethodFor(logger, method, null);
+ return;
+ }
+ }
+ // fall through
+ super.emitMethodBody(logger, method);
+ }
+
+ /**
* Checks that the method has the right structure to implement
* <code>Constant</code>.
*
@@ -135,40 +158,17 @@
return;
}
if (params.length != 1
- || !params[0].getType().getQualifiedSourceName().equals(
- "java.lang.String")) {
+ || !params[0].getType().getQualifiedSourceName().equals(
+ "java.lang.String")) {
String s = method + " must have a single String argument.";
throw error(logger, s);
}
} else {
if (method.getParameters().length > 0) {
throw error(
- logger,
- "User-defined methods in interfaces extending ConstantsWithLookup must have no parameters and a return type of int, String, String[], ...");
+ logger,
+ "User-defined methods in interfaces extending ConstantsWithLookup must have no parameters and a return type of int, String, String[], ...");
}
}
}
-
- /**
- * Create the method body associated with the given method. Arguments are
- * arg0...argN.
- */
- protected void emitMethodBody(TreeLogger logger, JMethod method)
- throws UnableToCompleteException {
- checkMethod(logger, method);
- if (method.getParameters().length == 1) {
- String name = method.getName();
- AbstractMethodCreator c = (AbstractMethodCreator) namesToMethodCreators
- .get(name);
- if (c != null) {
- c.createMethodFor(logger, method, null);
- return;
- }
- }
- // fall through
- super.emitMethodBody(logger, method);
- }
-
- private final Map namesToMethodCreators = new HashMap();
- final JMethod[] allInterfaceMethods;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java b/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java
index f2bff01..73bb227 100644
--- a/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java
+++ b/user/src/com/google/gwt/i18n/rebind/LocalizableGenerator.java
@@ -43,8 +43,7 @@
static final String CONSTANTS_NAME = Constants.class.getName();
- static final String CONSTANTS_WITH_LOOKUP_NAME =
- ConstantsWithLookup.class.getName();
+ static final String CONSTANTS_WITH_LOOKUP_NAME = ConstantsWithLookup.class.getName();
/**
* Represents default locale.
@@ -57,6 +56,8 @@
*/
private static final String PROP_LOCALE = "locale";
+ private LocalizableLinkageCreator linkageCreator = new LocalizableLinkageCreator();
+
/**
* Generate an implementation for the given type.
*
@@ -87,7 +88,7 @@
if (localeChunks.length > 0) {
if (!localeChunks[0].equals(localeChunks[0].toLowerCase())) {
logger.log(TreeLogger.ERROR, localeID
- + "'s language code should be lower case", null);
+ + "'s language code should be lower case", null);
throw new UnableToCompleteException();
}
}
@@ -98,11 +99,10 @@
// and country.
locale = new Locale(localeChunks[0], localeChunks[1]);
} else if (localeChunks.length == 3) {
- locale =
- new Locale(localeChunks[0], localeChunks[1], localeChunks[2]);
+ locale = new Locale(localeChunks[0], localeChunks[1], localeChunks[2]);
} else {
logger.log(TreeLogger.ERROR, localeID
- + " is not a correctly formatted locale", null);
+ + " is not a correctly formatted locale", null);
throw new UnableToCompleteException();
}
}
@@ -120,15 +120,11 @@
}
// Link current locale and interface type to correct implementation class.
- String generatedClass =
- AbstractLocalizableImplCreator.generateConstantOrMessageClass(logger,
- context, locale, targetClass);
+ String generatedClass = AbstractLocalizableImplCreator.generateConstantOrMessageClass(
+ logger, context, locale, targetClass);
if (generatedClass != null) {
return generatedClass;
}
return linkageCreator.linkWithImplClass(logger, targetClass, locale);
}
-
- private LocalizableLinkageCreator linkageCreator =
- new LocalizableLinkageCreator();
}
diff --git a/user/src/com/google/gwt/i18n/rebind/LocalizableLinkageCreator.java b/user/src/com/google/gwt/i18n/rebind/LocalizableLinkageCreator.java
index a4b0fb5..b3787bf 100644
--- a/user/src/com/google/gwt/i18n/rebind/LocalizableLinkageCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/LocalizableLinkageCreator.java
@@ -28,6 +28,66 @@
* Links classes with their localized counterparts.
*/
class LocalizableLinkageCreator extends AbstractSourceCreator {
+ private static Map findDerivedClasses(TreeLogger logger, JClassType baseClass)
+ throws UnableToCompleteException {
+ // Construct valid set of candidates for this type.
+ Map matchingClasses = new HashMap();
+ // Add base class if possible.
+ if (baseClass.isInterface() == null && baseClass.isAbstract() == false) {
+ matchingClasses.put(LocalizableGenerator.DEFAULT_TOKEN, baseClass);
+ }
+ String baseName = baseClass.getSimpleSourceName();
+
+ // Find matching sub types.
+ JClassType[] x = baseClass.getSubtypes();
+ for (int i = 0; i < x.length; i++) {
+ JClassType subType = x[i];
+ if ((subType.isInterface() == null) && (subType.isAbstract() == false)) {
+ String name = subType.getSimpleSourceName();
+ // Strip locale from type,
+ int localeIndex = name.indexOf("_");
+ String subTypeBaseName = name;
+ if (localeIndex != -1) {
+ subTypeBaseName = name.substring(0, localeIndex);
+ }
+ boolean matches = subTypeBaseName.equals(baseName);
+ if (matches) {
+ boolean isDefault = localeIndex == -1
+ || localeIndex == name.length() - 1;
+ if (isDefault) {
+ // Don't override base as default if present.
+ JClassType defaultClass = (JClassType) matchingClasses.get(LocalizableGenerator.DEFAULT_TOKEN);
+ if (defaultClass != null) {
+ throw error(logger, defaultClass + " and " + baseName
+ + " are both potencial default classes for " + baseClass);
+ } else {
+ matchingClasses.put(LocalizableGenerator.DEFAULT_TOKEN, subType);
+ }
+ } else {
+ // Don't allow a locale to be ambiguous. Very similar to default
+ // case, different error message.
+ String localeSubString = name.substring(localeIndex + 1);
+ JClassType dopClass = (JClassType) matchingClasses.get(localeSubString);
+ if (dopClass != null) {
+ throw error(logger, dopClass.getQualifiedSourceName() + " and "
+ + subType.getQualifiedSourceName()
+ + " are both potential matches to " + baseClass
+ + " in locale" + localeSubString);
+ }
+ matchingClasses.put(localeSubString, subType);
+ }
+ }
+ }
+ }
+ return matchingClasses;
+ }
+
+ /**
+ * Map to cache linkages of implementation classes and interfaces.
+ */
+ // Change back to ReferenceMap once apache collections is in.
+ private final Map implCache = new HashMap();
+
/**
* * Finds associated implementation in the current locale. Here are the rules
* <p>
@@ -55,7 +115,7 @@
if (baseClass.getName().indexOf("_") == 0) {
throw error(logger, "Cannot have a '_' in the base localizable class "
- + baseClass);
+ + baseClass);
}
Map matchingClasses = findDerivedClasses(logger, baseClass);
// Now that we have all matches, find best class
@@ -77,7 +137,7 @@
if (localeSuffix == LocalizableGenerator.DEFAULT_TOKEN) {
// We already shot our wad, no classes matched.
throw error(logger, "Cannot find a class to bind to argument type "
- + baseClass.getQualifiedSourceName());
+ + baseClass.getQualifiedSourceName());
} else if (strip == -1) {
// Try default.
localeSuffix = LocalizableGenerator.DEFAULT_TOKEN;
@@ -89,66 +149,4 @@
implCache.put(baseName + locale, className);
return result.getQualifiedSourceName();
}
-
- private static Map findDerivedClasses(TreeLogger logger, JClassType baseClass)
- throws UnableToCompleteException {
- // Construct valid set of candidates for this type.
- Map matchingClasses = new HashMap();
- // Add base class if possible.
- if (baseClass.isInterface() == null && baseClass.isAbstract() == false) {
- matchingClasses.put(LocalizableGenerator.DEFAULT_TOKEN, baseClass);
- }
- String baseName = baseClass.getSimpleSourceName();
-
- // Find matching sub types.
- JClassType[] x = baseClass.getSubtypes();
- for (int i = 0; i < x.length; i++) {
- JClassType subType = x[i];
- if ((subType.isInterface() == null) && (subType.isAbstract() == false)) {
- String name = subType.getSimpleSourceName();
- // Strip locale from type,
- int localeIndex = name.indexOf("_");
- String subTypeBaseName = name;
- if (localeIndex != -1) {
- subTypeBaseName = name.substring(0, localeIndex);
- }
- boolean matches = subTypeBaseName.equals(baseName);
- if (matches) {
- boolean isDefault = localeIndex == -1
- || localeIndex == name.length() - 1;
- if (isDefault) {
- // Don't override base as default if present.
- JClassType defaultClass = (JClassType) matchingClasses
- .get(LocalizableGenerator.DEFAULT_TOKEN);
- if (defaultClass != null) {
- throw error(logger, defaultClass + " and " + baseName
- + " are both potencial default classes for " + baseClass);
- } else {
- matchingClasses.put(LocalizableGenerator.DEFAULT_TOKEN, subType);
- }
- } else {
- // Don't allow a locale to be ambiguous. Very similar to default
- // case, different error message.
- String localeSubString = name.substring(localeIndex + 1);
- JClassType dopClass = (JClassType) matchingClasses
- .get(localeSubString);
- if (dopClass != null) {
- throw error(logger, dopClass.getQualifiedSourceName() + " and "
- + subType.getQualifiedSourceName()
- + " are both potential matches to " + baseClass + " in locale"
- + localeSubString);
- }
- matchingClasses.put(localeSubString, subType);
- }
- }
- }
- }
- return matchingClasses;
- }
-
- /**
- * Map to cache linkages of implementation classes and interfaces.
- */
- // Change back to ReferenceMap once apache collections is in.
- private final Map implCache = new HashMap();
}
diff --git a/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java b/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java
index a47f973..946c82f 100644
--- a/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/LookupMethodCreator.java
@@ -29,6 +29,8 @@
* Method creator to call the correct Map for the given Dictionary.
*/
class LookupMethodCreator extends AbstractMethodCreator {
+ private JType returnType;
+
/**
* Constructor for <code>LookupMethodCreator</code>.
*
@@ -41,6 +43,11 @@
this.returnType = returnType;
}
+ public void createMethodFor(TreeLogger logger, JMethod targetMethod,
+ String value) {
+ createMethodFor(targetMethod);
+ }
+
void createMethodFor(JMethod targetMethod) {
String template = "{0} target = ({0})cache.get(arg0);";
String type;
@@ -58,7 +65,7 @@
JMethod[] methods = ((ConstantsWithLookupImplCreator) currentCreator).allInterfaceMethods;
for (int i = 0; i < methods.length; i++) {
if (methods[i].getReturnType().equals(returnType)
- && methods[i] != targetMethod) {
+ && methods[i] != targetMethod) {
String methodName = methods[i].getName();
String body = "if(arg0.equals(" + wrap(methodName) + ")){";
println(body);
@@ -68,7 +75,7 @@
}
String format = "throw new java.util.MissingResourceException(\"Cannot find constant ''\" + {0} + \"''; expecting a method name\", \"{1}\", {0});";
String[] throwArgs = {
- "arg0", this.currentCreator.getTarget().getQualifiedSourceName()};
+ "arg0", this.currentCreator.getTarget().getQualifiedSourceName()};
String result = MessageFormat.format(format, throwArgs);
println(result);
}
@@ -85,11 +92,4 @@
String returnTemplate() {
return "return {0}();";
}
-
- private JType returnType;
-
- public void createMethodFor(TreeLogger logger, JMethod targetMethod,
- String value) {
- createMethodFor(targetMethod);
- }
}
diff --git a/user/src/com/google/gwt/i18n/rebind/SimpleValueMethodCreator.java b/user/src/com/google/gwt/i18n/rebind/SimpleValueMethodCreator.java
index 366cfcb..e6084c9 100644
--- a/user/src/com/google/gwt/i18n/rebind/SimpleValueMethodCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/SimpleValueMethodCreator.java
@@ -25,9 +25,6 @@
*/
class SimpleValueMethodCreator extends AbstractLocalizableMethodCreator {
- private static class BadBooleanPropertyValue extends RuntimeException {
- }
-
/**
* Helper class to delegate to the correct Number parser for this method.
*/
@@ -35,6 +32,9 @@
abstract String getValue(String stringVal);
}
+ private static class BadBooleanPropertyValue extends RuntimeException {
+ }
+
static final AbstractValueCreator DOUBLE = new AbstractValueCreator() {
String getValue(String stringVal) {
return Double.parseDouble(stringVal) + "";
@@ -67,6 +67,8 @@
}
};
+ private AbstractValueCreator valueCreator;
+
/**
* Constructor for <code>SimpleValueMethodCreator</code>.
*
@@ -87,10 +89,11 @@
} catch (NumberFormatException e) {
throw error(logger, value + " could not be parsed as a number.");
} catch (BadBooleanPropertyValue e) {
- throw error(logger, "'" + value
- + "' is not a valid boolean property value; must be 'true' or 'false'");
+ throw error(
+ logger,
+ "'"
+ + value
+ + "' is not a valid boolean property value; must be 'true' or 'false'");
}
}
-
- private AbstractValueCreator valueCreator;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/util/AbstractLocalizableInterfaceCreator.java b/user/src/com/google/gwt/i18n/rebind/util/AbstractLocalizableInterfaceCreator.java
index 7c4678e..78fbf78 100644
--- a/user/src/com/google/gwt/i18n/rebind/util/AbstractLocalizableInterfaceCreator.java
+++ b/user/src/com/google/gwt/i18n/rebind/util/AbstractLocalizableInterfaceCreator.java
@@ -46,6 +46,8 @@
*/
public abstract class AbstractLocalizableInterfaceCreator {
private static class RenameDuplicates extends ResourceKeyFormatter {
+ private Set methodNames = new HashSet();
+
public String format(String key) {
if (methodNames.contains(key)) {
key += "_dup";
@@ -55,8 +57,6 @@
return key;
}
}
-
- private Set methodNames = new HashSet();
}
private static class ReplaceBadChars extends ResourceKeyFormatter {
@@ -72,6 +72,19 @@
private static Pattern DEFAULT_CHARS = Pattern.compile("[.-]");
/**
+ * Composer for the current Constant.
+ */
+ protected SourceWriter composer;
+
+ private List formatters = new ArrayList();
+
+ private File resourceFile;
+
+ private File sourceFile;
+
+ private PrintWriter writer;
+
+ /**
* Creates a new constants creator.
*
* @param className constant class to create
@@ -84,7 +97,7 @@
String packageName, File resourceBundle, File targetLocation,
Class interfaceClass) throws IOException {
setup(packageName, className, resourceBundle, targetLocation,
- interfaceClass);
+ interfaceClass);
}
/**
@@ -120,57 +133,6 @@
genMethodDecl("String", defaultValue, key, key);
}
- private void addFormatters() {
- // For now, we completely control property key formatters.
- formatters.add(new ReplaceBadChars());
-
- // Rename Duplicates must always come last.
- formatters.add(new RenameDuplicates());
- }
-
- private String formatKey(String key) {
- for (int i = 0; i < formatters.size(); i++) {
- ResourceKeyFormatter formatter = (ResourceKeyFormatter) formatters.get(i);
- key = formatter.format(key);
- }
- if (Util.isValidJavaIdent(key) == false) {
- System.err.println("Warning: " + key
- + " is not a legitimate method name. " + sourceFile
- + " will have compiler errors");
- }
- return key;
- }
-
- private void genMethodDecl(String type, String defaultValue, String key,
- String typeArg) {
- composer.beginJavaDocComment();
- composer.println("Translated \"" + defaultValue + "\".\n");
- composer.println("@return translated \"" + defaultValue + "\"");
- composer.print(I18NSync.ID + typeArg);
- composer.endJavaDocComment();
- key = formatKey(key);
- composer.print(type + " " + key);
- composer.print("(");
- genMethodArgs(defaultValue);
- composer.print(");\n");
- }
-
- private void setup(String packageName, String className, File resourceBundle,
- File targetLocation, Class interfaceClass) throws IOException {
- ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(
- packageName, className);
- factory.makeInterface();
- factory.setJavaDocCommentForClass(javaDocComment(resourceBundle
- .getCanonicalPath().replace(File.separatorChar, '/')));
- factory.addImplementedInterface(interfaceClass.getName());
- FileOutputStream file = new FileOutputStream(targetLocation);
- Writer underlying = new OutputStreamWriter(file, Util.DEFAULT_ENCODING);
- writer = new PrintWriter(underlying);
- composer = factory.createSourceWriter(writer);
- resourceFile = resourceBundle;
- sourceFile = targetLocation;
- }
-
/**
* Create method args based upon the default value.
*
@@ -194,9 +156,9 @@
Iterator elements = p.getPropertyMap().entrySet().iterator();
if (elements.hasNext() == false) {
throw new IllegalStateException(
- "File '"
- + resourceFile
- + "' cannot be used to generate message classes, as it has no key/value pairs defined.");
+ "File '"
+ + resourceFile
+ + "' cannot be used to generate message classes, as it has no key/value pairs defined.");
}
while (elements.hasNext()) {
Entry s = (Entry) elements.next();
@@ -205,12 +167,54 @@
composer.commit(new PrintWriterTreeLogger());
}
- private List formatters = new ArrayList();
- private File resourceFile;
- private File sourceFile;
- private PrintWriter writer;
- /**
- * Composer for the current Constant.
- */
- protected SourceWriter composer;
+ private void addFormatters() {
+ // For now, we completely control property key formatters.
+ formatters.add(new ReplaceBadChars());
+
+ // Rename Duplicates must always come last.
+ formatters.add(new RenameDuplicates());
+ }
+
+ private String formatKey(String key) {
+ for (int i = 0; i < formatters.size(); i++) {
+ ResourceKeyFormatter formatter = (ResourceKeyFormatter) formatters.get(i);
+ key = formatter.format(key);
+ }
+ if (Util.isValidJavaIdent(key) == false) {
+ System.err.println("Warning: " + key
+ + " is not a legitimate method name. " + sourceFile
+ + " will have compiler errors");
+ }
+ return key;
+ }
+
+ private void genMethodDecl(String type, String defaultValue, String key,
+ String typeArg) {
+ composer.beginJavaDocComment();
+ composer.println("Translated \"" + defaultValue + "\".\n");
+ composer.println("@return translated \"" + defaultValue + "\"");
+ composer.print(I18NSync.ID + typeArg);
+ composer.endJavaDocComment();
+ key = formatKey(key);
+ composer.print(type + " " + key);
+ composer.print("(");
+ genMethodArgs(defaultValue);
+ composer.print(");\n");
+ }
+
+ private void setup(String packageName, String className, File resourceBundle,
+ File targetLocation, Class interfaceClass) throws IOException {
+ ClassSourceFileComposerFactory factory = new ClassSourceFileComposerFactory(
+ packageName, className);
+ factory.makeInterface();
+ factory.setJavaDocCommentForClass(javaDocComment(resourceBundle.getCanonicalPath().replace(
+ File.separatorChar, '/')));
+ factory.addImplementedInterface(interfaceClass.getName());
+ FileOutputStream file = new FileOutputStream(targetLocation);
+ Writer underlying = new OutputStreamWriter(file, Util.DEFAULT_ENCODING);
+ writer = new PrintWriter(underlying);
+ composer = factory.createSourceWriter(writer);
+ resourceFile = resourceBundle;
+ sourceFile = targetLocation;
+ }
}
diff --git a/user/src/com/google/gwt/i18n/rebind/util/AbstractResource.java b/user/src/com/google/gwt/i18n/rebind/util/AbstractResource.java
index c741324..a2bb3a5 100644
--- a/user/src/com/google/gwt/i18n/rebind/util/AbstractResource.java
+++ b/user/src/com/google/gwt/i18n/rebind/util/AbstractResource.java
@@ -46,6 +46,16 @@
*/
public static final int REPORT_KEYS_THRESHOLD = 30;
+ private final List alternativeParents = new ArrayList();
+
+ private Set keySet;
+
+ private Locale locale;
+
+ private String path;
+
+ private AbstractResource primaryParent;
+
/**
* @see java.util.ResourceBundle#getLocale()
*/
@@ -137,9 +147,9 @@
}
throw new IllegalArgumentException(
- key
- + " is not a valid resource key as it does not occur in the default version of "
- + this + " nor in any of " + alternativeParents);
+ key
+ + " is not a valid resource key as it does not occur in the default version of "
+ + this + " nor in any of " + alternativeParents);
}
}
}
@@ -155,11 +165,10 @@
s = parent.getObjectAux(key, false);
}
if ((s == null) && (alternativeParents.size() > 0)
- && (useAlternativeParents)) {
+ && (useAlternativeParents)) {
for (int i = 0; (i < alternativeParents.size()) && (s == null); i++) {
// Alternate parents may look at their alternative parents.
- AbstractResource altParent = (AbstractResource) alternativeParents
- .get(i);
+ AbstractResource altParent = (AbstractResource) alternativeParents.get(i);
s = altParent.getObjectAux(key, true);
}
}
@@ -213,10 +222,4 @@
element.toVerboseStringAux(indent + 1, buf);
}
}
-
- private final List alternativeParents = new ArrayList();
- private Set keySet;
- private Locale locale;
- private String path;
- private AbstractResource primaryParent;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/util/LocalizedPropertiesResource.java b/user/src/com/google/gwt/i18n/rebind/util/LocalizedPropertiesResource.java
index 1ba2af3..79dd8d4 100644
--- a/user/src/com/google/gwt/i18n/rebind/util/LocalizedPropertiesResource.java
+++ b/user/src/com/google/gwt/i18n/rebind/util/LocalizedPropertiesResource.java
@@ -37,7 +37,9 @@
LocalizedPropertiesResource bundle = new LocalizedPropertiesResource(m);
return bundle;
}
- }
+ }
+
+ private LocalizedProperties props;
public LocalizedPropertiesResource(InputStream m) {
props = new LocalizedProperties();
@@ -59,6 +61,4 @@
public String toString() {
return getPath();
}
-
- private LocalizedProperties props;
}
diff --git a/user/src/com/google/gwt/i18n/rebind/util/ResourceFactory.java b/user/src/com/google/gwt/i18n/rebind/util/ResourceFactory.java
index 7647851..cd2f0b5 100644
--- a/user/src/com/google/gwt/i18n/rebind/util/ResourceFactory.java
+++ b/user/src/com/google/gwt/i18n/rebind/util/ResourceFactory.java
@@ -30,6 +30,27 @@
* Creates resources.
*/
public abstract class ResourceFactory {
+ static class SimplePathTree extends AbstractPathTree {
+ String path;
+
+ SimplePathTree(String path) {
+ this.path = path;
+ }
+
+ public AbstractPathTree getChild(int i) {
+ throw new UnsupportedOperationException(
+ "Simple paths have no children, therefore cannot get child: " + i);
+ }
+
+ public String getPath() {
+ return path;
+ }
+
+ public int numChildren() {
+ return 0;
+ }
+ }
+
private abstract static class AbstractPathTree {
abstract AbstractPathTree getChild(int i);
@@ -39,6 +60,8 @@
}
private static class ClassPathTree extends AbstractPathTree {
+ Class javaInterface;
+
ClassPathTree(Class javaInterface) {
this.javaInterface = javaInterface;
}
@@ -55,11 +78,11 @@
int numChildren() {
return javaInterface.getInterfaces().length;
}
-
- Class javaInterface;
}
private static class JClassTypePathTree extends AbstractPathTree {
+ JClassType javaInterface;
+
JClassTypePathTree(JClassType javaInterface) {
this.javaInterface = javaInterface;
}
@@ -84,29 +107,6 @@
int numChildren() {
return javaInterface.getImplementedInterfaces().length;
}
-
- JClassType javaInterface;
- }
-
- static class SimplePathTree extends AbstractPathTree {
- SimplePathTree(String path) {
- this.path = path;
- }
-
- public AbstractPathTree getChild(int i) {
- throw new UnsupportedOperationException(
- "Simple paths have no children, therefore cannot get child: " + i);
- }
-
- public String getPath() {
- return path;
- }
-
- public int numChildren() {
- return 0;
- }
-
- String path;
}
public static final AbstractResource NOT_FOUND = new AbstractResource() {
@@ -123,6 +123,10 @@
private static Map cache = new HashMap();
private static List loaders = new ArrayList();
+ static {
+ loaders.add(new LocalizedPropertiesResource.Factory());
+ }
+
/**
* Clears the resource cache.
*/
@@ -140,7 +144,7 @@
public static AbstractResource getBundle(Class javaInterface, Locale locale) {
if (javaInterface.isInterface() == false) {
throw new IllegalArgumentException(javaInterface
- + " should be an interface.");
+ + " should be an interface.");
}
ClassPathTree path = new ClassPathTree(javaInterface);
return getBundleAux(path, locale, true);
@@ -202,8 +206,8 @@
if (locale != null) {
if (!("".equals(locale.getVariant()))) {
// parents, by default, share the list of alternativePaths;
- parent = getBundleAux(tree, new Locale(locale.getLanguage(), locale
- .getCountry()), false);
+ parent = getBundleAux(tree, new Locale(locale.getLanguage(),
+ locale.getCountry()), false);
} else if (!"".equals(locale.getCountry())) {
parent = getBundleAux(tree, new Locale(locale.getLanguage()), false);
}
@@ -268,8 +272,8 @@
cache.put(localizedPath, found);
if (found == null && required) {
throw new MissingResourceException(
- "Could not find any resource associated with " + tree.getPath(), null,
- null);
+ "Could not find any resource associated with " + tree.getPath(),
+ null, null);
}
return found;
}
@@ -277,8 +281,4 @@
abstract String getExt();
abstract AbstractResource load(InputStream m);
-
- static {
- loaders.add(new LocalizedPropertiesResource.Factory());
- }
}
diff --git a/user/src/com/google/gwt/i18n/tools/I18NCreator.java b/user/src/com/google/gwt/i18n/tools/I18NCreator.java
index 6253911..79459d0 100755
--- a/user/src/com/google/gwt/i18n/tools/I18NCreator.java
+++ b/user/src/com/google/gwt/i18n/tools/I18NCreator.java
@@ -37,7 +37,7 @@
/**
* Utility class to handle class name argument.
- *
+ *
*/
protected class ArgHandlerClassName extends ArgHandlerExtra {
@@ -49,8 +49,9 @@
// Check className for certain properties
if (!arg.matches("[\\w\\$]+(\\.[\\w\\$]+)+")) {
- System.err.println("'" + arg
- + "' does not appear to be a valid fully-qualified Java class name.");
+ System.err.println("'"
+ + arg
+ + "' does not appear to be a valid fully-qualified Java class name.");
return false;
}
@@ -58,14 +59,14 @@
//
if (arg.indexOf('$') != -1) {
System.err.println("'" + arg
- + "': This version of the tool does not support nested classes");
+ + "': This version of the tool does not support nested classes");
return false;
}
String[] parts = arg.split("\\.");
if (parts.length < 2) {
System.err.println("'" + arg
- + "': Cannot live in the root package. Please specify a package.");
+ + "': Cannot live in the root package. Please specify a package.");
return false;
}
@@ -78,7 +79,7 @@
}
public String[] getTagArgs() {
- return new String[]{"interfaceName"};
+ return new String[] {"interfaceName"};
}
public boolean isRequired() {
@@ -88,6 +89,12 @@
private static final String PACKAGE_PATH;
+ static {
+ String path = I18NCreator.class.getName();
+ path = path.substring(0, path.lastIndexOf('.') + 1);
+ PACKAGE_PATH = path.replace('.', '/');
+ }
+
public static void main(String[] args) {
I18NCreator creator = new I18NCreator();
if (creator.processArgs(args)) {
@@ -119,8 +126,8 @@
// Figure out what platform we're on
//
- boolean isWindows = gwtDevPath.substring(gwtDevPath.lastIndexOf('/') + 1)
- .indexOf("windows") >= 0;
+ boolean isWindows = gwtDevPath.substring(gwtDevPath.lastIndexOf('/') + 1).indexOf(
+ "windows") >= 0;
// If the path from here to the install directory is relative, we need to
// set specific "base" directory tags; this is for sample creation during
@@ -170,19 +177,19 @@
if (createMessagesInterface) {
// Create a skeleton i18n messages properties class
File i18nMessageProperties = Utility.createNormalFile(clientDir,
- interfaceName + ".properties", overwrite, ignore);
+ interfaceName + ".properties", overwrite, ignore);
if (i18nMessageProperties != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "i18nMessages.propertiessrc");
+ + "i18nMessages.propertiessrc");
Utility.writeTemplateFile(i18nMessageProperties, out, replacements);
}
} else {
// Create a skeleton i18n constants properties class
File i18nConstantProperties = Utility.createNormalFile(clientDir,
- interfaceName + ".properties", overwrite, ignore);
+ interfaceName + ".properties", overwrite, ignore);
if (i18nConstantProperties != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "i18nConstants.propertiessrc");
+ + "i18nConstants.propertiessrc");
Utility.writeTemplateFile(i18nConstantProperties, out, replacements);
}
}
@@ -191,10 +198,10 @@
// Create an eclipse localizable creator launch config
replacements.put("@projectName", eclipse);
File updateLaunchConfig = Utility.createNormalFile(outDir, interfaceName
- + "-i18n" + ".launch", overwrite, ignore);
+ + "-i18n" + ".launch", overwrite, ignore);
if (updateLaunchConfig != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "I18N-update.launchsrc");
+ + "I18N-update.launchsrc");
Utility.writeTemplateFile(updateLaunchConfig, out, replacements);
}
}
@@ -207,10 +214,10 @@
extension = "";
}
File gwti18n = Utility.createNormalFile(outDir, interfaceName + "-i18n"
- + extension, overwrite, ignore);
+ + extension, overwrite, ignore);
if (gwti18n != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH + "gwti18n"
- + extension + "src");
+ + extension + "src");
Utility.writeTemplateFile(gwti18n, out, replacements);
if (extension.length() == 0) {
Runtime.getRuntime().exec("chmod u+x " + gwti18n.getAbsolutePath());
@@ -218,6 +225,15 @@
}
}
+ private boolean createMessagesInterface = false;
+
+ private String eclipse = null;
+
+ private String fullInterfaceName = null;
+ private boolean ignore = false;
+ private File outDir;
+ private boolean overwrite = false;
+
protected I18NCreator() {
registerHandler(new ArgHandlerEclipse() {
@@ -254,7 +270,7 @@
public String getPurpose() {
return "Create scripts for a Messages interface "
- + "rather than a Constants one";
+ + "rather than a Constants one";
}
public String getTag() {
@@ -285,24 +301,11 @@
protected boolean run() {
try {
createLocalizable(fullInterfaceName, outDir, eclipse,
- createMessagesInterface, overwrite, ignore);
+ createMessagesInterface, overwrite, ignore);
return true;
} catch (IOException e) {
System.err.println(e.getClass().getName() + ": " + e.getMessage());
return false;
}
}
-
- static {
- String path = I18NCreator.class.getName();
- path = path.substring(0, path.lastIndexOf('.') + 1);
- PACKAGE_PATH = path.replace('.', '/');
- }
-
- private boolean createMessagesInterface = false;
- private String eclipse = null;
- private String fullInterfaceName = null;
- private boolean ignore = false;
- private File outDir;
- private boolean overwrite = false;
}
diff --git a/user/src/com/google/gwt/i18n/tools/I18NSync.java b/user/src/com/google/gwt/i18n/tools/I18NSync.java
index 15eab1c..3d496aa 100644
--- a/user/src/com/google/gwt/i18n/tools/I18NSync.java
+++ b/user/src/com/google/gwt/i18n/tools/I18NSync.java
@@ -145,7 +145,7 @@
public static void createConstantsWithLookupInterfaceFromClassName(
String className) throws IOException {
createLocalizableInterfaceFromClassName(className, null,
- ConstantsWithLookup.class);
+ ConstantsWithLookup.class);
}
/**
@@ -159,7 +159,7 @@
public static void createConstantsWithLookupInterfaceFromClassName(
String className, File outDir) throws IOException {
createLocalizableInterfaceFromClassName(className, outDir,
- ConstantsWithLookup.class);
+ ConstantsWithLookup.class);
}
/**
@@ -202,11 +202,34 @@
System.exit(1);
}
+ static void checkValidJavaSourceOutputFile(File targetSource)
+ throws IOException {
+
+ if (targetSource.isDirectory()) {
+ throw new IOException("Output file'" + targetSource
+ + "' exists and is a directory; cannot overwrite");
+ }
+ if (targetSource.getParentFile().isDirectory() == false) {
+ throw new IOException("The target source's directory '"
+ + targetSource.getParent() + "' must be an existing directory");
+ }
+ }
+
+ static void checkValidResourceInputFile(File resource) throws IOException {
+ if (!resource.getPath().endsWith(".properties")) {
+ throw new IOException("Properties files " + resource
+ + " should end with '.properties'");
+ }
+ if (!resource.exists() || !resource.isFile()) {
+ throw new IOException("Properties file not found: " + resource);
+ }
+ }
+
private static void checkValidSourceDir(File outDir) throws IOException {
if (outDir.isDirectory() == false) {
throw new IOException(outDir
- + " must be an existing directory. Current path is "
- + new File(".").getCanonicalPath());
+ + " must be an existing directory. Current path is "
+ + new File(".").getCanonicalPath());
}
}
@@ -221,7 +244,7 @@
checkValidSourceDir(sourceDir);
String sourcePath = className.replace('.', File.separatorChar);
sourcePath = sourceDir.getCanonicalFile() + File.separator + sourcePath
- + ".java";
+ + ".java";
source = new File(sourcePath);
}
// Need both source path and class name for this check
@@ -234,10 +257,10 @@
AbstractLocalizableInterfaceCreator creator;
if (interfaceClass.equals(Messages.class)) {
creator = new MessagesInterfaceCreator(name, packageName, resource,
- source);
+ source);
} else {
creator = new ConstantsInterfaceCreator(name, packageName, resource,
- source, interfaceClass);
+ source, interfaceClass);
}
creator.generate();
}
@@ -246,7 +269,7 @@
String javaPath = resource.getName();
javaPath = javaPath.substring(0, javaPath.lastIndexOf("."));
javaPath = resource.getParentFile().getPath() + File.separator + javaPath
- + ".java";
+ + ".java";
File targetClassFile = new File(javaPath);
return targetClassFile;
}
@@ -254,45 +277,29 @@
private static File urlToResourceFile(String className)
throws FileNotFoundException, IOException {
if (className.endsWith(".java") || className.endsWith(".properties")
- || className.endsWith(".class") || className.indexOf(File.separator) > 0) {
+ || className.endsWith(".class")
+ || className.indexOf(File.separator) > 0) {
throw new IllegalArgumentException(
- "class '"
- + className
- + "'should not contain an extension. \"com.google.gwt.SomeClass\" is an example of a correctly formed class string");
+ "class '"
+ + className
+ + "'should not contain an extension. \"com.google.gwt.SomeClass\" is an example of a correctly formed class string");
}
String resourcePath = className.replace('.', '/') + ".properties";
URL r = ClassLoader.getSystemResource(resourcePath);
if (r == null) {
throw new FileNotFoundException("Could not find the resource '"
- + resourcePath + " matching '" + className
- + "' did you remember to add it to your classpath?");
+ + resourcePath + " matching '" + className
+ + "' did you remember to add it to your classpath?");
}
File resourceFile = new File(r.getFile());
return resourceFile;
}
- static void checkValidJavaSourceOutputFile(File targetSource)
- throws IOException {
+ private String classNameArg;
- if (targetSource.isDirectory()) {
- throw new IOException("Output file'" + targetSource
- + "' exists and is a directory; cannot overwrite");
- }
- if (targetSource.getParentFile().isDirectory() == false) {
- throw new IOException("The target source's directory '"
- + targetSource.getParent() + "' must be an existing directory");
- }
- }
+ private boolean createMessagesArg = false;
- static void checkValidResourceInputFile(File resource) throws IOException {
- if (!resource.getPath().endsWith(".properties")) {
- throw new IOException("Properties files " + resource
- + " should end with '.properties'");
- }
- if (!resource.exists() || !resource.isFile()) {
- throw new IOException("Properties file not found: " + resource);
- }
- }
+ private File outDirArg;
private I18NSync() {
registerHandler(new classNameArgHandler());
@@ -334,8 +341,4 @@
return false;
}
}
-
- private String classNameArg;
- private boolean createMessagesArg = false;
- private File outDirArg;
}
diff --git a/user/src/com/google/gwt/json/client/JSONArray.java b/user/src/com/google/gwt/json/client/JSONArray.java
index b9ed7f1..736028b 100644
--- a/user/src/com/google/gwt/json/client/JSONArray.java
+++ b/user/src/com/google/gwt/json/client/JSONArray.java
@@ -22,6 +22,10 @@
*/
public class JSONArray extends JSONValue {
+ final JavaScriptObject javascriptArray;
+
+ final JavaScriptObject wrappedArray;
+
/**
* Creates an empty JSONArray.
*/
@@ -145,7 +149,4 @@
var x = this.@com.google.gwt.json.client.JSONArray::wrappedArray[index];
return x !== undefined;
}-*/;
-
- final JavaScriptObject javascriptArray;
- final JavaScriptObject wrappedArray;
}
diff --git a/user/src/com/google/gwt/json/client/JSONBoolean.java b/user/src/com/google/gwt/json/client/JSONBoolean.java
index d82402a..02084ce 100644
--- a/user/src/com/google/gwt/json/client/JSONBoolean.java
+++ b/user/src/com/google/gwt/json/client/JSONBoolean.java
@@ -40,6 +40,8 @@
}
}
+ private final boolean value;
+
/*
* This private constructor is used to build true and false.
*/
@@ -68,6 +70,4 @@
public String toString() {
return Boolean.toString(value);
}
-
- private final boolean value;
}
diff --git a/user/src/com/google/gwt/json/client/JSONNumber.java b/user/src/com/google/gwt/json/client/JSONNumber.java
index 285c435..d34897a 100644
--- a/user/src/com/google/gwt/json/client/JSONNumber.java
+++ b/user/src/com/google/gwt/json/client/JSONNumber.java
@@ -20,6 +20,8 @@
*/
public class JSONNumber extends JSONValue {
+ private double value;
+
/**
* Creates a new JSONNumber from the double value.
*/
@@ -47,6 +49,4 @@
public String toString() {
return new Double(value).toString();
}
-
- private double value;
}
diff --git a/user/src/com/google/gwt/json/client/JSONObject.java b/user/src/com/google/gwt/json/client/JSONObject.java
index a5f6d05..6221085 100644
--- a/user/src/com/google/gwt/json/client/JSONObject.java
+++ b/user/src/com/google/gwt/json/client/JSONObject.java
@@ -25,10 +25,14 @@
* set of {@link com.google.gwt.json.client.JSONValue} objects.
*/
public class JSONObject extends JSONValue {
+ private final JavaScriptObject backStore;
+
+ private final JavaScriptObject frontStore = createBlankObject();
+
public JSONObject() {
backStore = createBlankObject();
}
-
+
/**
* Creates a new JSONObject from the supplied JavaScript value.
*/
@@ -83,14 +87,14 @@
*/
public Set keySet() {
Set keySet = new HashSet();
- addAllKeysFromJavascriptObject(keySet, frontStore);
+ addAllKeysFromJavascriptObject(keySet, frontStore);
addAllKeysFromJavascriptObject(keySet, backStore);
return keySet;
}
/**
- * Maps the specified key to the specified value in this JSONObject.
- * If the specified key already has an associated value, it is overwritten.
+ * Maps the specified key to the specified value in this JSONObject. If the
+ * specified key already has an associated value, it is overwritten.
*
* @param key the key to associate with the specified value
* @param jsonValue the value to assoociate with this key
@@ -109,7 +113,7 @@
public int size() {
return keySet().size();
}
-
+
/**
* Converts a JSONObject into a JSON representation that can be used to
* communicate with a JSON service.
@@ -152,7 +156,4 @@
private native JavaScriptObject createBlankObject() /*-{
return {};
}-*/;
-
- private final JavaScriptObject backStore;
- private final JavaScriptObject frontStore = createBlankObject();
}
diff --git a/user/src/com/google/gwt/json/client/JSONString.java b/user/src/com/google/gwt/json/client/JSONString.java
index e43ab44..ecc1014 100644
--- a/user/src/com/google/gwt/json/client/JSONString.java
+++ b/user/src/com/google/gwt/json/client/JSONString.java
@@ -42,6 +42,8 @@
return out;
}-*/;
+ private String value;
+
/**
* Creates a new JSONString from the supplied String.
*
@@ -61,14 +63,14 @@
public JSONString isString() {
return this;
}
-
+
/**
* Returns the raw Java string value of this item.
*/
public String stringValue() {
return value;
}
-
+
/**
* Returns the JSON formatted value of this string, quoted for evaluating in a
* JavaScript interpreter.
@@ -83,6 +85,4 @@
});
return "\"" + s + "\"";
}-*/;
-
- private String value;
}
diff --git a/user/src/com/google/gwt/json/client/JSONValue.java b/user/src/com/google/gwt/json/client/JSONValue.java
index d2c1b0c..6b2c8e3 100644
--- a/user/src/com/google/gwt/json/client/JSONValue.java
+++ b/user/src/com/google/gwt/json/client/JSONValue.java
@@ -26,16 +26,6 @@
*/
public abstract class JSONValue {
/**
- * Returns non-null if this JSONValue is really a JSONObject.
- *
- * @return a reference to a JSONObject if this JSONValue is a JSONObject or
- * <code>null</code> otherwise.
- */
- public JSONObject isObject() {
- return null;
- }
-
- /**
* Returns a non-null reference if this JSONValue is really a JSONArray.
*
* @return a reference to a JSONArray if this JSONValue is a JSONArray or
@@ -46,26 +36,6 @@
}
/**
- * Returns a non-null reference if this JSONValue is really a JSONString.
- *
- * @return a reference to a JSONString if this JSONValue is a JSONString or
- * <code>null</code> otherwise.
- */
- public JSONString isString() {
- return null;
- }
-
- /**
- * Returns a non-null reference if this JSONValue is really a JSONNumber.
- *
- * @return a reference to a JSONNumber if this JSONValue is a JSONNumber or
- * <code>null</code> otherwise.
- */
- public JSONNumber isNumber() {
- return null;
- }
-
- /**
* Returns a non-null reference if this JSONValue is really a JSONBoolean.
*
* @return a reference to a JSONBoolean if this JSONValue is a JSONBoolean or
@@ -86,6 +56,36 @@
}
/**
+ * Returns a non-null reference if this JSONValue is really a JSONNumber.
+ *
+ * @return a reference to a JSONNumber if this JSONValue is a JSONNumber or
+ * <code>null</code> otherwise.
+ */
+ public JSONNumber isNumber() {
+ return null;
+ }
+
+ /**
+ * Returns non-null if this JSONValue is really a JSONObject.
+ *
+ * @return a reference to a JSONObject if this JSONValue is a JSONObject or
+ * <code>null</code> otherwise.
+ */
+ public JSONObject isObject() {
+ return null;
+ }
+
+ /**
+ * Returns a non-null reference if this JSONValue is really a JSONString.
+ *
+ * @return a reference to a JSONString if this JSONValue is a JSONString or
+ * <code>null</code> otherwise.
+ */
+ public JSONString isString() {
+ return null;
+ }
+
+ /**
* Returns a JSON-encoded string for this entity. Use this method to create
* JSON strings that can be sent from the client to a server.
*/
diff --git a/user/src/com/google/gwt/junit/JUnitMessageQueue.java b/user/src/com/google/gwt/junit/JUnitMessageQueue.java
index a5df082..8545b79 100644
--- a/user/src/com/google/gwt/junit/JUnitMessageQueue.java
+++ b/user/src/com/google/gwt/junit/JUnitMessageQueue.java
@@ -35,6 +35,18 @@
public class JUnitMessageQueue {
/**
+ * Maps the name of a test class to the method that should be run. Access must
+ * be synchronized.
+ */
+ private final Map nameMap = new HashMap();
+
+ /**
+ * Maps the name of a test class to the last results to be reported. Access
+ * must be synchronized.
+ */
+ private final Map resultsMap = new HashMap();
+
+ /**
* Only instantiatable within this package.
*/
JUnitMessageQueue() {
@@ -135,16 +147,4 @@
nameMap.notifyAll();
}
}
-
- /**
- * Maps the name of a test class to the method that should be run. Access must
- * be synchronized.
- */
- private final Map nameMap = new HashMap();
-
- /**
- * Maps the name of a test class to the last results to be reported. Access
- * must be synchronized.
- */
- private final Map resultsMap = new HashMap();
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/junit/JUnitShell.java b/user/src/com/google/gwt/junit/JUnitShell.java
index 24e7aca..f278af4 100644
--- a/user/src/com/google/gwt/junit/JUnitShell.java
+++ b/user/src/com/google/gwt/junit/JUnitShell.java
@@ -90,6 +90,11 @@
*/
private static JUnitShell unitTestShell;
+ static {
+ ModuleDefLoader.forceInherit("com.google.gwt.junit.JUnit");
+ ModuleDefLoader.setEnableCachingModules(true);
+ }
+
/**
* Called by {@link com.google.gwt.junit.server.JUnitHostImpl} to get an
* interface into the test process.
@@ -135,6 +140,32 @@
}
/**
+ * When headless, all logging goes to the console.
+ */
+ private PrintWriterTreeLogger consoleLogger;
+
+ /**
+ * Portal to interact with the servlet.
+ */
+ private JUnitMessageQueue messageQueue = new JUnitMessageQueue();
+
+ /**
+ * What type of test we're running; Local hosted, local web, or remote web.
+ */
+ private RunStyle runStyle = new RunStyleLocalHosted(this);
+
+ /**
+ * The time at which the current test will fail if the client has not yet
+ * started the test.
+ */
+ private long testBeginTimout;
+
+ /**
+ * Class name of the current/last test case to run.
+ */
+ private String testCaseClassName;
+
+ /**
* Enforce the singleton pattern. The call to {@link GWTShell}'s ctor forces
* server mode and disables processing extra arguments as URLs to be shown.
*/
@@ -169,7 +200,7 @@
}
public String[] getTagArgs() {
- return new String[]{"rmiUrl"};
+ return new String[] {"rmiUrl"};
}
public boolean isUndocumented() {
@@ -266,10 +297,10 @@
*/
protected boolean notDone() {
if (messageQueue.hasNextTestName(testCaseClassName)
- && testBeginTimout < System.currentTimeMillis()) {
+ && testBeginTimout < System.currentTimeMillis()) {
throw new TimeoutException(
- "The browser did not contact the server within "
- + TEST_BEGIN_TIMEOUT_MILLIS + "ms.");
+ "The browser did not contact the server within "
+ + TEST_BEGIN_TIMEOUT_MILLIS + "ms.");
}
if (messageQueue.hasResult(testCaseClassName)) {
@@ -282,7 +313,7 @@
void compileForWebMode(String moduleName) throws UnableToCompleteException {
BrowserWidgetHost browserHost = getBrowserHost();
assert (browserHost != null);
- browserHost.compile(new String[]{moduleName});
+ browserHost.compile(new String[] {moduleName});
}
/**
@@ -328,8 +359,7 @@
// Match either a non-whitespace, non start of quoted string, or a
// quoted string that can have embedded, escaped quoting characters
//
- Pattern pattern = Pattern
- .compile("[^\\s\"]+|\"[^\"\\\\]*(\\\\.[^\"\\\\]*)*\"");
+ Pattern pattern = Pattern.compile("[^\\s\"]+|\"[^\"\\\\]*(\\\\.[^\"\\\\]*)*\"");
Matcher matcher = pattern.matcher(args);
while (matcher.find()) {
argList.add(matcher.group());
@@ -338,35 +368,4 @@
return (String[]) argList.toArray(new String[argList.size()]);
}
-
- static {
- ModuleDefLoader.forceInherit("com.google.gwt.junit.JUnit");
- ModuleDefLoader.setEnableCachingModules(true);
- }
-
- /**
- * When headless, all logging goes to the console.
- */
- private PrintWriterTreeLogger consoleLogger;
-
- /**
- * Portal to interact with the servlet.
- */
- private JUnitMessageQueue messageQueue = new JUnitMessageQueue();
-
- /**
- * What type of test we're running; Local hosted, local web, or remote web.
- */
- private RunStyle runStyle = new RunStyleLocalHosted(this);
-
- /**
- * The time at which the current test will fail if the client has not yet
- * started the test.
- */
- private long testBeginTimout;
-
- /**
- * Class name of the current/last test case to run.
- */
- private String testCaseClassName;
}
diff --git a/user/src/com/google/gwt/junit/RunStyleLocalHosted.java b/user/src/com/google/gwt/junit/RunStyleLocalHosted.java
index 827e93b..0a7696f 100644
--- a/user/src/com/google/gwt/junit/RunStyleLocalHosted.java
+++ b/user/src/com/google/gwt/junit/RunStyleLocalHosted.java
@@ -24,6 +24,16 @@
class RunStyleLocalHosted extends RunStyle {
/**
+ * The containing shell.
+ */
+ protected final JUnitShell shell;
+
+ /**
+ * A browser window to host local tests.
+ */
+ private BrowserWidget browserWindow;
+
+ /**
* @param shell the containing shell
*/
RunStyleLocalHosted(JUnitShell shell) {
@@ -49,14 +59,4 @@
}
browserWindow.go(url);
}
-
- /**
- * The containing shell.
- */
- protected final JUnitShell shell;
-
- /**
- * A browser window to host local tests.
- */
- private BrowserWidget browserWindow;
}
diff --git a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
index 5118fd5..13c5d8c 100644
--- a/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
+++ b/user/src/com/google/gwt/junit/RunStyleRemoteWeb.java
@@ -32,6 +32,21 @@
private static final int PING_KEEPALIVE_MS = 2000;
/**
+ * A remote browser manager.
+ */
+ private final BrowserManager browserManager;
+
+ /**
+ * A local reference to a remote browser process.
+ */
+ private int remoteToken = 0;
+
+ /**
+ * The containing shell.
+ */
+ private final JUnitShell shell;
+
+ /**
* @param shell the containing shell
*/
public RunStyleRemoteWeb(JUnitShell shell, BrowserManager browserManager) {
@@ -50,17 +65,16 @@
throw new RuntimeException("Unable to determine my ip address", e);
}
String url = "http://" + localhost + ":" + shell.getPort() + "/"
- + moduleName;
+ + moduleName;
try {
if (remoteToken > 0) {
browserManager.killBrowser(remoteToken);
remoteToken = 0;
}
- remoteToken = browserManager
- .launchNewBrowser(url, INITIAL_KEEPALIVE_MS);
+ remoteToken = browserManager.launchNewBrowser(url, INITIAL_KEEPALIVE_MS);
} catch (Exception e) {
shell.getTopLogger().log(TreeLogger.ERROR,
- "Error launching remote browser", e);
+ "Error launching remote browser", e);
throw new UnableToCompleteException();
}
}
@@ -72,26 +86,11 @@
browserManager.keepAlive(remoteToken, PING_KEEPALIVE_MS);
} catch (Exception e) {
shell.getTopLogger().log(TreeLogger.WARN,
- "Unexpected exception keeping remote browser alive", e);
+ "Unexpected exception keeping remote browser alive", e);
return true;
}
}
return false;
}
- /**
- * A remote browser manager.
- */
- private final BrowserManager browserManager;
-
- /**
- * A local reference to a remote browser process.
- */
- private int remoteToken = 0;
-
- /**
- * The containing shell.
- */
- private final JUnitShell shell;
-
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/junit/client/GWTTestCase.java b/user/src/com/google/gwt/junit/client/GWTTestCase.java
index 2ad1d0c..ceb7c83 100644
--- a/user/src/com/google/gwt/junit/client/GWTTestCase.java
+++ b/user/src/com/google/gwt/junit/client/GWTTestCase.java
@@ -36,6 +36,11 @@
*/
public abstract class GWTTestCase extends TestCase {
+ /*
+ * Object that collects the results of this test case execution.
+ */
+ private TestResult testResult = null;
+
/**
* Add a checkpoint message to the current test. If this test fails, all
* checkpoint messages will be appended to the exception description. This can
@@ -171,9 +176,4 @@
protected final void runTest() throws Throwable {
JUnitShell.runTest(getModuleName(), this, testResult);
}
-
- /*
- * Object that collects the results of this test case execution.
- */
- private TestResult testResult = null;
}
diff --git a/user/src/com/google/gwt/junit/client/impl/ExceptionWrapper.java b/user/src/com/google/gwt/junit/client/impl/ExceptionWrapper.java
index b5b0924..1c010b9 100644
--- a/user/src/com/google/gwt/junit/client/impl/ExceptionWrapper.java
+++ b/user/src/com/google/gwt/junit/client/impl/ExceptionWrapper.java
@@ -25,6 +25,26 @@
public final class ExceptionWrapper implements IsSerializable {
/**
+ * Corresponds to {@link Throwable#getCause()}.
+ */
+ public ExceptionWrapper cause;
+
+ /**
+ * Corresponds to {@link Throwable#getMessage()}.
+ */
+ public String message;
+
+ /**
+ * Corresponds to {@link Throwable#getStackTrace()}.
+ */
+ public StackTraceWrapper[] stackTrace;
+
+ /**
+ * The run-time type of the exception.
+ */
+ public String typeName;
+
+ /**
* Creates an empty {@link ExceptionWrapper}.
*/
public ExceptionWrapper() {
@@ -45,24 +65,4 @@
}
}
- /**
- * Corresponds to {@link Throwable#getCause()}.
- */
- public ExceptionWrapper cause;
-
- /**
- * Corresponds to {@link Throwable#getMessage()}.
- */
- public String message;
-
- /**
- * Corresponds to {@link Throwable#getStackTrace()}.
- */
- public StackTraceWrapper[] stackTrace;
-
- /**
- * The run-time type of the exception.
- */
- public String typeName;
-
}
diff --git a/user/src/com/google/gwt/junit/client/impl/StackTraceWrapper.java b/user/src/com/google/gwt/junit/client/impl/StackTraceWrapper.java
index 3d6ca7d..be2f853 100644
--- a/user/src/com/google/gwt/junit/client/impl/StackTraceWrapper.java
+++ b/user/src/com/google/gwt/junit/client/impl/StackTraceWrapper.java
@@ -40,25 +40,6 @@
}
/**
- * Creates an empty {@link StackTraceWrapper}.
- */
- public StackTraceWrapper() {
- }
-
- /**
- * Creates a {@link StackTraceWrapper} around an existing
- * {@link StackTraceElement}.
- *
- * @param ste the {@link StackTraceElement} to wrap.
- */
- public StackTraceWrapper(StackTraceElement ste) {
- className = ste.getClassName();
- fileName = ste.getFileName();
- lineNumber = ste.getLineNumber();
- methodName = ste.getMethodName();
- }
-
- /**
* Corresponds to {@link StackTraceElement#getClassName()}.
*/
public String className;
@@ -77,4 +58,23 @@
* Corresponds to {@link StackTraceElement#getMethodName()}.
*/
public String methodName;
+
+ /**
+ * Creates an empty {@link StackTraceWrapper}.
+ */
+ public StackTraceWrapper() {
+ }
+
+ /**
+ * Creates a {@link StackTraceWrapper} around an existing
+ * {@link StackTraceElement}.
+ *
+ * @param ste the {@link StackTraceElement} to wrap.
+ */
+ public StackTraceWrapper(StackTraceElement ste) {
+ className = ste.getClassName();
+ fileName = ste.getFileName();
+ lineNumber = ste.getLineNumber();
+ methodName = ste.getMethodName();
+ }
}
diff --git a/user/src/com/google/gwt/junit/remote/BrowserManagerServer.java b/user/src/com/google/gwt/junit/remote/BrowserManagerServer.java
index 0653524..18f0d7a 100644
--- a/user/src/com/google/gwt/junit/remote/BrowserManagerServer.java
+++ b/user/src/com/google/gwt/junit/remote/BrowserManagerServer.java
@@ -106,6 +106,23 @@
}
/**
+ * The key associated with <code>process</code> in
+ * <code>processByToken</code>.
+ */
+ private Object key;
+
+ /**
+ * If non-null, the active TimerTask which will kill <code>process</code>
+ * when it fires.
+ */
+ private KillTask killTask;
+
+ /**
+ * The managed child process.
+ */
+ private final Process process;
+
+ /**
* Constructs a new ProcessManager for the specified process, and adds
* itself to <code>processByToken</code> using the supplied key. You must
* hold the lock on <code>processByToken</code> to call this method.
@@ -182,23 +199,6 @@
timer.schedule(killTask, keepAliveMs);
}
}
-
- /**
- * The key associated with <code>process</code> in
- * <code>processByToken</code>.
- */
- private Object key;
-
- /**
- * If non-null, the active TimerTask which will kill <code>process</code>
- * when it fires.
- */
- private KillTask killTask;
-
- /**
- * The managed child process.
- */
- private final Process process;
}
/**
@@ -242,6 +242,30 @@
}
/**
+ * The shell command to launch when a new browser is requested.
+ */
+ private final String launchCmd;
+
+ /**
+ * The next token that will be returned from
+ * {@link #launchNewBrowser(String, long)}.
+ */
+ private int nextToken = 1;
+
+ /**
+ * Master map of tokens onto ProcessManagers managing live processes. Also
+ * serves as a lock that must be held before any state-changing operations on
+ * this class may be performed.
+ */
+ private final Map processByToken = new HashMap();
+
+ /**
+ * A single shared Timer used by all instances of
+ * {@link ProcessManager.KillTask}.
+ */
+ private final Timer timer = new Timer();
+
+ /**
* Constructs a manager for a particular shell command.
*
* @param launchCmd the path to a browser's executable, suitable for passing
@@ -321,28 +345,4 @@
+ "' for '" + url + "'", e);
}
}
-
- /**
- * The shell command to launch when a new browser is requested.
- */
- private final String launchCmd;
-
- /**
- * The next token that will be returned from
- * {@link #launchNewBrowser(String, long)}.
- */
- private int nextToken = 1;
-
- /**
- * Master map of tokens onto ProcessManagers managing live processes. Also
- * serves as a lock that must be held before any state-changing operations on
- * this class may be performed.
- */
- private final Map processByToken = new HashMap();
-
- /**
- * A single shared Timer used by all instances of
- * {@link ProcessManager.KillTask}.
- */
- private final Timer timer = new Timer();
}
diff --git a/user/src/com/google/gwt/junit/remote/BrowserManagerTest.java b/user/src/com/google/gwt/junit/remote/BrowserManagerTest.java
index 188924b..9caeb6b 100644
--- a/user/src/com/google/gwt/junit/remote/BrowserManagerTest.java
+++ b/user/src/com/google/gwt/junit/remote/BrowserManagerTest.java
@@ -26,12 +26,6 @@
private static final int KEEP_ALIVE_MICROSECONDS = 5000;
/**
- * Not instantiable.
- */
- private BrowserManagerTest() {
- }
-
- /**
* Causes the server at the specified URL to launch a window to www.google.com
* for 5 seconds, then close it.
*
@@ -46,4 +40,10 @@
BrowserManager browserManager = (BrowserManager) Naming.lookup(args[0]);
browserManager.launchNewBrowser("www.google.com", KEEP_ALIVE_MICROSECONDS);
}
+
+ /**
+ * Not instantiable.
+ */
+ private BrowserManagerTest() {
+ }
}
diff --git a/user/src/com/google/gwt/junit/tools/JUnitCreator.java b/user/src/com/google/gwt/junit/tools/JUnitCreator.java
index 078eb10..2b3a7d2 100644
--- a/user/src/com/google/gwt/junit/tools/JUnitCreator.java
+++ b/user/src/com/google/gwt/junit/tools/JUnitCreator.java
@@ -88,6 +88,12 @@
private static final String PACKAGE_PATH;
+ static {
+ String path = JUnitCreator.class.getName();
+ path = path.substring(0, path.lastIndexOf('.') + 1);
+ PACKAGE_PATH = path.replace('.', '/');
+ }
+
public static void main(String[] args) {
JUnitCreator creator = new JUnitCreator();
if (creator.processArgs(args)) {
@@ -251,6 +257,16 @@
}
}
+ private String eclipse = null;
+
+ private String fullClassName = null;
+
+ private boolean ignore = false;
+ private String junitPath = null;
+ private String moduleName = null;
+ private File outDir;
+ private boolean overwrite = false;
+
protected JUnitCreator() {
registerHandler(new ArgHandlerString() {
@@ -369,18 +385,4 @@
return false;
}
}
-
- static {
- String path = JUnitCreator.class.getName();
- path = path.substring(0, path.lastIndexOf('.') + 1);
- PACKAGE_PATH = path.replace('.', '/');
- }
-
- private String eclipse = null;
- private String fullClassName = null;
- private boolean ignore = false;
- private String junitPath = null;
- private String moduleName = null;
- private File outDir;
- private boolean overwrite = false;
}
diff --git a/user/src/com/google/gwt/user/client/DOM.java b/user/src/com/google/gwt/user/client/DOM.java
index 98d2946..09b7b13 100644
--- a/user/src/com/google/gwt/user/client/DOM.java
+++ b/user/src/com/google/gwt/user/client/DOM.java
@@ -702,6 +702,11 @@
impl.insertChild(parent, child, index);
}
+ public static void insertListItem(Element select, String item, String value,
+ int index) {
+ impl.insertListItem(select, item, value, index);
+ }
+
/**
* Determine whether one element is equal to, or the child of, another.
*
@@ -855,6 +860,17 @@
}
/**
+ * Sets the option text of the given select object.
+ *
+ * @param select the select object whose option text is being set
+ * @param text the text to set
+ * @param index the index of the option whose text should be set
+ */
+ public static void setOptionText(Element select, String text, int index) {
+ impl.setOptionText(select, text, index);
+ }
+
+ /**
* Sets an attribute on the given element's style.
*
* @param elem the element whose style attribute is to be set
@@ -951,20 +967,4 @@
// Pass the event to the listener.
listener.onBrowserEvent(evt);
}
-
- public static void insertListItem(Element select, String item, String value,
- int index) {
- impl.insertListItem(select, item, value, index);
- }
-
- /**
- * Sets the option text of the given select object.
- *
- * @param select the select object whose option text is being set
- * @param text the text to set
- * @param index the index of the option whose text should be set
- */
- public static void setOptionText(Element select, String text, int index) {
- impl.setOptionText(select, text, index);
- }
}
diff --git a/user/src/com/google/gwt/user/client/HTTPRequest.java b/user/src/com/google/gwt/user/client/HTTPRequest.java
index 7bd85a2..1f3f8bd 100644
--- a/user/src/com/google/gwt/user/client/HTTPRequest.java
+++ b/user/src/com/google/gwt/user/client/HTTPRequest.java
@@ -24,8 +24,32 @@
*/
public class HTTPRequest {
- private static final HTTPRequestImpl httpRequest = (HTTPRequestImpl) GWT
- .create(HTTPRequestImpl.class);
+ private static final HTTPRequestImpl httpRequest = (HTTPRequestImpl) GWT.create(HTTPRequestImpl.class);
+
+ /**
+ * Makes an asynchronous HTTP GET to a remote server.
+ *
+ * @param url the absolute url to GET
+ * @param handler the response handler to be notified when either the request
+ * fails, or is completed successfully
+ * @return <code>false</code> if the invocation fails to issue
+ */
+ public static boolean asyncGet(String url, ResponseTextHandler handler) {
+ return httpRequest.asyncGet(url, handler);
+ }
+
+ /**
+ * Makes an asynchronous HTTP GET to a remote server.
+ *
+ * @param url the absolute url to GET
+ * @param handler the response handler to be notified when either the request
+ * fails, or is completed successfully
+ * @return <code>false</code> if the invocation fails to issue
+ */
+ public static boolean asyncGet(String user, String pwd, String url,
+ ResponseTextHandler handler) {
+ return httpRequest.asyncGet(user, pwd, url, handler);
+ };
/**
* Makes an asynchronous HTTP POST to a remote server.
@@ -54,29 +78,4 @@
String postData, ResponseTextHandler handler) {
return httpRequest.asyncPost(user, pwd, url, postData, handler);
};
-
- /**
- * Makes an asynchronous HTTP GET to a remote server.
- *
- * @param url the absolute url to GET
- * @param handler the response handler to be notified when either the request
- * fails, or is completed successfully
- * @return <code>false</code> if the invocation fails to issue
- */
- public static boolean asyncGet(String url, ResponseTextHandler handler) {
- return httpRequest.asyncGet(url, handler);
- }
-
- /**
- * Makes an asynchronous HTTP GET to a remote server.
- *
- * @param url the absolute url to GET
- * @param handler the response handler to be notified when either the request
- * fails, or is completed successfully
- * @return <code>false</code> if the invocation fails to issue
- */
- public static boolean asyncGet(String user, String pwd, String url,
- ResponseTextHandler handler) {
- return httpRequest.asyncGet(user, pwd, url, handler);
- };
}
diff --git a/user/src/com/google/gwt/user/client/History.java b/user/src/com/google/gwt/user/client/History.java
index e7cd054..ff1a82b 100644
--- a/user/src/com/google/gwt/user/client/History.java
+++ b/user/src/com/google/gwt/user/client/History.java
@@ -121,6 +121,15 @@
}
}
+ /**
+ * Removes a history listener.
+ *
+ * @param listener the listener to be removed
+ */
+ public static void removeHistoryListener(HistoryListener listener) {
+ historyListeners.remove(listener);
+ }
+
private static void fireHistoryChangedAndCatch(String historyToken,
UncaughtExceptionHandler handler) {
try {
@@ -136,13 +145,4 @@
listener.onHistoryChanged(historyToken);
}
}
-
- /**
- * Removes a history listener.
- *
- * @param listener the listener to be removed
- */
- public static void removeHistoryListener(HistoryListener listener) {
- historyListeners.remove(listener);
- }
}
diff --git a/user/src/com/google/gwt/user/client/Random.java b/user/src/com/google/gwt/user/client/Random.java
index 305d2d9..2ad1805 100644
--- a/user/src/com/google/gwt/user/client/Random.java
+++ b/user/src/com/google/gwt/user/client/Random.java
@@ -24,14 +24,6 @@
public final class Random {
/**
- * Not instantiable. Having different instances of this class would not be
- * meaningful because no state is stored and the common browser implementation
- * is shared.
- */
- private Random() {
- }
-
- /**
* Returns true or false with roughly equal probability. The underlying
* browser's random implementation is used.
*/
@@ -68,4 +60,12 @@
// "~~" forces the value to a 32 bit integer.
return ~~(Math.floor(Math.random() * upperBound));
}-*/;
+
+ /**
+ * Not instantiable. Having different instances of this class would not be
+ * meaningful because no state is stored and the common browser implementation
+ * is shared.
+ */
+ private Random() {
+ }
}
diff --git a/user/src/com/google/gwt/user/client/Timer.java b/user/src/com/google/gwt/user/client/Timer.java
index 7ff8b2e..62e20f2 100644
--- a/user/src/com/google/gwt/user/client/Timer.java
+++ b/user/src/com/google/gwt/user/client/Timer.java
@@ -37,6 +37,10 @@
private static ArrayList timers = new ArrayList();
+ static {
+ hookWindowClosing();
+ }
+
private static native void clearInterval(int id) /*-{
$wnd.clearInterval(id);
}-*/;
@@ -75,6 +79,10 @@
});
}
+ private boolean isRepeating;
+
+ private int timerId;
+
/**
* Cancels this timer.
*/
@@ -155,11 +163,4 @@
// Run the timer's code.
run();
}
-
- static {
- hookWindowClosing();
- }
-
- private boolean isRepeating;
- private int timerId;
}
diff --git a/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java b/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java
index a24e104..6d3415d 100644
--- a/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java
+++ b/user/src/com/google/gwt/user/client/impl/HTTPRequestImpl.java
@@ -24,6 +24,15 @@
*/
public class HTTPRequestImpl {
+ public boolean asyncGet(String url, ResponseTextHandler handler) {
+ return asyncGet(null, null, url, handler);
+ }
+
+ public boolean asyncGet(String user, String pwd, String url,
+ ResponseTextHandler handler) {
+ return asyncGetImpl(user, pwd, url, handler);
+ }
+
public boolean asyncPost(String url, String postData,
ResponseTextHandler handler) {
return asyncPost(null, null, url, postData, handler);
@@ -34,53 +43,19 @@
return asyncPostImpl(user, pwd, url, postData, handler);
}
- public boolean asyncGet(String url, ResponseTextHandler handler) {
- return asyncGet(null, null, url, handler);
- }
-
- public boolean asyncGet(String user, String pwd, String url,
- ResponseTextHandler handler) {
- return asyncGetImpl(user, pwd, url, handler);
- }
-
public JavaScriptObject createXmlHTTPRequest() {
return doCreateXmlHTTPRequest();
}
/**
- * All the supported browsers except for IE instantiate it as shown.
+ * All the supported browsers except for IE instantiate it as shown.
*/
protected native JavaScriptObject doCreateXmlHTTPRequest() /*-{
return new XMLHttpRequest();
}-*/;
- private native boolean asyncPostImpl(String user, String pwd, String url, String postData, ResponseTextHandler handler) /*-{
- var xmlHttp = this.@com.google.gwt.user.client.impl.HTTPRequestImpl::doCreateXmlHTTPRequest()();
- try {
- xmlHttp.open("POST", url, true);
- xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
- xmlHttp.onreadystatechange = function() {
- if (xmlHttp.readyState == 4) {
- delete xmlHttp.onreadystatechange;
- var localHandler = handler;
- var responseText = xmlHttp.responseText;
- handler = null;
- xmlHttp = null;
- localHandler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/lang/String;)(responseText);
- }
- };
- xmlHttp.send(postData);
- return true;
- }
- catch (e) {
- delete xmlHttp.onreadystatechange;
- handler = null;
- xmlHttp = null;
- return false;
- }
- }-*/;
-
- private native boolean asyncGetImpl(String user, String pwd, String url, ResponseTextHandler handler) /*-{
+ private native boolean asyncGetImpl(String user, String pwd, String url,
+ ResponseTextHandler handler) /*-{
var xmlHttp = this.@com.google.gwt.user.client.impl.HTTPRequestImpl::doCreateXmlHTTPRequest()();
try {
xmlHttp.open("GET", url, true);
@@ -105,4 +80,31 @@
return false;
}
}-*/;
+
+ private native boolean asyncPostImpl(String user, String pwd, String url,
+ String postData, ResponseTextHandler handler) /*-{
+ var xmlHttp = this.@com.google.gwt.user.client.impl.HTTPRequestImpl::doCreateXmlHTTPRequest()();
+ try {
+ xmlHttp.open("POST", url, true);
+ xmlHttp.setRequestHeader("Content-Type", "text/plain; charset=utf-8");
+ xmlHttp.onreadystatechange = function() {
+ if (xmlHttp.readyState == 4) {
+ delete xmlHttp.onreadystatechange;
+ var localHandler = handler;
+ var responseText = xmlHttp.responseText;
+ handler = null;
+ xmlHttp = null;
+ localHandler.@com.google.gwt.user.client.ResponseTextHandler::onCompletion(Ljava/lang/String;)(responseText);
+ }
+ };
+ xmlHttp.send(postData);
+ return true;
+ }
+ catch (e) {
+ delete xmlHttp.onreadystatechange;
+ handler = null;
+ xmlHttp = null;
+ return false;
+ }
+ }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/impl/HistoryImpl.java b/user/src/com/google/gwt/user/client/impl/HistoryImpl.java
index a987d20..59ea0b1 100644
--- a/user/src/com/google/gwt/user/client/impl/HistoryImpl.java
+++ b/user/src/com/google/gwt/user/client/impl/HistoryImpl.java
@@ -23,11 +23,13 @@
*/
public abstract class HistoryImpl {
- public abstract boolean init();
- public abstract String getToken();
- public abstract void newItem(String historyToken);
-
protected static void onHistoryChanged(String historyToken) {
History.onHistoryChanged(historyToken);
}
+
+ public abstract String getToken();
+
+ public abstract boolean init();
+
+ public abstract void newItem(String historyToken);
}
diff --git a/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java b/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java
index 833e925..307097b 100644
--- a/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java
+++ b/user/src/com/google/gwt/user/client/impl/HistoryImplIE6.java
@@ -21,6 +21,10 @@
*/
class HistoryImplIE6 extends HistoryImpl {
+ public native String getToken() /*-{
+ return $wnd.__historyToken;
+ }-*/;
+
public native boolean init() /*-{
// Check for existence of the history frame.
var historyFrame = $doc.getElementById('__gwt_historyFrame');
@@ -80,10 +84,6 @@
return true;
}-*/;
- public native String getToken() /*-{
- return $wnd.__historyToken;
- }-*/;
-
public native void newItem(String historyToken) /*-{
var iframe = $doc.getElementById('__gwt_historyFrame');
iframe.contentWindow.location.href = 'history.html?' + historyToken;
diff --git a/user/src/com/google/gwt/user/client/impl/HistoryImplSafari.java b/user/src/com/google/gwt/user/client/impl/HistoryImplSafari.java
index 573a9ad..e777c67 100644
--- a/user/src/com/google/gwt/user/client/impl/HistoryImplSafari.java
+++ b/user/src/com/google/gwt/user/client/impl/HistoryImplSafari.java
@@ -20,6 +20,10 @@
*/
class HistoryImplSafari extends HistoryImpl {
+ public native String getToken() /*-{
+ return $wnd.__historyToken;
+ }-*/;
+
public native boolean init() /*-{
// Check for existence of the history frame.
var historyFrame = $doc.getElementById('__gwt_historyFrame');
@@ -70,10 +74,6 @@
return true;
}-*/;
- public native String getToken() /*-{
- return $wnd.__historyToken;
- }-*/;
-
public native void newItem(String historyToken) /*-{
var iframe = $doc.getElementById('__gwt_historyFrame');
iframe.contentWindow.location.href = 'history.html?' + historyToken;
diff --git a/user/src/com/google/gwt/user/client/impl/HistoryImplStandard.java b/user/src/com/google/gwt/user/client/impl/HistoryImplStandard.java
index dbece9e..10c66f0 100644
--- a/user/src/com/google/gwt/user/client/impl/HistoryImplStandard.java
+++ b/user/src/com/google/gwt/user/client/impl/HistoryImplStandard.java
@@ -20,6 +20,10 @@
*/
class HistoryImplStandard extends HistoryImpl {
+ public native String getToken() /*-{
+ return $wnd.__historyToken;
+ }-*/;
+
public native boolean init() /*-{
$wnd.__historyToken = '';
@@ -48,10 +52,6 @@
return true;
}-*/;
- public native String getToken() /*-{
- return $wnd.__historyToken;
- }-*/;
-
public native void newItem(String historyToken) /*-{
if(historyToken == "" || historyToken == null){
historyToken = "#";
diff --git a/user/src/com/google/gwt/user/client/rpc/SerializableException.java b/user/src/com/google/gwt/user/client/rpc/SerializableException.java
index db3a94d..7bfe77b 100644
--- a/user/src/com/google/gwt/user/client/rpc/SerializableException.java
+++ b/user/src/com/google/gwt/user/client/rpc/SerializableException.java
@@ -21,6 +21,8 @@
*/
public class SerializableException extends Exception implements IsSerializable {
+ private String msg;
+
/**
* The default constructor. This constructor is used implicitly during
* serialization or when constructing subclasses.
@@ -57,6 +59,4 @@
// nothing
return null;
}
-
- private String msg;
}
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java b/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
index fb123bd..94ae2e3 100644
--- a/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
+++ b/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStream.java
@@ -25,6 +25,10 @@
public static final int SERIALIZATION_STREAM_FLAGS_NO_TYPE_VERSIONING = 1;
public static final int SERIALIZATION_STREAM_VERSION = 2;
+ protected int flags = 0;
+
+ protected int version;
+
public final void addFlags(int flags) {
this.flags |= flags;
}
@@ -48,7 +52,4 @@
protected final void setVersion(int version) {
this.version = version;
}
-
- protected int flags = 0;
- protected int version;
}
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStreamReader.java b/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStreamReader.java
index 1d69aab..4f4b59a 100644
--- a/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStreamReader.java
+++ b/user/src/com/google/gwt/user/client/rpc/impl/AbstractSerializationStreamReader.java
@@ -28,8 +28,10 @@
public abstract class AbstractSerializationStreamReader extends
AbstractSerializationStream implements SerializationStreamReader {
+ private ArrayList seenArray = new ArrayList();
+
public void prepareToRead(String encoded) throws SerializationException {
- fSeenArray.clear();
+ seenArray.clear();
// Read the stream version number
//
@@ -46,7 +48,7 @@
if (token < 0) {
// Negative means a previous object
// Transform negative 1-based to 0-based.
- return fSeenArray.get(-(token + 1));
+ return seenArray.get(-(token + 1));
}
// Positive means a new object
@@ -78,9 +80,7 @@
protected abstract String getString(int index);
protected final void rememberDecodedObject(Object o) {
- fSeenArray.add(o);
+ seenArray.add(o);
}
- private ArrayList fSeenArray = new ArrayList();
-
}
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamReader.java b/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamReader.java
index 1306dc0..c15fa8a 100644
--- a/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamReader.java
+++ b/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamReader.java
@@ -32,6 +32,14 @@
return array.length;
}-*/;
+ int index;
+
+ JavaScriptObject results;
+
+ JavaScriptObject stringTable;
+
+ private Serializer serializer;
+
public ClientSerializationStreamReader(Serializer serializer) {
this.serializer = serializer;
}
@@ -79,7 +87,8 @@
return getString(readInt());
}
- protected Object deserialize(String typeSignature) throws SerializationException {
+ protected Object deserialize(String typeSignature)
+ throws SerializationException {
Object instance = serializer.instantiate(this, typeSignature);
rememberDecodedObject(instance);
serializer.deserialize(this, instance, typeSignature);
@@ -98,9 +107,4 @@
return this.@com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::results[--this.@com.google.gwt.user.client.rpc.impl.ClientSerializationStreamReader::index];
}-*/;
- int index;
- JavaScriptObject results;
- JavaScriptObject stringTable;
- private Serializer serializer;
-
}
diff --git a/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamWriter.java b/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamWriter.java
index 040f84b..ebaa8bc 100644
--- a/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamWriter.java
+++ b/user/src/com/google/gwt/user/client/rpc/impl/ClientSerializationStreamWriter.java
@@ -37,6 +37,18 @@
return {};
}-*/;
+ JavaScriptObject objectMap;
+
+ JavaScriptObject stringMap;
+
+ private StringBuffer encodeBuffer;
+
+ private int objectCount;
+
+ private Serializer serializer;
+
+ private ArrayList stringTable = new ArrayList();
+
public ClientSerializationStreamWriter(Serializer serializer) {
this.serializer = serializer;
}
@@ -101,7 +113,8 @@
setIntForInt(System.identityHashCode(instance), objectCount++);
}
- protected void serialize(Object instance, String typeSignature) throws SerializationException {
+ protected void serialize(Object instance, String typeSignature)
+ throws SerializationException {
serializer.serialize(this, instance, typeSignature);
}
@@ -141,11 +154,4 @@
return buffer;
}
- JavaScriptObject objectMap;
- JavaScriptObject stringMap;
- private StringBuffer encodeBuffer;
- private int objectCount;
- private Serializer serializer;
- private ArrayList stringTable = new ArrayList();
-
}
diff --git a/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java b/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java
index d6c8b72..e8b6e55 100644
--- a/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java
+++ b/user/src/com/google/gwt/user/client/ui/AbsolutePanel.java
@@ -64,6 +64,28 @@
}
/**
+ * Gets the left position of the specified widget within the panel.
+ *
+ * @param w the widget whose position is to be retrieved
+ * @return the widget's left position
+ */
+ public int getWidgetLeft(Widget w) {
+ checkWidgetParent(w);
+ return DOM.getIntAttribute(w.getElement(), "offsetLeft");
+ }
+
+ /**
+ * Gets the top position of the specified widget within the panel.
+ *
+ * @param w the widget whose position is to be retrieved
+ * @return the widget's top position
+ */
+ public int getWidgetTop(Widget w) {
+ checkWidgetParent(w);
+ return DOM.getIntAttribute(w.getElement(), "offsetTop");
+ }
+
+ /**
* Sets the position of the specified child widget. Setting a position of
* <code>(-1, -1)</code> will cause the child widget to be positioned
* statically.
@@ -87,32 +109,10 @@
}
}
- /**
- * Gets the left position of the specified widget within the panel.
- *
- * @param w the widget whose position is to be retrieved
- * @return the widget's left position
- */
- public int getWidgetLeft(Widget w) {
- checkWidgetParent(w);
- return DOM.getIntAttribute(w.getElement(), "offsetLeft");
- }
-
- /**
- * Gets the top position of the specified widget within the panel.
- *
- * @param w the widget whose position is to be retrieved
- * @return the widget's top position
- */
- public int getWidgetTop(Widget w) {
- checkWidgetParent(w);
- return DOM.getIntAttribute(w.getElement(), "offsetTop");
- }
-
private void checkWidgetParent(Widget w) {
if (w.getParent() != this) {
throw new IllegalArgumentException(
- "Widget must be a child of this panel.");
+ "Widget must be a child of this panel.");
}
}
}
diff --git a/user/src/com/google/gwt/user/client/ui/CellPanel.java b/user/src/com/google/gwt/user/client/ui/CellPanel.java
index 3bfd7a6..a4450ea 100644
--- a/user/src/com/google/gwt/user/client/ui/CellPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/CellPanel.java
@@ -37,14 +37,6 @@
setElement(table);
}
- protected Element getTable() {
- return table;
- }
-
- protected Element getBody() {
- return body;
- }
-
/**
* Gets the amount of spacing between this panel's cells.
*
@@ -128,6 +120,14 @@
DOM.setIntAttribute(table, "cellSpacing", spacing);
}
+ protected Element getBody() {
+ return body;
+ }
+
+ protected Element getTable() {
+ return table;
+ }
+
private Element getWidgetTd(Widget w) {
if (w.getParent() != this) {
return null;
diff --git a/user/src/com/google/gwt/user/client/ui/ComplexPanel.java b/user/src/com/google/gwt/user/client/ui/ComplexPanel.java
index 0bd6fec..e6cdc6c 100644
--- a/user/src/com/google/gwt/user/client/ui/ComplexPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/ComplexPanel.java
@@ -44,22 +44,6 @@
}
/**
- * Inserts a new child widget into the panel.
- *
- * @param w the child widget to be added
- * @param container the element within which the child will be contained
- * @param beforeIndex the index before which the widget will be added
- */
- protected void insert(Widget w, Element container, int beforeIndex) {
- if (w.getParent() == this) {
- return;
- }
-
- adopt(w, container);
- children.insert(w, beforeIndex);
- }
-
- /**
* Adds a new child widget to the panel.
*
* @param w the child widget to be added
@@ -77,4 +61,20 @@
protected WidgetCollection getChildren() {
return children;
}
+
+ /**
+ * Inserts a new child widget into the panel.
+ *
+ * @param w the child widget to be added
+ * @param container the element within which the child will be contained
+ * @param beforeIndex the index before which the widget will be added
+ */
+ protected void insert(Widget w, Element container, int beforeIndex) {
+ if (w.getParent() == this) {
+ return;
+ }
+
+ adopt(w, container);
+ children.insert(w, beforeIndex);
+ }
}
diff --git a/user/src/com/google/gwt/user/client/ui/DockPanel.java b/user/src/com/google/gwt/user/client/ui/DockPanel.java
index 1b7f03e..9d886ee 100644
--- a/user/src/com/google/gwt/user/client/ui/DockPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/DockPanel.java
@@ -108,7 +108,7 @@
if (direction == CENTER) {
if (center != null) {
throw new IllegalArgumentException(
- "Only one CENTER widget may be added");
+ "Only one CENTER widget may be added");
}
center = widget;
}
@@ -214,6 +214,30 @@
}
/**
+ * Used by {@link #realizeTable(Widget)} to ensure that super.add() is called
+ * at the right time for newly added widgets.
+ *
+ * @param parent the parent element (always a TD)
+ * @param child the child element to be added
+ * @param beingAdded the widget that is currently being added to the
+ * DockPanel, if any
+ */
+ private void appendAndMaybeAdopt(Element parent, Element child,
+ Widget beingAdded) {
+ if (beingAdded != null) {
+ // If beingAdded is specified, and the child element is beingAdded's
+ // element, then call super.add() on its behalf.
+ if (DOM.compare(child, beingAdded.getElement())) {
+ super.add(beingAdded, parent);
+ return;
+ }
+ }
+
+ // Normal case -- just append it.
+ DOM.appendChild(parent, child);
+ }
+
+ /**
* Creates the table representing the DockPanel. This method uses the local
* list of children in {@link #children}, because when add() is called, the
* superclass' child list doesn't yet contain the new child.
@@ -299,28 +323,4 @@
appendAndMaybeAdopt(centerTd, center.getElement(), beingAdded);
}
}
-
- /**
- * Used by {@link #realizeTable(Widget)} to ensure that super.add() is called
- * at the right time for newly added widgets.
- *
- * @param parent the parent element (always a TD)
- * @param child the child element to be added
- * @param beingAdded the widget that is currently being added to the
- * DockPanel, if any
- */
- private void appendAndMaybeAdopt(Element parent, Element child,
- Widget beingAdded) {
- if (beingAdded != null) {
- // If beingAdded is specified, and the child element is beingAdded's
- // element, then call super.add() on its behalf.
- if (DOM.compare(child, beingAdded.getElement())) {
- super.add(beingAdded, parent);
- return;
- }
- }
-
- // Normal case -- just append it.
- DOM.appendChild(parent, child);
- }
}
diff --git a/user/src/com/google/gwt/user/client/ui/FastStringMap.java b/user/src/com/google/gwt/user/client/ui/FastStringMap.java
index 76cb113..1e4fe9e 100644
--- a/user/src/com/google/gwt/user/client/ui/FastStringMap.java
+++ b/user/src/com/google/gwt/user/client/ui/FastStringMap.java
@@ -37,6 +37,10 @@
class FastStringMap extends AbstractMap {
private static class ImplMapEntry implements Map.Entry {
+ private Object key;
+
+ private Object value;
+
ImplMapEntry(String key, Object value) {
this.key = key;
this.value = value;
@@ -46,7 +50,7 @@
if (a instanceof Map.Entry) {
Map.Entry s = (Map.Entry) a;
if (equalsWithNullCheck(key, s.getKey())
- && equalsWithNullCheck(value, s.getValue())) {
+ && equalsWithNullCheck(value, s.getValue())) {
return true;
}
}
@@ -88,11 +92,10 @@
return a.equals(b);
}
}
-
- private Object key;
- private Object value;
}
+ JavaScriptObject map;
+
public FastStringMap() {
init();
}
@@ -125,6 +128,8 @@
public Iterator iterator() {
Iterator custom = new Iterator() {
+ Iterator keys = keySet().iterator();
+
public boolean hasNext() {
return keys.hasNext();
}
@@ -137,8 +142,6 @@
public void remove() {
keys.remove();
}
-
- Iterator keys = keySet().iterator();
};
return custom;
}
@@ -254,7 +257,7 @@
return (String) key;
} else {
throw new IllegalArgumentException(GWT.getTypeName(this)
- + " can only have Strings as keys, not" + key);
+ + " can only have Strings as keys, not" + key);
}
}
@@ -268,6 +271,4 @@
}
}-*/;
- JavaScriptObject map;
-
}
diff --git a/user/src/com/google/gwt/user/client/ui/FlexTable.java b/user/src/com/google/gwt/user/client/ui/FlexTable.java
index cee0ad5..7ffa760 100644
--- a/user/src/com/google/gwt/user/client/ui/FlexTable.java
+++ b/user/src/com/google/gwt/user/client/ui/FlexTable.java
@@ -92,6 +92,14 @@
}
}
+ private static native void addCells(Element table, int row, int num)/*-{
+ var rowElem = table.rows[row];
+ for(var i = 0; i < num; i++){
+ var cell = $doc.createElement("td");
+ rowElem.appendChild(cell);
+ }
+ }-*/;
+
public FlexTable() {
super();
setCellFormatter(new FlexCellFormatter());
@@ -196,7 +204,7 @@
prepareRow(row);
if (column < 0) {
throw new IndexOutOfBoundsException(
- "Cannot create a column with a negative index: " + column);
+ "Cannot create a column with a negative index: " + column);
}
// Ensure that the requested column exists.
@@ -216,7 +224,7 @@
protected void prepareRow(int row) {
if (row < 0) {
throw new IndexOutOfBoundsException(
- "Cannot create a row with a negative index: " + row);
+ "Cannot create a row with a negative index: " + row);
}
// Ensure that the requested row exists.
@@ -225,12 +233,4 @@
insertRow(i);
}
}
-
- private static native void addCells(Element table, int row, int num)/*-{
- var rowElem = table.rows[row];
- for(var i = 0; i < num; i++){
- var cell = $doc.createElement("td");
- rowElem.appendChild(cell);
- }
- }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/ui/FocusWidget.java b/user/src/com/google/gwt/user/client/ui/FocusWidget.java
index f10ec66..1fb3f3b 100644
--- a/user/src/com/google/gwt/user/client/ui/FocusWidget.java
+++ b/user/src/com/google/gwt/user/client/ui/FocusWidget.java
@@ -28,15 +28,25 @@
/**
* <code>FocusImpl</code> contains browser specific focus code for focusable
- * widgets. This <code>FocusImpl</code> instance is intentionally _not_ rebound, as the
- * base implementation works on all browsers for truly focusable widgets. The
- * special cases are only needed for things that aren't naturally focusable on
- * some browsers, such as DIVs.
+ * widgets. This <code>FocusImpl</code> instance is intentionally _not_
+ * rebound, as the base implementation works on all browsers for truly
+ * focusable widgets. The special cases are only needed for things that aren't
+ * naturally focusable on some browsers, such as DIVs.
*/
private static final FocusImpl impl = new FocusImpl();
+ /**
+ * Gets the FocusImpl instance.
+ *
+ * @return impl
+ */
+ protected static FocusImpl getFocusImpl() {
+ return impl;
+ }
+
private ClickListenerCollection clickListeners;
private FocusListenerCollection focusListeners;
+
private KeyboardListenerCollection keyboardListeners;
/**
@@ -151,12 +161,4 @@
public void setTabIndex(int index) {
impl.setTabIndex(getElement(), index);
}
-
- /**
- * Gets the FocusImpl instance.
- * @return impl
- */
- protected static FocusImpl getFocusImpl() {
- return impl;
- }
}
diff --git a/user/src/com/google/gwt/user/client/ui/FormHandlerCollection.java b/user/src/com/google/gwt/user/client/ui/FormHandlerCollection.java
index 1fef7fe..30fd5fa 100644
--- a/user/src/com/google/gwt/user/client/ui/FormHandlerCollection.java
+++ b/user/src/com/google/gwt/user/client/ui/FormHandlerCollection.java
@@ -27,6 +27,22 @@
public class FormHandlerCollection extends ArrayList {
/**
+ * Fires a {@link FormHandler#onSubmitComplete(FormSubmitCompleteEvent)} on
+ * all handlers in the collection.
+ *
+ * @param sender the object sending the event
+ * @param results the results of the form submission
+ */
+ public void fireOnComplete(Object sender, String results) {
+ FormSubmitCompleteEvent event = new FormSubmitCompleteEvent(sender, results);
+
+ for (Iterator it = iterator(); it.hasNext();) {
+ FormHandler handler = (FormHandler) it.next();
+ handler.onSubmitComplete(event);
+ }
+ }
+
+ /**
* Fires a {@link FormHandler#onSubmit(FormSubmitEvent)} on all handlers in
* the collection.
*
@@ -43,20 +59,4 @@
return event.isCancelled();
}
-
- /**
- * Fires a {@link FormHandler#onSubmitComplete(FormSubmitCompleteEvent)} on
- * all handlers in the collection.
- *
- * @param sender the object sending the event
- * @param results the results of the form submission
- */
- public void fireOnComplete(Object sender, String results) {
- FormSubmitCompleteEvent event = new FormSubmitCompleteEvent(sender, results);
-
- for (Iterator it = iterator(); it.hasNext();) {
- FormHandler handler = (FormHandler) it.next();
- handler.onSubmitComplete(event);
- }
- }
}
diff --git a/user/src/com/google/gwt/user/client/ui/FormSubmitEvent.java b/user/src/com/google/gwt/user/client/ui/FormSubmitEvent.java
index c850a50..55d75e7 100644
--- a/user/src/com/google/gwt/user/client/ui/FormSubmitEvent.java
+++ b/user/src/com/google/gwt/user/client/ui/FormSubmitEvent.java
@@ -34,15 +34,6 @@
}
/**
- * Sets whether the form submit will be cancelled.
- *
- * @param cancel <code>true</code> to cancel the submit
- */
- public void setCancelled(boolean cancel) {
- this.cancel = cancel;
- }
-
- /**
* Gets whether this form submit will be cancelled.
*
* @return <code>true</code> if the form submit will be cancelled
@@ -50,4 +41,13 @@
public boolean isCancelled() {
return cancel;
}
+
+ /**
+ * Sets whether the form submit will be cancelled.
+ *
+ * @param cancel <code>true</code> to cancel the submit
+ */
+ public void setCancelled(boolean cancel) {
+ this.cancel = cancel;
+ }
}
diff --git a/user/src/com/google/gwt/user/client/ui/Grid.java b/user/src/com/google/gwt/user/client/ui/Grid.java
index 4336ab7..b843c8e 100644
--- a/user/src/com/google/gwt/user/client/ui/Grid.java
+++ b/user/src/com/google/gwt/user/client/ui/Grid.java
@@ -33,6 +33,27 @@
public class Grid extends HTMLTable {
/**
+ * Native method to add rows into a table with a given number of columns.
+ *
+ * @param table the table element
+ * @param rows number of rows to add
+ * @param columns the number of columns per row
+ */
+ private static native void addRows(Element table, int rows, int columns) /*-{
+ var td = $doc.createElement("td");
+ td.innerHTML = " ";
+ var row = $doc.createElement("tr");
+ for(var cellNum = 0; cellNum < columns; cellNum++) {
+ var cell = td.cloneNode(true);
+ row.appendChild(cell);
+ }
+ table.appendChild(row);
+ for(var rowNum = 1; rowNum < rows; rowNum++) {
+ table.appendChild(row.cloneNode(true));
+ }
+ }-*/;
+
+ /**
* Number of columns in the current grid.
*/
protected int numColumns;
@@ -63,7 +84,7 @@
this();
resize(rows, columns);
}
-
+
/**
* Replaces the contents of the specified cell with a single space.
*
@@ -126,7 +147,7 @@
}
if (columns <= 0) {
throw new IndexOutOfBoundsException("Cannot set number of columns to "
- + columns);
+ + columns);
}
if (numColumns > columns) {
@@ -159,7 +180,7 @@
}
if (rows <= 0) {
throw new IndexOutOfBoundsException("Cannot set number of rows to "
- + rows);
+ + rows);
}
if (numRows < rows) {
addRows(getBodyElement(), rows - numRows, numColumns);
@@ -196,12 +217,12 @@
prepareRow(row);
if (column < 0) {
throw new IndexOutOfBoundsException(
- "Cannot access a column with a negative index: " + column);
+ "Cannot access a column with a negative index: " + column);
}
if (column >= numColumns) {
throw new IndexOutOfBoundsException("Column index: " + column
- + ", Column size: " + numColumns);
+ + ", Column size: " + numColumns);
}
}
@@ -215,7 +236,7 @@
// Ensure that the indices are not negative.
if (column < 0) {
throw new IndexOutOfBoundsException(
- "Cannot access a column with a negative index: " + column);
+ "Cannot access a column with a negative index: " + column);
}
/**
@@ -224,7 +245,7 @@
*/
if (column >= numColumns) {
throw new IndexOutOfBoundsException("Column index: " + column
- + ", Column size: " + numColumns);
+ + ", Column size: " + numColumns);
}
}
@@ -238,7 +259,7 @@
// Ensure that the indices are not negative.
if (row < 0) {
throw new IndexOutOfBoundsException(
- "Cannot access a row with a negative index: " + row);
+ "Cannot access a row with a negative index: " + row);
}
/**
@@ -247,28 +268,7 @@
*/
if (row >= numRows) {
throw new IndexOutOfBoundsException("Row index: " + row + ", Row size: "
- + numRows);
+ + numRows);
}
}
-
- /**
- * Native method to add rows into a table with a given number of columns.
- *
- * @param table the table element
- * @param rows number of rows to add
- * @param columns the number of columns per row
- */
- private static native void addRows(Element table, int rows, int columns) /*-{
- var td = $doc.createElement("td");
- td.innerHTML = " ";
- var row = $doc.createElement("tr");
- for(var cellNum = 0; cellNum < columns; cellNum++) {
- var cell = td.cloneNode(true);
- row.appendChild(cell);
- }
- table.appendChild(row);
- for(var rowNum = 1; rowNum < rows; rowNum++) {
- table.appendChild(row.cloneNode(true));
- }
- }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/ui/HTMLTable.java b/user/src/com/google/gwt/user/client/ui/HTMLTable.java
index 189f914..9b060fd 100644
--- a/user/src/com/google/gwt/user/client/ui/HTMLTable.java
+++ b/user/src/com/google/gwt/user/client/ui/HTMLTable.java
@@ -179,7 +179,7 @@
VerticalAlignmentConstant align) {
prepareCell(row, column);
DOM.setStyleAttribute(getCellElement(bodyElem, row, column),
- "verticalAlign", align.getVerticalAlignString());
+ "verticalAlign", align.getVerticalAlignString());
}
/**
@@ -226,32 +226,6 @@
}
/**
- * Native method to get a cell's element.
- *
- * @param table the table element
- * @param row the row of the cell
- * @param col the column of the cell
- * @return the element
- */
-
- private native Element getCellElement(Element table, int row, int col) /*-{
- var out = table.rows[row].cells[col];
- return (out == null ? null : out);
- }-*/;
-
- /**
- * Gets the TD element representing the specified cell unsafely (meaning
- * that it doesn't ensure that the row and column are valid).
- *
- * @param row the row of the cell to be retrieved
- * @param column the column of the cell to be retrieved
- * @return the column's TD element
- */
- private Element getRawElement(int row, int column) {
- return getCellElement(bodyElem, row, column);
- }
-
- /**
* Gets the element associated with a cell. If it does not exist and the
* subtype allows creation of elements, creates it.
*
@@ -292,6 +266,32 @@
Element elem = ensureElement(row, column);
DOM.setAttribute(elem, attrName, value);
}
+
+ /**
+ * Native method to get a cell's element.
+ *
+ * @param table the table element
+ * @param row the row of the cell
+ * @param col the column of the cell
+ * @return the element
+ */
+
+ private native Element getCellElement(Element table, int row, int col) /*-{
+ var out = table.rows[row].cells[col];
+ return (out == null ? null : out);
+ }-*/;
+
+ /**
+ * Gets the TD element representing the specified cell unsafely (meaning
+ * that it doesn't ensure that the row and column are valid).
+ *
+ * @param row the row of the cell to be retrieved
+ * @param column the column of the cell to be retrieved
+ * @return the column's TD element
+ */
+ private Element getRawElement(int row, int column) {
+ return getCellElement(bodyElem, row, column);
+ }
}
/**
@@ -299,6 +299,8 @@
* by the support cross-browser HTML support for column formatting.
*/
public class ColumnFormatter {
+ protected Element columnGroup;
+
/**
* Adds a style to the specified column.
*
@@ -347,7 +349,7 @@
Element elem = ensureColumn(column);
DOM.setAttribute(elem, "className", styleName);
}
-
+
/**
* Sets the width of the specified column.
*
@@ -378,8 +380,6 @@
}
return DOM.getChild(columnGroup, col);
}
-
- protected Element columnGroup;
}
/**
@@ -469,8 +469,8 @@
* @throws IndexOutOfBoundsException
*/
public void setVerticalAlign(int row, VerticalAlignmentConstant align) {
- DOM.setStyleAttribute(ensureElement(row), "verticalAlign", align
- .getVerticalAlignString());
+ DOM.setStyleAttribute(ensureElement(row), "verticalAlign",
+ align.getVerticalAlignString());
}
/**
@@ -520,6 +520,43 @@
private static final String HASH_ATTR = "__hash";
/**
+ * Table's body.
+ */
+ private final Element bodyElem;
+
+ /**
+ * Current cell formatter.
+ */
+ private CellFormatter cellFormatter;
+
+ /**
+ * Column Formatter.
+ */
+ private ColumnFormatter columnFormatter;
+
+ /**
+ * Current row formatter.
+ */
+ private RowFormatter rowFormatter;
+
+ /**
+ * Table element.
+ */
+ private final Element tableElem;
+
+ /**
+ * Current table listener.
+ */
+ private TableListenerCollection tableListeners;
+
+ /**
+ * The element map, used to quickly look up the Widget in a particular cell.
+ * We have to use a map here, because hanging references to Widgets from
+ * Elements would cause memory leaks.
+ */
+ private final FastStringMap widgetMap = new FastStringMap();
+
+ /**
* Create a new empty HTML Table.
*/
public HTMLTable() {
@@ -856,84 +893,6 @@
}
/**
- * Removes any widgets, text, and HTML within the cell. This method assumes
- * that the requested cell already exists.
- *
- * @param row the cell's row
- * @param column the cell's column
- * @param clearInnerHTML should the cell's inner html be cleared?
- * @return element that has been cleaned
- */
- private Element cleanCell(int row, int column, boolean clearInnerHTML) {
- // Clear whatever is in the cell.
- Element td = getCellFormatter().getRawElement(row, column);
- internalClearCell(td, clearInnerHTML);
- return td;
- }
-
- /**
- * Gets the key associated with the cell. This key is used within the widget
- * map.
- *
- * @param row the cell's row
- * @param column the cell's column
- * @return the associated key
- */
- private Object computeKey(int row, int column) {
- Element e = cellFormatter.getRawElement(row, column);
- Element child = DOM.getFirstChild(e);
- if (child == null) {
- return null;
- } else {
- return computeKeyForElement(child);
- }
- }
-
- /**
- * Computes the key to lookup the Widget.
- *
- * @param widgetElement
- * @return returns the key
- */
- private String computeKeyForElement(Element widgetElement) {
- return DOM.getAttribute(widgetElement, HASH_ATTR);
- }
-
- /**
- * Gets the Widget associated with the element.
- *
- * @param widgetElement widget's element
- * @return the widget
- */
- private Widget getWidget(Element widgetElement) {
- Object key = computeKeyForElement(widgetElement);
- if (key != null) {
- Widget widget = (Widget) widgetMap.get(key);
- assert (widget != null);
- return widget;
- } else {
- return null;
- }
- }
-
- /**
- * Removes the given widget from a cell. The widget must not be
- * <code>null</code>.
- *
- * @param widget widget to be removed
- * @return always return true
- */
- private boolean removeWidget(Widget widget) {
- // Clear the widget's parent.
- disown(widget);
-
- // Remove the widget from the map.
- Object x = widgetMap.remove(computeKeyForElement(widget.getElement()));
- assert (x != null);
- return true;
- }
-
- /**
* Bounds checks that the cell exists at the specified location.
*
* @param row cell's row
@@ -944,12 +903,12 @@
checkRowBounds(row);
if (column < 0) {
throw new IndexOutOfBoundsException("Column " + column
- + " must be non-negative: " + column);
+ + " must be non-negative: " + column);
}
int cellSize = getCellCount(row);
if (cellSize <= column) {
throw new IndexOutOfBoundsException("Column index: " + column
- + ", Column size: " + getCellCount(row));
+ + ", Column size: " + getCellCount(row));
}
}
@@ -963,7 +922,7 @@
int rowSize = getRowCount();
if ((row >= rowSize) || (row < 0)) {
throw new IndexOutOfBoundsException("Row index: " + row + ", Row size: "
- + rowSize);
+ + rowSize);
}
}
@@ -1145,9 +1104,9 @@
}
/**
- * Subclasses must implemea whaccessed. If the row already exists, this method must
- * do nothing. Otherwise, a subclass must either ensure that the row exists or
- * throw an {@link IndexOutOfBoundsException}.
+ * Subclasses must implemea whaccessed. If the row already exists, this method
+ * must do nothing. Otherwise, a subclass must either ensure that the row
+ * exists or throw an {@link IndexOutOfBoundsException}.
*
* @param row the cell's row
*/
@@ -1213,39 +1172,80 @@
}
/**
- * Table's body.
+ * Removes any widgets, text, and HTML within the cell. This method assumes
+ * that the requested cell already exists.
+ *
+ * @param row the cell's row
+ * @param column the cell's column
+ * @param clearInnerHTML should the cell's inner html be cleared?
+ * @return element that has been cleaned
*/
- private final Element bodyElem;
+ private Element cleanCell(int row, int column, boolean clearInnerHTML) {
+ // Clear whatever is in the cell.
+ Element td = getCellFormatter().getRawElement(row, column);
+ internalClearCell(td, clearInnerHTML);
+ return td;
+ }
/**
- * Current cell formatter.
+ * Gets the key associated with the cell. This key is used within the widget
+ * map.
+ *
+ * @param row the cell's row
+ * @param column the cell's column
+ * @return the associated key
*/
- private CellFormatter cellFormatter;
+ private Object computeKey(int row, int column) {
+ Element e = cellFormatter.getRawElement(row, column);
+ Element child = DOM.getFirstChild(e);
+ if (child == null) {
+ return null;
+ } else {
+ return computeKeyForElement(child);
+ }
+ }
/**
- * Column Formatter.
+ * Computes the key to lookup the Widget.
+ *
+ * @param widgetElement
+ * @return returns the key
*/
- private ColumnFormatter columnFormatter;
+ private String computeKeyForElement(Element widgetElement) {
+ return DOM.getAttribute(widgetElement, HASH_ATTR);
+ }
/**
- * Current row formatter.
+ * Gets the Widget associated with the element.
+ *
+ * @param widgetElement widget's element
+ * @return the widget
*/
- private RowFormatter rowFormatter;
+ private Widget getWidget(Element widgetElement) {
+ Object key = computeKeyForElement(widgetElement);
+ if (key != null) {
+ Widget widget = (Widget) widgetMap.get(key);
+ assert (widget != null);
+ return widget;
+ } else {
+ return null;
+ }
+ }
/**
- * Table element.
+ * Removes the given widget from a cell. The widget must not be
+ * <code>null</code>.
+ *
+ * @param widget widget to be removed
+ * @return always return true
*/
- private final Element tableElem;
+ private boolean removeWidget(Widget widget) {
+ // Clear the widget's parent.
+ disown(widget);
- /**
- * Current table listener.
- */
- private TableListenerCollection tableListeners;
-
- /**
- * The element map, used to quickly look up the Widget in a particular cell.
- * We have to use a map here, because hanging references to Widgets from
- * Elements would cause memory leaks.
- */
- private final FastStringMap widgetMap = new FastStringMap();
+ // Remove the widget from the map.
+ Object x = widgetMap.remove(computeKeyForElement(widget.getElement()));
+ assert (x != null);
+ return true;
+ }
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/user/client/ui/HasFocus.java b/user/src/com/google/gwt/user/client/ui/HasFocus.java
index bf5a58f..d868f75 100644
--- a/user/src/com/google/gwt/user/client/ui/HasFocus.java
+++ b/user/src/com/google/gwt/user/client/ui/HasFocus.java
@@ -21,6 +21,13 @@
public interface HasFocus extends SourcesFocusEvents, SourcesKeyboardEvents {
/**
+ * Gets the widget's position in the tab index.
+ *
+ * @return the widget's tab index
+ */
+ public int getTabIndex();
+
+ /**
* Sets the widget's 'access key'. This key is used (in conjunction with a
* browser-specific modifier key) to automatically focus the widget.
*
@@ -29,25 +36,18 @@
public void setAccessKey(char key);
/**
- * Explicitly focus/unfocus this widget. Only one widget can have focus
- * at a time, and the widget that does will receive all keyboard events.
+ * Explicitly focus/unfocus this widget. Only one widget can have focus at a
+ * time, and the widget that does will receive all keyboard events.
*
* @param focused whether this widget should take focus or release it
*/
public void setFocus(boolean focused);
/**
- * Gets the widget's position in the tab index.
- *
- * @return the widget's tab index
- */
- public int getTabIndex();
-
- /**
- * Sets the widget's position in the tab index. If more than one widget
- * has the same tab index, each such widget will receive focus in an
- * arbitrary order. Setting the tab index to <code>-1</code> will cause this
- * widget to be removed from the tab order.
+ * Sets the widget's position in the tab index. If more than one widget has
+ * the same tab index, each such widget will receive focus in an arbitrary
+ * order. Setting the tab index to <code>-1</code> will cause this widget to
+ * be removed from the tab order.
*
* @param index the widget's tab index
*/
diff --git a/user/src/com/google/gwt/user/client/ui/HasWidgets.java b/user/src/com/google/gwt/user/client/ui/HasWidgets.java
index 3e0588e..b40c1a0 100644
--- a/user/src/com/google/gwt/user/client/ui/HasWidgets.java
+++ b/user/src/com/google/gwt/user/client/ui/HasWidgets.java
@@ -24,12 +24,6 @@
public interface HasWidgets {
/**
- * Gets an iterator for the contained widgets. This iterator is required to
- * implement {@link Iterator#remove()}.
- */
- Iterator iterator();
-
- /**
* Adds a child widget.
*
* @param w the widget to be added
@@ -39,15 +33,21 @@
void add(Widget w);
/**
+ * Removes all child widgets.
+ */
+ void clear();
+
+ /**
+ * Gets an iterator for the contained widgets. This iterator is required to
+ * implement {@link Iterator#remove()}.
+ */
+ Iterator iterator();
+
+ /**
* Removes a child widget.
*
* @param w the widget to be removed
* @return <code>true</code> if the widget was present
*/
boolean remove(Widget w);
-
- /**
- * Removes all child widgets.
- */
- void clear();
}
diff --git a/user/src/com/google/gwt/user/client/ui/Hyperlink.java b/user/src/com/google/gwt/user/client/ui/Hyperlink.java
index 63095ca..8558299 100644
--- a/user/src/com/google/gwt/user/client/ui/Hyperlink.java
+++ b/user/src/com/google/gwt/user/client/ui/Hyperlink.java
@@ -48,7 +48,7 @@
public class Hyperlink extends Widget implements HasHTML, SourcesClickEvents {
private Element anchorElem;
- private ClickListenerCollection fClickListeners;
+ private ClickListenerCollection clickListeners;
private String targetHistoryToken;
/**
@@ -92,10 +92,10 @@
}
public void addClickListener(ClickListener listener) {
- if (fClickListeners == null) {
- fClickListeners = new ClickListenerCollection();
+ if (clickListeners == null) {
+ clickListeners = new ClickListenerCollection();
}
- fClickListeners.add(listener);
+ clickListeners.add(listener);
}
public String getHTML() {
@@ -118,8 +118,8 @@
public void onBrowserEvent(Event event) {
if (DOM.eventGetType(event) == Event.ONCLICK) {
- if (fClickListeners != null) {
- fClickListeners.fireClick(this);
+ if (clickListeners != null) {
+ clickListeners.fireClick(this);
}
History.newItem(targetHistoryToken);
DOM.eventPreventDefault(event);
@@ -127,8 +127,8 @@
}
public void removeClickListener(ClickListener listener) {
- if (fClickListeners != null) {
- fClickListeners.remove(listener);
+ if (clickListeners != null) {
+ clickListeners.remove(listener);
}
}
diff --git a/user/src/com/google/gwt/user/client/ui/ListBox.java b/user/src/com/google/gwt/user/client/ui/ListBox.java
index 4924549..4f426a3 100644
--- a/user/src/com/google/gwt/user/client/ui/ListBox.java
+++ b/user/src/com/google/gwt/user/client/ui/ListBox.java
@@ -232,6 +232,21 @@
}
/**
+ * Sets the text associated with the item at a given index.
+ *
+ * @param index the index of the item to be set
+ * @param text the item's new text
+ * @throws IndexOutOfBoundsException if the index is out of range
+ */
+ public void setItemText(int index, String text) {
+ checkIndex(index);
+ if (text == null) {
+ throw new NullPointerException("Cannot set an option to have null text");
+ }
+ DOM.setOptionText(getElement(), text, index);
+ }
+
+ /**
* Sets whether this list allows multiple selections.
*
* @param multiple <code>true</code> to allow multiple selections
@@ -254,21 +269,6 @@
}
/**
- * Sets the text associated with the item at a given index.
- *
- * @param index the index of the item to be set
- * @param text the item's new text
- * @throws IndexOutOfBoundsException if the index is out of range
- */
- public void setItemText(int index, String text) {
- checkIndex(index);
- if (text == null) {
- throw new NullPointerException("Cannot set an option to have null text");
- }
- DOM.setOptionText(getElement(), text, index);
- }
-
- /**
* Sets the value associated with the item at a given index. This value can be
* used for any purpose, but is also what is passed to the server when the
* ListBox is submitted as part of a {@link FormPanel}.
diff --git a/user/src/com/google/gwt/user/client/ui/MenuBar.java b/user/src/com/google/gwt/user/client/ui/MenuBar.java
index d04fa73..598fe63 100644
--- a/user/src/com/google/gwt/user/client/ui/MenuBar.java
+++ b/user/src/com/google/gwt/user/client/ui/MenuBar.java
@@ -40,7 +40,8 @@
* </ul>
*
* <p>
- * <h3>Example</h3> {@example com.google.gwt.examples.MenuBarExample}
+ * <h3>Example</h3>
+ * {@example com.google.gwt.examples.MenuBarExample}
* </p>
*/
public class MenuBar extends Widget implements PopupListener {
@@ -253,6 +254,15 @@
this.autoOpen = autoOpen;
}
+ protected void onDetach() {
+ // When the menu is detached, make sure to close all of its children.
+ if (popup != null) {
+ popup.hide();
+ }
+
+ super.onDetach();
+ }
+
/*
* Closes all parent menu popups.
*/
@@ -340,10 +350,10 @@
if (vertical) {
popup.setPopupPosition(item.getAbsoluteLeft() + item.getOffsetWidth(),
- item.getAbsoluteTop());
+ item.getAbsoluteTop());
} else {
popup.setPopupPosition(item.getAbsoluteLeft(), item.getAbsoluteTop()
- + item.getOffsetHeight());
+ + item.getOffsetHeight());
}
shownChildMenu = item.getSubMenu();
@@ -354,20 +364,11 @@
popup.show();
}
- protected void onDetach() {
- // When the menu is detached, make sure to close all of its children.
- if (popup != null) {
- popup.hide();
- }
-
- super.onDetach();
- }
-
void itemOver(MenuItem item) {
if (item == null) {
// Don't clear selection if the currently selected item's menu is showing.
if ((selectedItem != null)
- && (shownChildMenu == selectedItem.getSubMenu())) {
+ && (shownChildMenu == selectedItem.getSubMenu())) {
return;
}
}
diff --git a/user/src/com/google/gwt/user/client/ui/Panel.java b/user/src/com/google/gwt/user/client/ui/Panel.java
index aeed8b0..2b0b37b 100644
--- a/user/src/com/google/gwt/user/client/ui/Panel.java
+++ b/user/src/com/google/gwt/user/client/ui/Panel.java
@@ -26,6 +26,10 @@
*/
public abstract class Panel extends Widget implements HasWidgets {
+ public void add(Widget w) {
+ throw new UnsupportedOperationException("This panel does not support no-arg add()");
+ }
+
public void clear() {
Iterator it = iterator();
while (it.hasNext()) {
@@ -34,10 +38,6 @@
}
}
- public void add(Widget w) {
- throw new UnsupportedOperationException("This panel does not support no-arg add()");
- }
-
/**
* This method must be called as part of the add method of any panel. It
* ensures that the Widget's parent is set properly, and that it is removed
diff --git a/user/src/com/google/gwt/user/client/ui/ScrollPanel.java b/user/src/com/google/gwt/user/client/ui/ScrollPanel.java
index e90b3a9..5b119d1 100644
--- a/user/src/com/google/gwt/user/client/ui/ScrollPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/ScrollPanel.java
@@ -52,8 +52,8 @@
}
/**
- * Ensures that the specified item is visible, by adjusting the panel's
- * scroll position.
+ * Ensures that the specified item is visible, by adjusting the panel's scroll
+ * position.
*
* @param item the item whose visibility is to be ensured
*/
@@ -64,15 +64,6 @@
}
/**
- * Gets the vertical scroll position.
- *
- * @return the vertical scroll position, in pixels
- */
- public int getScrollPosition() {
- return DOM.getIntAttribute(getElement(), "scrollTop");
- }
-
- /**
* Gets the horizontal scroll position.
*
* @return the horizontal scroll position, in pixels
@@ -81,11 +72,20 @@
return DOM.getIntAttribute(getElement(), "scrollLeft");
}
+ /**
+ * Gets the vertical scroll position.
+ *
+ * @return the vertical scroll position, in pixels
+ */
+ public int getScrollPosition() {
+ return DOM.getIntAttribute(getElement(), "scrollTop");
+ }
+
public void onBrowserEvent(Event event) {
if (DOM.eventGetType(event) == Event.ONSCROLL) {
if (scrollListeners != null) {
scrollListeners.fireScroll(this, getHorizontalScrollPosition(),
- getScrollPosition());
+ getScrollPosition());
}
}
}
@@ -104,16 +104,7 @@
*/
public void setAlwaysShowScrollBars(boolean alwaysShow) {
DOM.setStyleAttribute(getElement(), "overflow", alwaysShow ? "scroll"
- : "auto");
- }
-
- /**
- * Sets the vertical scroll position.
- *
- * @param position the new vertical scroll position, in pixels
- */
- public void setScrollPosition(int position) {
- DOM.setIntAttribute(getElement(), "scrollTop", position);
+ : "auto");
}
/**
@@ -125,6 +116,15 @@
DOM.setIntAttribute(getElement(), "scrollLeft", position);
}
+ /**
+ * Sets the vertical scroll position.
+ *
+ * @param position the new vertical scroll position, in pixels
+ */
+ public void setScrollPosition(int position) {
+ DOM.setIntAttribute(getElement(), "scrollTop", position);
+ }
+
private native void ensureVisibleImpl(Element scroll, Element e) /*-{
if (!e)
return;
diff --git a/user/src/com/google/gwt/user/client/ui/StackPanel.java b/user/src/com/google/gwt/user/client/ui/StackPanel.java
index b770971..e4842e5 100644
--- a/user/src/com/google/gwt/user/client/ui/StackPanel.java
+++ b/user/src/com/google/gwt/user/client/ui/StackPanel.java
@@ -115,6 +115,15 @@
setStackText(getWidgetCount() - 1, stackText, asHTML);
}
+ /**
+ * Gets the currently selected child index.
+ *
+ * @return selected child
+ */
+ public int getSelectedIndex() {
+ return visibleStack;
+ }
+
public Widget getWidget(int index) {
return getChildren().get(index);
}
@@ -256,13 +265,4 @@
getWidget(index).setVisible(visible);
}
- /**
- * Gets the currently selected child index.
- *
- * @return selected child
- */
- public int getSelectedIndex() {
- return visibleStack;
- }
-
}
diff --git a/user/src/com/google/gwt/user/client/ui/Tree.java b/user/src/com/google/gwt/user/client/ui/Tree.java
index aa63875..f249bfb 100644
--- a/user/src/com/google/gwt/user/client/ui/Tree.java
+++ b/user/src/com/google/gwt/user/client/ui/Tree.java
@@ -81,7 +81,7 @@
sinkEvents(Event.MOUSEEVENTS | Event.ONCLICK | Event.KEYEVENTS);
DOM.sinkEvents(focusable, Event.FOCUSEVENTS | Event.KEYEVENTS
- | DOM.getEventsSunk(focusable));
+ | DOM.getEventsSunk(focusable));
// The 'root' item is invisible and serves only as a container
// for all top-level items.
@@ -375,7 +375,7 @@
}
}
- // Intentional fallthrough.
+ // Intentional fallthrough.
case Event.ONKEYUP:
if (eventType == Event.ONKEYUP) {
// If we got here because of a key tab, then we need to make sure the
@@ -390,7 +390,7 @@
}
}
- // Intentional fallthrough.
+ // Intentional fallthrough.
case Event.ONKEYPRESS: {
if (keyboardListeners != null) {
keyboardListeners.fireKeyboardEvent(this, event);
@@ -406,7 +406,7 @@
public boolean remove(Widget w) {
throw new UnsupportedOperationException(
- "Widgets should never be directly removed from a tree");
+ "Widgets should never be directly removed from a tree");
}
public void removeFocusListener(FocusListener listener) {
@@ -509,6 +509,56 @@
return accum.iterator();
}
+ protected void onAttach() {
+ super.onAttach();
+
+ // Ensure that all child widgets are attached.
+ for (Iterator it = iterator(); it.hasNext();) {
+ Widget child = (Widget) it.next();
+ child.onAttach();
+ }
+ }
+
+ protected void onDetach() {
+ super.onDetach();
+
+ // Ensure that all child widgets are detached.
+ for (Iterator it = iterator(); it.hasNext();) {
+ Widget child = (Widget) it.next();
+ child.onDetach();
+ }
+ }
+
+ protected void onLoad() {
+ root.updateStateRecursive();
+ }
+
+ void adopt(TreeItem.ContentPanel content) {
+ getChildWidgets().add(content);
+ content.treeSetParent(this);
+ }
+
+ void disown(TreeItem.ContentPanel item) {
+ getChildWidgets().remove(item);
+ item.treeSetParent(null);
+ }
+
+ void fireStateChanged(TreeItem item) {
+ if (listeners != null) {
+ listeners.fireItemStateChanged(item);
+ }
+ }
+
+ /**
+ * Get the Set of child widgets. Exposed only to allow unit tests to validate
+ * tree.
+ *
+ * @return the children
+ */
+ Set getChildWidgets() {
+ return childWidgets;
+ }
+
/**
* Collects parents going up the element tree, terminated at the tree root.
*/
@@ -672,56 +722,6 @@
}
}
- protected void onAttach() {
- super.onAttach();
-
- // Ensure that all child widgets are attached.
- for (Iterator it = iterator(); it.hasNext();) {
- Widget child = (Widget) it.next();
- child.onAttach();
- }
- }
-
- protected void onDetach() {
- super.onDetach();
-
- // Ensure that all child widgets are detached.
- for (Iterator it = iterator(); it.hasNext();) {
- Widget child = (Widget) it.next();
- child.onDetach();
- }
- }
-
- protected void onLoad() {
- root.updateStateRecursive();
- }
-
- void adopt(TreeItem.ContentPanel content) {
- getChildWidgets().add(content);
- content.treeSetParent(this);
- }
-
- void disown(TreeItem.ContentPanel item) {
- getChildWidgets().remove(item);
- item.treeSetParent(null);
- }
-
- void fireStateChanged(TreeItem item) {
- if (listeners != null) {
- listeners.fireItemStateChanged(item);
- }
- }
-
- /**
- * Get the Set of child widgets. Exposed only to allow unit tests to validate
- * tree.
- *
- * @return the children
- */
- Set getChildWidgets() {
- return childWidgets;
- }
-
private native boolean shouldTreeDelegateFocusToElement(Element elem) /*-{
var focus =
((elem.nodeName == "SELECT") ||
diff --git a/user/src/com/google/gwt/user/client/ui/TreeItem.java b/user/src/com/google/gwt/user/client/ui/TreeItem.java
index a2c6597..b261891 100644
--- a/user/src/com/google/gwt/user/client/ui/TreeItem.java
+++ b/user/src/com/google/gwt/user/client/ui/TreeItem.java
@@ -400,32 +400,20 @@
contentPanel.setWidget(widget);
}
- private void clearContentPanel() {
- if (contentPanel != null) {
- // Child should not be owned by anyone anymore.
- Widget child = contentPanel.getWidget();
- if (contentPanel.getWidget() != null) {
- contentPanel.remove(child);
- }
-
- // Tree should no longer own contentPanel.
- if (tree != null) {
- tree.disown(contentPanel);
- contentPanel = null;
- }
+ /**
+ * Returns the widget, if any, that should be focused on if this TreeItem is
+ * selected.
+ *
+ * @return widget to be focused.
+ */
+ protected HasFocus getFocusableWidget() {
+ Widget widget = getWidget();
+ if (widget instanceof HasFocus) {
+ return (HasFocus)widget;
+ } else {
+ return null;
}
- }
-
- private void ensureContentPanel() {
- if (contentPanel == null) {
- // Ensure contentElem is empty.
- DOM.setInnerHTML(contentElem, "");
- contentPanel = new ContentPanel(contentElem);
- if (getTree() != null) {
- tree.adopt(contentPanel);
- }
- }
- }
+ }
void addTreeItems(List accum) {
for (int i = 0; i < children.size(); i++) {
@@ -463,21 +451,6 @@
return ret;
}
- /**
- * Returns the widget, if any, that should be focused on if this TreeItem is
- * selected.
- *
- * @return widget to be focused.
- */
- protected HasFocus getFocusableWidget() {
- Widget widget = getWidget();
- if (widget instanceof HasFocus) {
- return (HasFocus)widget;
- } else {
- return null;
- }
- }
-
String imgSrc(String img) {
if (tree == null) {
return img;
@@ -542,4 +515,31 @@
}
}
+ private void clearContentPanel() {
+ if (contentPanel != null) {
+ // Child should not be owned by anyone anymore.
+ Widget child = contentPanel.getWidget();
+ if (contentPanel.getWidget() != null) {
+ contentPanel.remove(child);
+ }
+
+ // Tree should no longer own contentPanel.
+ if (tree != null) {
+ tree.disown(contentPanel);
+ contentPanel = null;
+ }
+ }
+ }
+
+ private void ensureContentPanel() {
+ if (contentPanel == null) {
+ // Ensure contentElem is empty.
+ DOM.setInnerHTML(contentElem, "");
+ contentPanel = new ContentPanel(contentElem);
+ if (getTree() != null) {
+ tree.adopt(contentPanel);
+ }
+ }
+ }
+
}
diff --git a/user/src/com/google/gwt/user/client/ui/UIObject.java b/user/src/com/google/gwt/user/client/ui/UIObject.java
index 8650f49..0d4d4aa 100644
--- a/user/src/com/google/gwt/user/client/ui/UIObject.java
+++ b/user/src/com/google/gwt/user/client/ui/UIObject.java
@@ -25,10 +25,8 @@
*/
public abstract class UIObject {
private static final String NULL_HANDLE_MSG = "Null widget handle. If you "
- + "are creating a composite, ensure that initWidget() has been called.";
+ + "are creating a composite, ensure that initWidget() has been called.";
- private Element element;
-
public static native boolean isVisible(Element elem) /*-{
return (elem.style.display != 'none');
}-*/;
@@ -53,7 +51,7 @@
}
if (style.length() == 0) {
throw new IllegalArgumentException(
- "Cannot pass is an empty string as a style name.");
+ "Cannot pass is an empty string as a style name.");
}
// Get the current style string.
@@ -72,13 +70,13 @@
int last = idx + style.length();
int lastPos = oldStyle.length();
if ((last == lastPos)
- || ((last < lastPos) && (oldStyle.charAt(last) == ' '))) {
+ || ((last < lastPos) && (oldStyle.charAt(last) == ' '))) {
break;
}
}
idx = oldStyle.indexOf(style, idx + 1);
}
-
+
if (add) {
// Only add the style if it's not already present.
if (idx == -1) {
@@ -94,6 +92,8 @@
}
}
+ private Element element;
+
/**
* Adds a style name to the widget.
*
@@ -308,7 +308,7 @@
*/
public void sinkEvents(int eventBitsToAdd) {
DOM.sinkEvents(getElement(), eventBitsToAdd
- | DOM.getEventsSunk(getElement()));
+ | DOM.getEventsSunk(getElement()));
}
/**
@@ -334,7 +334,7 @@
*/
public void unsinkEvents(int eventBitsToRemove) {
DOM.sinkEvents(getElement(), DOM.getEventsSunk(getElement())
- & (~eventBitsToRemove));
+ & (~eventBitsToRemove));
}
/**
diff --git a/user/src/com/google/gwt/user/client/ui/Widget.java b/user/src/com/google/gwt/user/client/ui/Widget.java
index 58b7051..b9f6005 100644
--- a/user/src/com/google/gwt/user/client/ui/Widget.java
+++ b/user/src/com/google/gwt/user/client/ui/Widget.java
@@ -31,16 +31,6 @@
private Widget parent;
/**
- * Gets the panel-defined layout data associated with this widget.
- *
- * @return the widget's layout data
- * @see #setLayoutData
- */
- Object getLayoutData() {
- return layoutData;
- }
-
- /**
* Gets this widget's parent panel.
*
* @return the widget's parent panel
@@ -64,22 +54,19 @@
}
/**
- * Sets the panel-defined layout data associated with this widget. Only the
- * panel that currently contains a widget should ever set this value. It
- * serves as a place to store layout bookkeeping data associated with a
- * widget.
+ * Removes this widget from its parent widget. If it has no parent, this
+ * method does nothing.
*
- * @param layoutData the widget's layout data
+ * @throws IllegalStateException if this widget's parent does not support
+ * removal (e.g. {@link Composite})
*/
- void setLayoutData(Object layoutData) {
- this.layoutData = layoutData;
- }
-
- /**
- * This method is called when the widget becomes attached to the browser's
- * document.
- */
- protected void onLoad() {
+ public void removeFromParent() {
+ if (parent instanceof HasWidgets) {
+ ((HasWidgets) parent).remove(this);
+ } else if (parent != null) {
+ throw new IllegalStateException(
+ "This widget's parent does not implement HasWidgets");
+ }
}
/**
@@ -121,6 +108,35 @@
}
/**
+ * This method is called when the widget becomes attached to the browser's
+ * document.
+ */
+ protected void onLoad() {
+ }
+
+ /**
+ * Gets the panel-defined layout data associated with this widget.
+ *
+ * @return the widget's layout data
+ * @see #setLayoutData
+ */
+ Object getLayoutData() {
+ return layoutData;
+ }
+
+ /**
+ * Sets the panel-defined layout data associated with this widget. Only the
+ * panel that currently contains a widget should ever set this value. It
+ * serves as a place to store layout bookkeeping data associated with a
+ * widget.
+ *
+ * @param layoutData the widget's layout data
+ */
+ void setLayoutData(Object layoutData) {
+ this.layoutData = layoutData;
+ }
+
+ /**
* Sets this widget's parent. This method should only be called by
* {@link Panel} and {@link Composite}.
*
@@ -135,20 +151,4 @@
onAttach();
}
}
-
- /**
- * Removes this widget from its parent widget. If it has no parent, this
- * method does nothing.
- *
- * @throws IllegalStateException if this widget's parent does not support
- * removal (e.g. {@link Composite})
- */
- public void removeFromParent() {
- if (parent instanceof HasWidgets) {
- ((HasWidgets) parent).remove(this);
- } else if (parent != null) {
- throw new IllegalStateException(
- "This widget's parent does not implement HasWidgets");
- }
- }
}
diff --git a/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java b/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java
index b8ea1df..5882bcf 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/FormPanelImpl.java
@@ -23,6 +23,16 @@
public class FormPanelImpl {
/**
+ * Gets the form element's encoding.
+ *
+ * @param form the form whose encoding is to be retrieved
+ * @return the form's encoding type
+ */
+ public native String getEncoding(Element form) /*-{
+ return form.enctype;
+ }-*/;
+
+ /**
* Gets the response text from the loaded iframe.
*
* @param iframe the iframe from which the response text is to be extracted
@@ -42,28 +52,6 @@
}-*/;
/**
- * Sets the form element's encoding.
- *
- * @param form the form whose encoding is to be set
- * @param encoding the new encoding type
- */
- // To be safe, setting both.
- public native void setEncoding(Element form, String encoding) /*-{
- form.enctype = encoding;
- form.encoding = encoding;
- }-*/;
-
- /**
- * Gets the form element's encoding.
- *
- * @param form the form whose encoding is to be retrieved
- * @return the form's encoding type
- */
- public native String getEncoding(Element form) /*-{
- return form.enctype;
- }-*/;
-
- /**
* Hooks the iframe's onLoad event and the form's onSubmit event.
*
* @param iframe the iframe whose onLoad event is to be hooked
@@ -94,6 +82,18 @@
}-*/;
/**
+ * Sets the form element's encoding.
+ *
+ * @param form the form whose encoding is to be set
+ * @param encoding the new encoding type
+ */
+ // To be safe, setting both.
+ public native void setEncoding(Element form, String encoding) /*-{
+ form.enctype = encoding;
+ form.encoding = encoding;
+ }-*/;
+
+ /**
* Submits a form.
*
* @param form the form to be submitted
diff --git a/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java b/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java
index f63d00b..0a07e5a 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/PopupImpl.java
@@ -19,8 +19,7 @@
import com.google.gwt.user.client.Element;
/**
- * Implementation class used by
- * {@link com.google.gwt.user.client.ui.PopupPanel}.
+ * Implementation class used by {@link com.google.gwt.user.client.ui.PopupPanel}.
*/
public class PopupImpl {
@@ -28,9 +27,9 @@
return DOM.createDiv();
}
- public void onShow(Element popup) {
+ public void onHide(Element popup) {
}
- public void onHide(Element popup) {
+ public void onShow(Element popup) {
}
}
diff --git a/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java b/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java
index fce0f16..b26256a 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/PopupImplIE6.java
@@ -23,6 +23,13 @@
*/
public class PopupImplIE6 extends PopupImpl {
+ public native void onHide(Element popup) /*-{
+ var frame = popup.__frame;
+ frame.parentElement.removeChild(frame);
+ popup.__frame = null;
+ frame.__popup = null;
+ }-*/;
+
public native void onShow(Element popup) /*-{
var frame = $doc.createElement('iframe');
frame.scrolling = 'no';
@@ -37,11 +44,4 @@
frame.style.setExpression('height', 'this.__popup.offsetHeight');
popup.parentElement.insertBefore(frame, popup);
}-*/;
-
- public native void onHide(Element popup) /*-{
- var frame = popup.__frame;
- frame.parentElement.removeChild(frame);
- popup.__frame = null;
- frame.__popup = null;
- }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/ui/impl/TextBoxImpl.java b/user/src/com/google/gwt/user/client/ui/impl/TextBoxImpl.java
index 7990453..dd3b780 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/TextBoxImpl.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/TextBoxImpl.java
@@ -18,8 +18,7 @@
import com.google.gwt.user.client.Element;
/**
- * Implementation class used by
- * {@link com.google.gwt.user.client.ui.TextBox}.
+ * Implementation class used by {@link com.google.gwt.user.client.ui.TextBox}.
*/
public class TextBoxImpl {
@@ -41,11 +40,11 @@
}
}-*/;
- public native void setSelectionRange(Element elem, int pos, int length) /*-{
- elem.setSelectionRange(pos, pos + length);
- }-*/;
-
public int getTextAreaCursorPos(Element elem) {
return getCursorPos(elem);
}
+
+ public native void setSelectionRange(Element elem, int pos, int length) /*-{
+ elem.setSelectionRange(pos, pos + length);
+ }-*/;
}
diff --git a/user/src/com/google/gwt/user/client/ui/impl/TextBoxImplIE6.java b/user/src/com/google/gwt/user/client/ui/impl/TextBoxImplIE6.java
index 3c606ca..8d232df 100644
--- a/user/src/com/google/gwt/user/client/ui/impl/TextBoxImplIE6.java
+++ b/user/src/com/google/gwt/user/client/ui/impl/TextBoxImplIE6.java
@@ -47,18 +47,6 @@
}
}-*/;
- public native void setSelectionRange(Element elem, int pos, int length) /*-{
- try {
- var tr = elem.createTextRange();
- tr.collapse(true);
- tr.moveStart('character', pos);
- tr.moveEnd('character', length);
- tr.select();
- }
- catch (e) {
- }
- }-*/;
-
public native int getTextAreaCursorPos(Element elem) /*-{
try {
var tr = elem.document.selection.createRange();
@@ -72,4 +60,16 @@
}
}-*/;
+ public native void setSelectionRange(Element elem, int pos, int length) /*-{
+ try {
+ var tr = elem.createTextRange();
+ tr.collapse(true);
+ tr.moveStart('character', pos);
+ tr.moveEnd('character', length);
+ tr.select();
+ }
+ catch (e) {
+ }
+ }-*/;
+
}
diff --git a/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java b/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java
index 4a32298..a3e7356 100644
--- a/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java
+++ b/user/src/com/google/gwt/user/rebind/AbstractGeneratorClassCreator.java
@@ -72,6 +72,19 @@
}
/**
+ * List of registered method factories associated with <code>Constant</code>
+ * method implementations.
+ */
+ protected Map methodFactories = new HashMap();
+
+ /**
+ * The interface the generator is conforming to.
+ */
+ JClassType targetClass;
+
+ private final SourceWriter writer;
+
+ /**
* Creates a new class creator, supplies a place to write the class, the
* interface to conform to, and the new name.
*
@@ -112,47 +125,9 @@
methodFactories.put(returnType, creator);
}
- private void emitMethods(TreeLogger logger, JClassType cur)
- throws UnableToCompleteException {
- JMethod[] x = getAllInterfaceMethods(cur);
- for (int i = 0; i < x.length; i++) {
- genMethod(logger, x[i]);
- getWriter().println();
- }
- }
-
- /**
- * Generates a method declaration for the given method.
- *
- * @param method method to generate
- * @throws UnableToCompleteException
- */
- private void genMethod(TreeLogger logger, JMethod method)
- throws UnableToCompleteException {
- String name = method.getName();
- String returnType = method.getReturnType().getQualifiedSourceName();
- getWriter().print("public " + returnType + " " + name + "(");
- JParameter[] params = method.getParameters();
- for (int i = 0; i < params.length; i++) {
- if (i != 0) {
- getWriter().print(",");
- }
- getWriter().print(
- params[i].getType().getParameterizedQualifiedSourceName() + " arg"
- + (i));
- }
- getWriter().println(") {");
- getWriter().indent();
- String methodName = method.getName();
- TreeLogger branch = branch(logger, "Generating method body for "
- + methodName + "()");
- emitMethodBody(branch, method);
- getWriter().outdent();
- getWriter().println("}");
- }
-
/**
* Returns the standard message when constructing a branch.
+ *
* @return branch message
*/
protected String branchMessage() {
@@ -195,7 +170,7 @@
AbstractMethodCreator methodCreator = (AbstractMethodCreator) methodFactories.get(type);
if (methodCreator == null) {
String msg = "No current method creator exists for " + method
- + " only methods with return types of ";
+ + " only methods with return types of ";
Iterator iter = this.methodFactories.keySet().iterator();
while (iter.hasNext()) {
msg += ((JType) iter.next()).getSimpleSourceName();
@@ -218,14 +193,42 @@
return writer;
}
- private final SourceWriter writer;
+ private void emitMethods(TreeLogger logger, JClassType cur)
+ throws UnableToCompleteException {
+ JMethod[] x = getAllInterfaceMethods(cur);
+ for (int i = 0; i < x.length; i++) {
+ genMethod(logger, x[i]);
+ getWriter().println();
+ }
+ }
+
/**
- * List of registered method factories associated with <code>Constant</code>
- * method implementations.
+ * Generates a method declaration for the given method.
+ *
+ * @param method method to generate
+ * @throws UnableToCompleteException
*/
- protected Map methodFactories = new HashMap();
- /**
- * The interface the generator is conforming to.
- */
- JClassType targetClass;
+ private void genMethod(TreeLogger logger, JMethod method)
+ throws UnableToCompleteException {
+ String name = method.getName();
+ String returnType = method.getReturnType().getQualifiedSourceName();
+ getWriter().print("public " + returnType + " " + name + "(");
+ JParameter[] params = method.getParameters();
+ for (int i = 0; i < params.length; i++) {
+ if (i != 0) {
+ getWriter().print(",");
+ }
+ getWriter().print(
+ params[i].getType().getParameterizedQualifiedSourceName() + " arg"
+ + (i));
+ }
+ getWriter().println(") {");
+ getWriter().indent();
+ String methodName = method.getName();
+ TreeLogger branch = branch(logger, "Generating method body for "
+ + methodName + "()");
+ emitMethodBody(branch, method);
+ getWriter().outdent();
+ getWriter().println("}");
+ }
}
diff --git a/user/src/com/google/gwt/user/rebind/AbstractMethodCreator.java b/user/src/com/google/gwt/user/rebind/AbstractMethodCreator.java
index 26f7681..4a0d396 100644
--- a/user/src/com/google/gwt/user/rebind/AbstractMethodCreator.java
+++ b/user/src/com/google/gwt/user/rebind/AbstractMethodCreator.java
@@ -26,6 +26,12 @@
*/
public abstract class AbstractMethodCreator extends AbstractSourceCreator {
/**
+ * AbstractGeneratorClassCreator associated with the method currently in
+ * process.
+ */
+ protected AbstractGeneratorClassCreator currentCreator;
+
+ /**
* Constructor for <code>AbstractMethodCreator</code>.
*
* @param classCreator
@@ -76,10 +82,4 @@
protected void print(String printMe) {
currentCreator.getWriter().print(printMe);
}
-
- /**
- * AbstractGeneratorClassCreator associated with the method currently in
- * process.
- */
- protected AbstractGeneratorClassCreator currentCreator;
}
diff --git a/user/src/com/google/gwt/user/rebind/ClassSourceFileComposer.java b/user/src/com/google/gwt/user/rebind/ClassSourceFileComposer.java
index 59ba473..396e6dc 100644
--- a/user/src/com/google/gwt/user/rebind/ClassSourceFileComposer.java
+++ b/user/src/com/google/gwt/user/rebind/ClassSourceFileComposer.java
@@ -28,6 +28,25 @@
*/
private static final String STAR_COMMENT_LINE = " * ";
+ private boolean atStart;
+
+ /**
+ * Either STAR/BLOCK comment line, not pulled out into a ENUM class because
+ * only used by this class.
+ */
+ private String commentIndicator;
+
+ private final GeneratorContext ctx;
+
+ /**
+ * Are you currently in a comment?
+ */
+ private boolean inComment;
+
+ private int indent;
+
+ private final PrintWriter printWriter;
+
ClassSourceFileComposer(GeneratorContext ctx, PrintWriter printWriter,
String targetPackageName, String targetClassShortName,
String superClassName, String[] interfaceNames, String[] imports,
@@ -36,7 +55,7 @@
this.printWriter = printWriter;
if (targetPackageName == null) {
throw new IllegalArgumentException("Cannot supply a null package name to"
- + targetClassShortName);
+ + targetClassShortName);
}
// Inlined header to only have one method with a huge number of methods.
println("package " + targetPackageName + ";");
@@ -162,7 +181,7 @@
String superClassName, String[] interfaceNames) {
if (superClassName != null) {
throw new IllegalArgumentException("Cannot set superclass name "
- + superClassName + " on a interface.");
+ + superClassName + " on a interface.");
}
print("public interface " + targetClassShortName);
if (interfaceNames != null && interfaceNames.length > 0) {
@@ -175,18 +194,4 @@
}
}
}
-
- private boolean atStart;
- /**
- * Either STAR/BLOCK comment line, not pulled out into a ENUM class because
- * only used by this class.
- */
- private String commentIndicator;
- private final GeneratorContext ctx;
- /**
- * Are you currently in a comment?
- */
- private boolean inComment;
- private int indent;
- private final PrintWriter printWriter;
}
diff --git a/user/src/com/google/gwt/user/rebind/ClassSourceFileComposerFactory.java b/user/src/com/google/gwt/user/rebind/ClassSourceFileComposerFactory.java
index d23159b..c3bda0a 100644
--- a/user/src/com/google/gwt/user/rebind/ClassSourceFileComposerFactory.java
+++ b/user/src/com/google/gwt/user/rebind/ClassSourceFileComposerFactory.java
@@ -25,7 +25,7 @@
/**
* Factory clas to create <code>ClassSourceFileComposer</code> instances.
- *
+ *
*/
public class ClassSourceFileComposerFactory {
/**
@@ -37,13 +37,18 @@
* This type is a class.
*/
public static final JavaSourceCategory CLASS;
-
+
/**
* This type is a interface.
*/
public static final JavaSourceCategory INTERFACE;
static Map pool = new HashMap();
+ static {
+ CLASS = new JavaSourceCategory("class");
+ INTERFACE = new JavaSourceCategory("interface");
+ }
+
public static JavaSourceCategory require(String key) {
return (JavaSourceCategory) Enum.require(key, pool);
}
@@ -51,13 +56,22 @@
protected JavaSourceCategory(String key) {
super(key, pool);
}
-
- static {
- CLASS = new JavaSourceCategory("class");
- INTERFACE = new JavaSourceCategory("interface");
- }
}
+ private JavaSourceCategory classCategory = JavaSourceCategory.CLASS;
+
+ private String classComment;
+
+ private String className;
+
+ private Set imports = new HashSet();
+
+ private Set interfaceNames = new HashSet();
+
+ private String packageName;
+
+ private String superClassName;
+
public ClassSourceFileComposerFactory(String packageName, String className) {
this.packageName = packageName;
this.className = className;
@@ -82,8 +96,8 @@
public SourceWriter createSourceWriter(GeneratorContext ctx,
PrintWriter printWriter) {
return new ClassSourceFileComposer(ctx, printWriter, getCreatedPackage(),
- getCreatedClassShortName(), getSuperclassName(), getInterfaceNames(),
- getImports(), classCategory, classComment);
+ getCreatedClassShortName(), getSuperclassName(), getInterfaceNames(),
+ getImports(), classCategory, classComment);
}
/**
@@ -98,8 +112,8 @@
*/
public SourceWriter createSourceWriter(PrintWriter printWriter) {
return new ClassSourceFileComposer(null, printWriter, getCreatedPackage(),
- getCreatedClassShortName(), getSuperclassName(), getInterfaceNames(),
- getImports(), classCategory, classComment);
+ getCreatedClassShortName(), getSuperclassName(), getInterfaceNames(),
+ getImports(), classCategory, classComment);
}
public String getCreatedClassName() {
@@ -143,12 +157,4 @@
private String[] getImports() {
return (String[]) imports.toArray(new String[imports.size()]);
}
-
- private JavaSourceCategory classCategory = JavaSourceCategory.CLASS;
- private String classComment;
- private String className;
- private Set imports = new HashSet();
- private Set interfaceNames = new HashSet();
- private String packageName;
- private String superClassName;
}
diff --git a/user/src/com/google/gwt/user/rebind/Enum.java b/user/src/com/google/gwt/user/rebind/Enum.java
index 426a71c..4c779b2 100644
--- a/user/src/com/google/gwt/user/rebind/Enum.java
+++ b/user/src/com/google/gwt/user/rebind/Enum.java
@@ -33,12 +33,17 @@
Enum t = (Enum) pool.get(key);
if (t == null) {
throw new IllegalArgumentException(key
- + " is not a valid Enum type. Current options are " + pool.keySet());
+ + " is not a valid Enum type. Current options are " + pool.keySet());
}
return t;
}
/**
+ * Associated key.
+ */
+ final String key;
+
+ /**
* Creates a new <code>Enum</code> in a given pool.
*
* @param key associated key
@@ -55,9 +60,4 @@
public String toString() {
return key;
}
-
- /**
- * Associated key.
- */
- final String key;
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/user/rebind/rpc/CustomSerializerInfo.java b/user/src/com/google/gwt/user/rebind/rpc/CustomSerializerInfo.java
index 71d2ce1..4358d4e 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/CustomSerializerInfo.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/CustomSerializerInfo.java
@@ -21,7 +21,7 @@
/**
* Customized Seralizer information.
- *
+ *
*/
public class CustomSerializerInfo {
JClassType serializeeClass;
@@ -34,35 +34,47 @@
return deserializeMethod;
}
+ public JMethod getInstantiateMethod() {
+ return instantiateMethod;
+ }
+
+ public JClassType getSerializeeClass() {
+ return serializeeClass;
+ }
+
+ public JMethod getSerializeMethod() {
+ return serializeMethod;
+ }
+
+ public JClassType getSerializerClass() {
+ return serializerClass;
+ }
+
public boolean setDeserializeMethod(TreeLogger logger,
JMethod deserializeMethod) {
if (this.deserializeMethod != null
- && this.deserializeMethod != deserializeMethod) {
+ && this.deserializeMethod != deserializeMethod) {
logger.log(TreeLogger.ERROR, "Type "
- + serializeeClass.getQualifiedSourceName()
- + " has more than one custom field serializer deserialize method, "
- + this.deserializeMethod.getReadableDeclaration() + " and "
- + deserializeMethod.getReadableDeclaration(), null);
+ + serializeeClass.getQualifiedSourceName()
+ + " has more than one custom field serializer deserialize method, "
+ + this.deserializeMethod.getReadableDeclaration() + " and "
+ + deserializeMethod.getReadableDeclaration(), null);
return false;
}
this.deserializeMethod = deserializeMethod;
return true;
}
- public JMethod getInstantiateMethod() {
- return instantiateMethod;
- }
-
public boolean setInstantiateMethod(TreeLogger logger,
JMethod instantiateMethod) {
if (this.instantiateMethod != null
- && this.instantiateMethod != instantiateMethod) {
+ && this.instantiateMethod != instantiateMethod) {
logger.log(TreeLogger.ERROR, "Type "
- + serializeeClass.getQualifiedSourceName()
- + " has more than one custom field serializer instantiate method, "
- + this.instantiateMethod.getReadableDeclaration() + " and "
- + instantiateMethod.getReadableDeclaration(), null);
+ + serializeeClass.getQualifiedSourceName()
+ + " has more than one custom field serializer instantiate method, "
+ + this.instantiateMethod.getReadableDeclaration() + " and "
+ + instantiateMethod.getReadableDeclaration(), null);
return false;
}
@@ -70,17 +82,17 @@
return true;
}
- public JMethod getSerializeMethod() {
- return serializeMethod;
+ public void setSerializeeClass(JClassType serializeeClass) {
+ this.serializeeClass = serializeeClass;
}
public boolean setSerializeMethod(TreeLogger logger, JMethod serializeMethod) {
if (this.serializeMethod != null && this.serializeMethod != serializeMethod) {
logger.log(TreeLogger.ERROR, "Type "
- + serializeeClass.getQualifiedSourceName()
- + " has more than one custom field serializer deserialize method, "
- + this.serializeMethod.getReadableDeclaration() + " and "
- + serializeMethod.getReadableDeclaration(), null);
+ + serializeeClass.getQualifiedSourceName()
+ + " has more than one custom field serializer deserialize method, "
+ + this.serializeMethod.getReadableDeclaration() + " and "
+ + serializeMethod.getReadableDeclaration(), null);
return false;
}
@@ -88,30 +100,17 @@
return true;
}
- public JClassType getSerializerClass() {
- return serializerClass;
- }
-
public boolean setSerializerClass(TreeLogger logger,
JClassType serializerClass) {
- if (this.serializerClass != null
- && this.serializerClass != serializerClass) {
+ if (this.serializerClass != null && this.serializerClass != serializerClass) {
logger.log(TreeLogger.ERROR, "Type "
- + serializeeClass.getQualifiedSourceName()
- + " has more than one custom field serializer, "
- + this.serializerClass.getQualifiedSourceName() + " and "
- + serializerClass.getQualifiedSourceName(), null);
+ + serializeeClass.getQualifiedSourceName()
+ + " has more than one custom field serializer, "
+ + this.serializerClass.getQualifiedSourceName() + " and "
+ + serializerClass.getQualifiedSourceName(), null);
return false;
}
this.serializerClass = serializerClass;
return true;
}
-
- public JClassType getSerializeeClass() {
- return serializeeClass;
- }
-
- public void setSerializeeClass(JClassType serializeeClass) {
- this.serializeeClass = serializeeClass;
- }
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java b/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
index 341e137..f0733a4 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/FieldSerializerCreator.java
@@ -51,7 +51,15 @@
* fully qualified type names everywhere
*/
public class FieldSerializerCreator {
-
+
+ private JClassType serializableClass;
+
+ private JField[] serializableFields;
+
+ private SerializableTypeOracle serializationOracle;
+
+ private SourceWriter sourceWriter;
+
/**
* Constructs a field serializer for the class.
*
@@ -63,25 +71,24 @@
assert (requestedClass != null);
assert (requestedClass.isClass() != null);
- fSerializationOracle = serializationOracle;
- fSerializableClass = requestedClass;
+ this.serializationOracle = serializationOracle;
+ serializableClass = requestedClass;
}
public String realize(TreeLogger logger, GeneratorContext ctx) {
assert (ctx != null);
- assert (fSerializationOracle.isSerializable(getSerializableClass()));
+ assert (serializationOracle.isSerializable(getSerializableClass()));
logger = logger.branch(TreeLogger.SPAM,
"Generating a field serializer for type '"
- + fSerializableClass.getQualifiedSourceName() + "'", null);
- String fieldSerializerName = fSerializationOracle
- .getFieldSerializerName(getSerializableClass());
+ + serializableClass.getQualifiedSourceName() + "'", null);
+ String fieldSerializerName = serializationOracle.getFieldSerializerName(getSerializableClass());
- fSourceWriter = getSourceWriter(logger, ctx);
- if (fSourceWriter == null) {
+ sourceWriter = getSourceWriter(logger, ctx);
+ if (sourceWriter == null) {
return fieldSerializerName;
}
- assert fSourceWriter != null;
+ assert sourceWriter != null;
writeFieldAccessors();
@@ -89,7 +96,7 @@
writeDeserializeMethod();
- fSourceWriter.commit(logger);
+ sourceWriter.commit(logger);
return fieldSerializerName;
}
@@ -113,8 +120,7 @@
* @return name of the field serializer
*/
private String getFieldSerializerClassName() {
- String sourceName = fSerializationOracle
- .getFieldSerializerName(getSerializableClass());
+ String sourceName = serializationOracle.getFieldSerializerName(getSerializableClass());
int qualifiedSourceNameStart = sourceName.lastIndexOf('.');
if (qualifiedSourceNameStart >= 0) {
@@ -135,7 +141,7 @@
}
private JClassType getSerializableClass() {
- return fSerializableClass;
+ return serializableClass;
}
/**
@@ -144,13 +150,12 @@
* @return array of serializable fields
*/
private JField[] getSerializableFields() {
- if (fSerializableFields != null) {
- return fSerializableFields;
+ if (serializableFields != null) {
+ return serializableFields;
}
- fSerializableFields = fSerializationOracle
- .applyFieldSerializationPolicy(getSerializableClass());
- return fSerializableFields;
+ serializableFields = serializationOracle.applyFieldSerializationPolicy(getSerializableClass());
+ return serializableFields;
}
/**
@@ -166,8 +171,8 @@
JClassType superClass = serializableClass.getSuperclass();
if (superClass != null) {
- SerializableTypeOracle serializationOracle = getSerializationOracle();
- if (serializationOracle.isSerializable(superClass)) {
+ SerializableTypeOracle oracle = getSerializationOracle();
+ if (oracle.isSerializable(superClass)) {
return superClass;
}
@@ -178,7 +183,7 @@
}
private SerializableTypeOracle getSerializationOracle() {
- return fSerializationOracle;
+ return serializationOracle;
}
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx) {
@@ -203,44 +208,40 @@
*/
private boolean needsAccessorMethods(JField field) {
/*
- * Field serializers are always emitted into the the same package as the
- * class that they serialize. This enables the serializer class to
- * access all fields except those that are private.
+ * Field serializers are always emitted into the the same package as the
+ * class that they serialize. This enables the serializer class to access
+ * all fields except those that are private.
*
- * Java Access Levels:
- * default - package
- * private - class only
- * protected - package and all subclasses
- * public - all
+ * Java Access Levels: default - package private - class only protected -
+ * package and all subclasses public - all
*/
return field.isPrivate();
}
private void writeDeserializeMethod() {
- fSourceWriter.print("public static void deserialize(");
- fSourceWriter.print(SerializationStreamReader.class.getName());
- fSourceWriter.print(" streamReader, ");
- fSourceWriter.print(getSerializableClass().getQualifiedSourceName());
- fSourceWriter.println(" instance) throws "
+ sourceWriter.print("public static void deserialize(");
+ sourceWriter.print(SerializationStreamReader.class.getName());
+ sourceWriter.print(" streamReader, ");
+ sourceWriter.print(getSerializableClass().getQualifiedSourceName());
+ sourceWriter.println(" instance) throws "
+ SerializationException.class.getName() + "{");
- fSourceWriter.indent();
+ sourceWriter.indent();
writeFieldDeserializationStatements();
- JClassType serializableClass = getSerializableClass().isClass();
- if (serializableClass != null) {
- JClassType serializableSuperClass = getSerializableSuperclass(serializableClass);
+ JClassType jClass = getSerializableClass().isClass();
+ if (jClass != null) {
+ JClassType serializableSuperClass = getSerializableSuperclass(jClass);
if (serializableSuperClass != null) {
- String fieldSerializerName = fSerializationOracle
- .getFieldSerializerName(serializableSuperClass);
- fSourceWriter.print(fieldSerializerName);
- fSourceWriter.println(".deserialize(streamReader, instance);");
+ String fieldSerializerName = serializationOracle.getFieldSerializerName(serializableSuperClass);
+ sourceWriter.print(fieldSerializerName);
+ sourceWriter.println(".deserialize(streamReader, instance);");
}
}
- fSourceWriter.outdent();
- fSourceWriter.println("}");
- fSourceWriter.println();
+ sourceWriter.outdent();
+ sourceWriter.println("}");
+ sourceWriter.println();
}
/**
@@ -249,11 +250,11 @@
* external class to access the field's value.
*/
private void writeFieldAccessors() {
- JField[] serializableFields = getSerializableFields();
- int fieldCount = serializableFields.length;
+ JField[] jFields = getSerializableFields();
+ int fieldCount = jFields.length;
for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex) {
- JField serializableField = serializableFields[fieldIndex];
+ JField serializableField = jFields[fieldIndex];
if (!needsAccessorMethods(serializableField)) {
continue;
@@ -268,28 +269,26 @@
JType type = getSerializableClass();
JArrayType isArray = type.isArray();
if (isArray != null) {
- fSourceWriter
- .println("for (int itemIndex = 0; itemIndex < instance.length; ++itemIndex) {");
- fSourceWriter.indent();
+ sourceWriter.println("for (int itemIndex = 0; itemIndex < instance.length; ++itemIndex) {");
+ sourceWriter.indent();
JType componentType = isArray.getComponentType();
- fSourceWriter.print("instance[itemIndex] = ");
+ sourceWriter.print("instance[itemIndex] = ");
if (Shared.typeNeedsCast(componentType)) {
- fSourceWriter
- .print("(" + componentType.getQualifiedSourceName() + ") ");
+ sourceWriter.print("(" + componentType.getQualifiedSourceName() + ") ");
}
String readMethodName = "streamReader.read"
+ Shared.getCallSuffix(componentType);
- fSourceWriter.println(readMethodName + "();");
- fSourceWriter.outdent();
- fSourceWriter.println("}");
+ sourceWriter.println(readMethodName + "();");
+ sourceWriter.outdent();
+ sourceWriter.println("}");
} else {
- JField[] serializableFields = getSerializableFields();
- int fieldCount = serializableFields.length;
+ JField[] jFields = getSerializableFields();
+ int fieldCount = jFields.length;
for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex) {
- JField serializableField = serializableFields[fieldIndex];
+ JField serializableField = jFields[fieldIndex];
JType fieldType = serializableField.getType();
boolean needsAccessor = needsAccessorMethods(serializableField);
@@ -301,22 +300,22 @@
}
if (needsAccessor) {
- fSourceWriter.print("set");
- fSourceWriter.print(Shared.capitalize(serializableField.getName()));
- fSourceWriter.print("(instance, ");
- fSourceWriter.print(streamReadExpression);
- fSourceWriter.println(");");
+ sourceWriter.print("set");
+ sourceWriter.print(Shared.capitalize(serializableField.getName()));
+ sourceWriter.print("(instance, ");
+ sourceWriter.print(streamReadExpression);
+ sourceWriter.println(");");
} else {
- fSourceWriter.print("instance.");
- fSourceWriter.print(serializableField.getName());
- fSourceWriter.print(" = ");
- fSourceWriter.print(streamReadExpression);
- fSourceWriter.println(";");
+ sourceWriter.print("instance.");
+ sourceWriter.print(serializableField.getName());
+ sourceWriter.print(" = ");
+ sourceWriter.print(streamReadExpression);
+ sourceWriter.println(";");
}
}
}
- fSourceWriter.println();
+ sourceWriter.println();
}
/**
@@ -327,70 +326,69 @@
String fieldTypeQualifiedSourceName = fieldType.getQualifiedSourceName();
String fieldName = serializableField.getName();
- fSourceWriter.print("private static native ");
- fSourceWriter.print(fieldTypeQualifiedSourceName);
- fSourceWriter.print(" get");
- fSourceWriter.print(Shared.capitalize(fieldName));
- fSourceWriter.print("(");
- fSourceWriter.print(getSerializableClass().getQualifiedSourceName());
- fSourceWriter.println(" instance) /*-{");
- fSourceWriter.indent();
+ sourceWriter.print("private static native ");
+ sourceWriter.print(fieldTypeQualifiedSourceName);
+ sourceWriter.print(" get");
+ sourceWriter.print(Shared.capitalize(fieldName));
+ sourceWriter.print("(");
+ sourceWriter.print(getSerializableClass().getQualifiedSourceName());
+ sourceWriter.println(" instance) /*-{");
+ sourceWriter.indent();
- fSourceWriter.print("return instance.@");
- fSourceWriter.print(getBinaryTypeName(getSerializableClass()));
- fSourceWriter.print("::");
- fSourceWriter.print(fieldName);
- fSourceWriter.println(";");
+ sourceWriter.print("return instance.@");
+ sourceWriter.print(getBinaryTypeName(getSerializableClass()));
+ sourceWriter.print("::");
+ sourceWriter.print(fieldName);
+ sourceWriter.println(";");
- fSourceWriter.outdent();
- fSourceWriter.println("}-*/;");
- fSourceWriter.println();
+ sourceWriter.outdent();
+ sourceWriter.println("}-*/;");
+ sourceWriter.println();
}
private void writeFieldSerializationStatements() {
JType type = getSerializableClass();
JArrayType isArray = type.isArray();
if (isArray != null) {
- fSourceWriter.println("int itemCount = instance.length;");
- fSourceWriter.println();
- fSourceWriter.println("streamWriter.writeInt(itemCount);");
- fSourceWriter.println();
- fSourceWriter
- .println("for (int itemIndex = 0; itemIndex < itemCount; ++itemIndex) {");
- fSourceWriter.indent();
+ sourceWriter.println("int itemCount = instance.length;");
+ sourceWriter.println();
+ sourceWriter.println("streamWriter.writeInt(itemCount);");
+ sourceWriter.println();
+ sourceWriter.println("for (int itemIndex = 0; itemIndex < itemCount; ++itemIndex) {");
+ sourceWriter.indent();
String writeMethodName = "write"
+ Shared.getCallSuffix(isArray.getComponentType());
- fSourceWriter.print("streamWriter.");
- fSourceWriter.print(writeMethodName);
- fSourceWriter.println("(instance[itemIndex]);");
- fSourceWriter.outdent();
- fSourceWriter.println("}");
+ sourceWriter.print("streamWriter.");
+ sourceWriter.print(writeMethodName);
+ sourceWriter.println("(instance[itemIndex]);");
+ sourceWriter.outdent();
+ sourceWriter.println("}");
} else {
- JField[] serializableFields = getSerializableFields();
- int fieldCount = serializableFields.length;
+ JField[] jFields = getSerializableFields();
+ int fieldCount = jFields.length;
for (int fieldIndex = 0; fieldIndex < fieldCount; ++fieldIndex) {
- JField serializableField = serializableFields[fieldIndex];
+ JField serializableField = jFields[fieldIndex];
JType fieldType = serializableField.getType();
String writeMethodName = "write" + Shared.getCallSuffix(fieldType);
- fSourceWriter.print("streamWriter.");
- fSourceWriter.print(writeMethodName);
- fSourceWriter.print("(");
+ sourceWriter.print("streamWriter.");
+ sourceWriter.print(writeMethodName);
+ sourceWriter.print("(");
if (needsAccessorMethods(serializableField)) {
- fSourceWriter.print("get");
- fSourceWriter.print(Shared.capitalize(serializableField.getName()));
- fSourceWriter.println("(instance));");
+ sourceWriter.print("get");
+ sourceWriter.print(Shared.capitalize(serializableField.getName()));
+ sourceWriter.println("(instance));");
} else {
- fSourceWriter.print("instance.");
- fSourceWriter.print(serializableField.getName());
- fSourceWriter.println(");");
+ sourceWriter.print("instance.");
+ sourceWriter.print(serializableField.getName());
+ sourceWriter.println(");");
}
}
}
- fSourceWriter.println();
+ sourceWriter.println();
}
/**
@@ -399,61 +397,54 @@
private void writeFieldSet(JField serializableField) {
JType fieldType = serializableField.getType();
String fieldTypeQualifiedSourceName = fieldType.getQualifiedSourceName();
- String serializableClassQualifedName = getSerializableClass()
- .getQualifiedSourceName();
+ String serializableClassQualifedName = getSerializableClass().getQualifiedSourceName();
String fieldName = serializableField.getName();
- fSourceWriter.print("private static native void ");
- fSourceWriter.print(" set");
- fSourceWriter.print(Shared.capitalize(fieldName));
- fSourceWriter.print("(");
- fSourceWriter.print(serializableClassQualifedName);
- fSourceWriter.print(" instance, ");
- fSourceWriter.print(fieldTypeQualifiedSourceName);
- fSourceWriter.println(" value) /*-{");
- fSourceWriter.indent();
+ sourceWriter.print("private static native void ");
+ sourceWriter.print(" set");
+ sourceWriter.print(Shared.capitalize(fieldName));
+ sourceWriter.print("(");
+ sourceWriter.print(serializableClassQualifedName);
+ sourceWriter.print(" instance, ");
+ sourceWriter.print(fieldTypeQualifiedSourceName);
+ sourceWriter.println(" value) /*-{");
+ sourceWriter.indent();
- fSourceWriter.print("instance.@");
- fSourceWriter.print(getBinaryTypeName(getSerializableClass()));
- fSourceWriter.print("::");
- fSourceWriter.print(fieldName);
- fSourceWriter.println(" = value;");
+ sourceWriter.print("instance.@");
+ sourceWriter.print(getBinaryTypeName(getSerializableClass()));
+ sourceWriter.print("::");
+ sourceWriter.print(fieldName);
+ sourceWriter.println(" = value;");
- fSourceWriter.outdent();
- fSourceWriter.println("}-*/;");
- fSourceWriter.println();
+ sourceWriter.outdent();
+ sourceWriter.println("}-*/;");
+ sourceWriter.println();
}
private void writeSerializeMethod() {
- fSourceWriter.print("public static void serialize(");
- fSourceWriter.print(SerializationStreamWriter.class.getName());
- fSourceWriter.print(" streamWriter, ");
- fSourceWriter.print(getSerializableClass().getQualifiedSourceName());
- fSourceWriter.println(" instance) throws "
+ sourceWriter.print("public static void serialize(");
+ sourceWriter.print(SerializationStreamWriter.class.getName());
+ sourceWriter.print(" streamWriter, ");
+ sourceWriter.print(getSerializableClass().getQualifiedSourceName());
+ sourceWriter.println(" instance) throws "
+ SerializationException.class.getName() + " {");
- fSourceWriter.indent();
+ sourceWriter.indent();
writeFieldSerializationStatements();
- JClassType serializableClass = getSerializableClass().isClass();
- if (serializableClass != null) {
- JClassType serializableSuperclass = getSerializableSuperclass(serializableClass);
+ JClassType jClass = getSerializableClass().isClass();
+ if (jClass != null) {
+ JClassType serializableSuperclass = getSerializableSuperclass(jClass);
if (serializableSuperclass != null) {
- String fieldSerializerName = fSerializationOracle
- .getFieldSerializerName(serializableSuperclass);
- fSourceWriter.print(fieldSerializerName);
- fSourceWriter.println(".serialize(streamWriter, instance);");
+ String fieldSerializerName = serializationOracle.getFieldSerializerName(serializableSuperclass);
+ sourceWriter.print(fieldSerializerName);
+ sourceWriter.println(".serialize(streamWriter, instance);");
}
}
- fSourceWriter.outdent();
- fSourceWriter.println("}");
- fSourceWriter.println();
+ sourceWriter.outdent();
+ sourceWriter.println("}");
+ sourceWriter.println();
}
- private JClassType fSerializableClass;
- private JField[] fSerializableFields;
- private SerializableTypeOracle fSerializationOracle;
- private SourceWriter fSourceWriter;
-
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java b/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
index a32066a..30d4f00 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ProxyCreator.java
@@ -53,14 +53,12 @@
private static final String PROXY_SUFFIX = "_Proxy";
private static final String SERIALIZATION_STREAM_READER_INSTANTIATION = ClientSerializationStreamReader.class.getName()
- + " streamReader = new "
- + ClientSerializationStreamReader.class.getName()
- + "(SERIALIZER);";
+ + " streamReader = new "
+ + ClientSerializationStreamReader.class.getName() + "(SERIALIZER);";
private static final String SERIALIZATION_STREAM_WRITER_INSTANTIATION = ClientSerializationStreamWriter.class.getName()
- + " streamWriter = new "
- + ClientSerializationStreamWriter.class.getName()
- + "(SERIALIZER);";
+ + " streamWriter = new "
+ + ClientSerializationStreamWriter.class.getName() + "(SERIALIZER);";
private static String createOverloadSignature(JMethod method) {
StringBuffer sb = new StringBuffer();
@@ -90,6 +88,12 @@
return type.getQualifiedSourceName();
}
+ private boolean enforceTypeVersioning;
+
+ private SerializableTypeOracle serializableTypeOracle;
+
+ private JClassType serviceIntf;
+
public ProxyCreator(JClassType serviceIntf,
SerializableTypeOracle serializableTypeOracle) {
this.serviceIntf = serviceIntf;
@@ -97,7 +101,7 @@
if (serviceIntf.isInterface() == null) {
throw new RuntimeException("Expecting a service interface, but "
- + serviceIntf.getQualifiedSourceName() + " is not an interface");
+ + serviceIntf.getQualifiedSourceName() + " is not an interface");
}
}
@@ -108,8 +112,8 @@
assert (isValidServiceInterface(logger, context));
logger = logger.branch(TreeLogger.SPAM,
- "Generating RPC Proxy for service interface '"
- + serviceIntf.getQualifiedSourceName() + "'", null);
+ "Generating RPC Proxy for service interface '"
+ + serviceIntf.getQualifiedSourceName() + "'", null);
SourceWriter srcWriter = getSourceWriter(logger, context);
if (srcWriter == null) {
return getProxyQualifiedName();
@@ -161,11 +165,11 @@
for (i = 0; i < params.length; i++) {
JParameter param = params[i];
w.print((i > 0 ? ", " : "") + getJavaTypeName(param.getType()) + " "
- + param.getName());
+ + param.getName());
}
w.println((i > 0 ? ", final " : "final ") + AsyncCallback.class.getName()
- + " callback) {");
+ + " callback) {");
w.indent();
w.println("final " + SERIALIZATION_STREAM_READER_INSTANTIATION);
w.println("final " + SERIALIZATION_STREAM_WRITER_INSTANTIATION);
@@ -181,14 +185,14 @@
w.outdent();
w.println("} catch (" + SerializationException.class.getName() + " e) {");
w.indentln("callback.onFailure(new " + InvocationException.class.getName()
- + "(e.getMessage()));");
+ + "(e.getMessage()));");
w.indentln("return;");
w.println("}");
// Generate the async response handler.
//
w.println(ResponseTextHandler.class.getName() + " handler = new "
- + ResponseTextHandler.class.getName() + "() {");
+ + ResponseTextHandler.class.getName() + "() {");
w.indent();
{
w.println("public final void onCompletion(String encodedResponse) {");
@@ -273,7 +277,7 @@
w.indent();
{
w.println("caught = new " + InvocationException.class.getName()
- + "(encodedResponse);");
+ + "(encodedResponse);");
}
w.outdent();
w.println("}");
@@ -310,8 +314,8 @@
//
w.println("if (!com.google.gwt.user.client.HTTPRequest.asyncPost(getServiceEntryPoint(), streamWriter.toString(), handler))");
w.indentln("callback.onFailure(new "
- + InvocationException.class.getName()
- + "(\"Unable to initiate the asynchronous service invocation -- check the network connection\"));");
+ + InvocationException.class.getName()
+ + "(\"Unable to initiate the asynchronous service invocation -- check the network connection\"));");
w.outdent();
w.println("}");
@@ -327,7 +331,7 @@
JParameter[] params = method.getParameters();
w.println();
w.print("private void __" + methodName + "("
- + ClientSerializationStreamWriter.class.getName() + " streamWriter");
+ + ClientSerializationStreamWriter.class.getName() + " streamWriter");
for (int i = 0; i < params.length; i++) {
JParameter param = params[i];
w.print(", " + getJavaTypeName(param.getType()) + " " + param.getName());
@@ -350,18 +354,18 @@
if (!shouldEnforceTypeVersioning()) {
w.println("streamWriter.addFlags("
- + ClientSerializationStreamReader.class.getName()
- + ".SERIALIZATION_STREAM_FLAGS_NO_TYPE_VERSIONING);");
+ + ClientSerializationStreamReader.class.getName()
+ + ".SERIALIZATION_STREAM_FLAGS_NO_TYPE_VERSIONING);");
}
w.println("streamWriter.writeString(\""
- + serializableTypeOracle.getSerializedTypeName(serviceIntf) + "\");");
+ + serializableTypeOracle.getSerializedTypeName(serviceIntf) + "\");");
w.println("streamWriter.writeString(\"" + methodName + "\");");
w.println("streamWriter.writeInt(" + params.length + ");");
for (int i = 0; i < params.length; ++i) {
JParameter param = params[i];
w.println("streamWriter.writeString(\""
- + serializableTypeOracle.getSerializedTypeName(param.getType())
- + "\");");
+ + serializableTypeOracle.getSerializedTypeName(param.getType())
+ + "\");");
}
// Encode the arguments.
@@ -373,7 +377,7 @@
w.outdent();
w.println("}");
- }
+ }
/**
* Generate any fields required by the proxy.
@@ -381,7 +385,7 @@
private void generateProxyFields(SourceWriter srcWriter) {
String typeSerializerName = serializableTypeOracle.getTypeSerializerQualifiedName(serviceIntf);
srcWriter.println("private static final " + typeSerializerName
- + " SERIALIZER = new " + typeSerializerName + "();");
+ + " SERIALIZER = new " + typeSerializerName + "();");
}
/**
@@ -474,25 +478,25 @@
private String getProxyQualifiedName() {
String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- PROXY_SUFFIX);
+ PROXY_SUFFIX);
return name[0].length() == 0 ? name[1] : name[0] + "." + name[1];
}
private String getProxySimpleName() {
String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- PROXY_SUFFIX);
+ PROXY_SUFFIX);
return name[1];
}
private SourceWriter getSourceWriter(TreeLogger logger, GeneratorContext ctx) {
PrintWriter printWriter = ctx.tryCreate(logger, getPackageName(),
- getProxySimpleName());
+ getProxySimpleName());
if (printWriter == null) {
return null;
}
ClassSourceFileComposerFactory composerFactory = new ClassSourceFileComposerFactory(
- getPackageName(), getProxySimpleName());
+ getPackageName(), getProxySimpleName());
composerFactory.addImport(GWT.class.getName());
String className = UncaughtExceptionHandler.class.getName();
@@ -509,7 +513,7 @@
PropertyOracle propertyOracle = context.getPropertyOracle();
try {
String propVal = propertyOracle.getPropertyValue(logger,
- Shared.RPC_PROP_ENFORCE_TYPE_VERSIONING);
+ Shared.RPC_PROP_ENFORCE_TYPE_VERSIONING);
if (propVal != null && propVal.equals("false")) {
enforceTypeVersioning = false;
} else {
@@ -537,7 +541,7 @@
assert (serializableTypeOracle != null);
ServiceInterfaceValidator siv = new ServiceInterfaceValidator(logger, ctx,
- serializableTypeOracle, serviceIntf);
+ serializableTypeOracle, serviceIntf);
try {
return siv.isValid();
@@ -551,8 +555,4 @@
private boolean shouldEnforceTypeVersioning() {
return enforceTypeVersioning;
}
-
- private boolean enforceTypeVersioning;
- private SerializableTypeOracle serializableTypeOracle;
- private JClassType serviceIntf;
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracle.java b/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracle.java
index 190e4f7..7897490 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracle.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracle.java
@@ -24,8 +24,8 @@
*/
public interface ReachableTypeOracle {
/**
- * Determine the set of types that are reachable from the method signatures
- * in this interface and any interfaces that it implements. This includes
+ * Determine the set of types that are reachable from the method signatures in
+ * this interface and any interfaces that it implements. This includes
* parameter types, return types, and checked exception types.
*
* <li>Interface
@@ -33,20 +33,31 @@
* <li>Types reachable from implemented interfaces
* <li>Types reachable from non-static member methods
* </ul>
- *
+ *
* @param intf
* @return reachable types
*/
JType[] getTypesReachableFromInterface(JClassType intf);
-
+
/**
- * Determine the set of types that are reachable from a given type. The rules
+ * Determine the set of type that are reachable from this method signature.
+ * This includes the parameter types, return types, and checked exception
+ * types.
+ *
+ * @param method
+ * @return reachable types
+ */
+ JType[] getTypesReachableFromMethod(JMethod method);
+
+ /**
+ * Determine the set of types that are reachable from a given type. The rules
* used to examine the type are as follows:
- *
+ *
* <ul>
* <li>Primitive
* <ul>
- * <li>Only the primitive is reachable. TODO(mmendez): should the boxed version be included?
+ * <li>Only the primitive is reachable. TODO(mmendez): should the boxed
+ * version be included?
* </ul>
* <li>Interface
* <ul>
@@ -55,7 +66,7 @@
* <li>Method
* <ul>
* <li>Method signatures are ignored by this method.
- * </ul>
+ * </ul>
* <li>Class
* <ul>
* <li>Types reachable from the field types
@@ -76,13 +87,4 @@
* @return reachable types
*/
JType[] getTypesReachableFromType(JType cls);
-
- /**
- * Determine the set of type that are reachable from this method signature. This
- * includes the parameter types, return types, and checked exception types.
- *
- * @param method
- * @return reachable types
- */
- JType[] getTypesReachableFromMethod(JMethod method);
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracleImpl.java b/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracleImpl.java
index 1198b05..2bf111c 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracleImpl.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ReachableTypeOracleImpl.java
@@ -38,27 +38,6 @@
this.rootLogger = rootLogger;
}
- public JType[] getTypesReachableFromType(JType type) {
- if (type.isClass() == null && type.isParameterized() == null
- && type.isArray() == null) {
- // TODO(mmendez): add the proper error message
- throw new IllegalArgumentException();
- }
-
- HashSet cachedResult = (HashSet) reachableTypeCache.get(type);
- if (cachedResult != null) {
- return (JType[]) cachedResult.toArray(new JType[cachedResult.size()]);
- }
-
- HashSet reachableTypes = new HashSet();
-
- addTypesReachableFromType(rootLogger, reachableTypes, type);
-
- reachableTypeCache.put(type, reachableTypes);
-
- return (JType[]) reachableTypes.toArray(new JType[reachableTypes.size()]);
- }
-
public JType[] getTypesReachableFromInterface(JClassType intf) {
if ((intf == null) || (intf.isInterface() == null)) {
// TODO(mmendez): add the proper error message
@@ -94,98 +73,47 @@
return (JType[]) reachableTypes.toArray(new JType[reachableTypes.size()]);
}
- /*
- * Add all types reachable from this interface.
- */
- private void addTypesReachableFromInterface(TreeLogger logger,
- HashSet reachableTypes, JClassType intf) {
- logger = logger.branch(TreeLogger.DEBUG,
- "Adding types reachable from interface " + intf.getQualifiedSourceName(),
- null);
-
- JClassType[] intfs = intf.getImplementedInterfaces();
- for (int intfIndex = 0; intfIndex < intfs.length; ++intfIndex) {
- JClassType intfImpl = intfs[intfIndex];
- assert (intfImpl != null);
-
- addTypesReachableFromInterface(logger, reachableTypes, intfImpl);
+ public JType[] getTypesReachableFromType(JType type) {
+ if (type.isClass() == null && type.isParameterized() == null
+ && type.isArray() == null) {
+ // TODO(mmendez): add the proper error message
+ throw new IllegalArgumentException();
}
- JMethod[] methods = intf.getMethods();
- for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex) {
- JMethod method = methods[methodIndex];
- assert (method != null);
+ HashSet cachedResult = (HashSet) reachableTypeCache.get(type);
+ if (cachedResult != null) {
+ return (JType[]) cachedResult.toArray(new JType[cachedResult.size()]);
+ }
- addTypesReachableFromMethod(logger, reachableTypes, method);
+ HashSet reachableTypes = new HashSet();
+
+ addTypesReachableFromType(rootLogger, reachableTypes, type);
+
+ reachableTypeCache.put(type, reachableTypes);
+
+ return (JType[]) reachableTypes.toArray(new JType[reachableTypes.size()]);
+ }
+
+ private void addTypeReachableFromParameterizedType(TreeLogger logger,
+ HashSet reachableTypes, JParameterizedType parameterizedType) {
+ assert (parameterizedType != null);
+
+ addTypesReachableFromType(logger, reachableTypes,
+ parameterizedType.getRawType());
+
+ JType typeArgs[] = parameterizedType.getTypeArgs();
+ for (int index = 0; index < typeArgs.length; ++index) {
+ JType typeArg = typeArgs[index];
+
+ addTypesReachableFromType(logger, reachableTypes, typeArg);
}
}
- /*
- * Add all types that are reachable from a method by considering the
- * parameters return type, and exceptions thrown.
- */
- private void addTypesReachableFromMethod(TreeLogger logger,
- HashSet reachableTypes, JMethod method) {
- logger = logger.branch(TreeLogger.DEBUG,
- "Adding types reachable from method " + method.getReadableDeclaration(),
- null);
-
- JType returnType = method.getReturnType();
- if (returnType != null) {
- addTypesReachableFromType(logger, reachableTypes, returnType);
- }
-
- JParameter[] params = method.getParameters();
- for (int paramIndex = 0; paramIndex < params.length; ++paramIndex) {
- JParameter param = params[paramIndex];
- addTypesReachableFromType(logger, reachableTypes, param.getType());
- }
-
- JType[] typesThrown = method.getThrows();
- for (int index = 0; index < typesThrown.length; ++index) {
- JType typeThrown = typesThrown[index];
- addTypesReachableFromType(logger, reachableTypes, typeThrown);
- }
- }
-
- /*
- * Implements the type centric part of the static serializability algorithm.
- */
- private void addTypesReachableFromType(TreeLogger logger,
- HashSet reachableTypes, JType type) {
- assert (type != null);
-
- if (reachableTypes.contains(type)) {
- return;
- }
-
- logger = logger
- .branch(TreeLogger.DEBUG, "Adding types reachable from type "
- + type.getQualifiedSourceName(), null);
-
- reachableTypes.add(type);
-
- if (type.isPrimitive() != null) {
- return;
- }
-
- if (type.isArray() != null) {
- addTypesReachableFromArray(logger, reachableTypes, type.isArray());
- return;
- }
-
- if (type.isParameterized() != null) {
- addTypeReachableFromParameterizedType(logger, reachableTypes, type
- .isParameterized());
- return;
- }
-
- if (type.isClassOrInterface() == null) {
- return;
- }
-
- addTypesReachableFromClassOrInterface(logger, reachableTypes, type
- .isClassOrInterface());
+ private void addTypesReachableFromArray(TreeLogger logger,
+ HashSet reachableTypes, JArrayType arrayType) {
+ assert (arrayType != null);
+ JType componentType = arrayType.getComponentType();
+ addTypesReachableFromType(logger, reachableTypes, componentType);
}
private void addTypesReachableFromClassOrInterface(TreeLogger logger,
@@ -229,25 +157,98 @@
}
}
- private void addTypeReachableFromParameterizedType(TreeLogger logger,
- HashSet reachableTypes, JParameterizedType parameterizedType) {
- assert (parameterizedType != null);
+ /*
+ * Add all types reachable from this interface.
+ */
+ private void addTypesReachableFromInterface(TreeLogger logger,
+ HashSet reachableTypes, JClassType intf) {
+ logger = logger.branch(TreeLogger.DEBUG,
+ "Adding types reachable from interface "
+ + intf.getQualifiedSourceName(), null);
- addTypesReachableFromType(logger, reachableTypes, parameterizedType
- .getRawType());
+ JClassType[] intfs = intf.getImplementedInterfaces();
+ for (int intfIndex = 0; intfIndex < intfs.length; ++intfIndex) {
+ JClassType intfImpl = intfs[intfIndex];
+ assert (intfImpl != null);
- JType typeArgs[] = parameterizedType.getTypeArgs();
- for (int index = 0; index < typeArgs.length; ++index) {
- JType typeArg = typeArgs[index];
+ addTypesReachableFromInterface(logger, reachableTypes, intfImpl);
+ }
- addTypesReachableFromType(logger, reachableTypes, typeArg);
+ JMethod[] methods = intf.getMethods();
+ for (int methodIndex = 0; methodIndex < methods.length; ++methodIndex) {
+ JMethod method = methods[methodIndex];
+ assert (method != null);
+
+ addTypesReachableFromMethod(logger, reachableTypes, method);
}
}
- private void addTypesReachableFromArray(TreeLogger logger,
- HashSet reachableTypes, JArrayType arrayType) {
- assert (arrayType != null);
- JType componentType = arrayType.getComponentType();
- addTypesReachableFromType(logger, reachableTypes, componentType);
+ /*
+ * Add all types that are reachable from a method by considering the
+ * parameters return type, and exceptions thrown.
+ */
+ private void addTypesReachableFromMethod(TreeLogger logger,
+ HashSet reachableTypes, JMethod method) {
+ logger = logger.branch(
+ TreeLogger.DEBUG,
+ "Adding types reachable from method " + method.getReadableDeclaration(),
+ null);
+
+ JType returnType = method.getReturnType();
+ if (returnType != null) {
+ addTypesReachableFromType(logger, reachableTypes, returnType);
+ }
+
+ JParameter[] params = method.getParameters();
+ for (int paramIndex = 0; paramIndex < params.length; ++paramIndex) {
+ JParameter param = params[paramIndex];
+ addTypesReachableFromType(logger, reachableTypes, param.getType());
+ }
+
+ JType[] typesThrown = method.getThrows();
+ for (int index = 0; index < typesThrown.length; ++index) {
+ JType typeThrown = typesThrown[index];
+ addTypesReachableFromType(logger, reachableTypes, typeThrown);
+ }
+ }
+
+ /*
+ * Implements the type centric part of the static serializability algorithm.
+ */
+ private void addTypesReachableFromType(TreeLogger logger,
+ HashSet reachableTypes, JType type) {
+ assert (type != null);
+
+ if (reachableTypes.contains(type)) {
+ return;
+ }
+
+ logger = logger.branch(TreeLogger.DEBUG,
+ "Adding types reachable from type " + type.getQualifiedSourceName(),
+ null);
+
+ reachableTypes.add(type);
+
+ if (type.isPrimitive() != null) {
+ return;
+ }
+
+ if (type.isArray() != null) {
+ addTypesReachableFromArray(logger, reachableTypes, type.isArray());
+ return;
+ }
+
+ if (type.isParameterized() != null) {
+ addTypeReachableFromParameterizedType(logger, reachableTypes,
+ type.isParameterized());
+ return;
+ }
+
+ if (type.isClassOrInterface() == null) {
+ return;
+ }
+
+ addTypesReachableFromClassOrInterface(logger, reachableTypes,
+ type.isClassOrInterface());
}
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializableType.java b/user/src/com/google/gwt/user/rebind/rpc/SerializableType.java
index 51cf2ca..f614baf 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableType.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableType.java
@@ -34,14 +34,24 @@
this.isSerializable = isSerializable;
}
- public JType getType() {
- return type;
+ public JClassType getCustomSerializer() {
+ if (customSerializerInfo != null) {
+ return customSerializerInfo.getSerializerClass();
+ }
+
+ return null;
}
- public String toString() {
- String s = isSerializable() ? "Serializable " : "Unserializable ";
- s += type.toString();
- return s;
+ public JMethod getCustomSerializerInstantiateMethod() {
+ if (customSerializerInfo != null) {
+ return customSerializerInfo.getInstantiateMethod();
+ }
+
+ return null;
+ }
+
+ public JType getType() {
+ return type;
}
public boolean hasCustomSerializer() {
@@ -68,19 +78,9 @@
this.isSerializable = serializable;
}
- public JClassType getCustomSerializer() {
- if (customSerializerInfo != null) {
- return customSerializerInfo.getSerializerClass();
- }
-
- return null;
- }
-
- public JMethod getCustomSerializerInstantiateMethod() {
- if (customSerializerInfo != null) {
- return customSerializerInfo.getInstantiateMethod();
- }
-
- return null;
+ public String toString() {
+ String s = isSerializable() ? "Serializable " : "Unserializable ";
+ s += type.toString();
+ return s;
}
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java
index 418c842..4ee6f89 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracle.java
@@ -24,35 +24,73 @@
* Interface implemented by any class that wants to answer questions about
* serializable types.
*/
-public interface SerializableTypeOracle {
+public interface SerializableTypeOracle {
+ /**
+ * Returns the set of fields that are serializable for a given class type.
+ * This method does not consider any superclass fields.
+ *
+ * @param classType the class for which we want serializable fields
+ * @return array of fields that meet the serialization criteria.
+ */
+ JField[] applyFieldSerializationPolicy(JClassType classType);
+
/**
* Creates a string that represents a serialized instance reference from a
* qualified type name.
*
- * @param instanceType
+ * @param instanceType
* @return string containing a serialized instance reference
*/
String encodeSerializedInstanceReference(JType instanceType);
/**
+ * Returns the instantiate method on a custom field serializer if there is one
+ * and it is valid or null if there is not.
+ *
+ * @param type
+ * @return reference to a valid custom field serializer instantiation method
+ * or null
+ */
+ JMethod getCustomFieldSerializerInstantiateMethodForType(JType type);
+
+ /**
+ * Returns the name of the field serializer for a particular type. This name
+ * can be either the name of a custom field serializer or that of a generated
+ * field serializer. If the type is not serializable then it can return null.
+ *
+ * @param type the type that is going to be serialized
+ * @return the fully qualified name of the field serializer for the given type
+ */
+ String getFieldSerializerName(JType type);
+
+ /**
+ * Returns the list of all types that are considered serializable.
+ *
+ * @return array of serializable types
+ */
+ JType[] getSerializableTypes();
+
+ /**
+ * Get the set of serializable types that are assignable to the requested
+ * class, interface, primitive, parameterized, or array type. The set of types
+ * for arrays will always be the inner most component type if it is
+ * serializable or for parameterized types it will be the set of types
+ * assignable to the raw parameterized type.
+ *
+ * @param type
+ * @return array of serializable types that are assignable to the given type
+ */
+ JType[] getSerializableTypesAssignableTo(JType type);
+
+ /**
* Returns the serialization signature for a type.
*
- * @param instanceType
+ * @param instanceType
* @return a string representing the serialization signature of a type
*/
String getSerializationSignature(JType instanceType);
/**
- * Returns true if the type is serializable. If a type is serializable then
- * there is a secondary type called a FieldSerializer that provides the
- * behavior necessary to serialize or deserialize the fields of an instance.
- *
- * @param type the type that maybe serializable
- * @return true if the type is serializable
- */
- boolean isSerializable(JType type);
-
- /**
* Returns the serialized name of a type.
*
* The following table describes the encoding of a serialized type name.
@@ -98,39 +136,10 @@
String getSerializedTypeName(JType type);
/**
- * Returns the name of the field serializer for a particular type. This name
- * can be either the name of a custom field serializer or that of a generated
- * field serializer. If the type is not serializable then it can return null.
- *
- * @param type the type that is going to be serialized
- * @return the fully qualified name of the field serializer for the given type
- */
- String getFieldSerializerName(JType type);
-
- /**
- * Returns the list of all types that are considered serializable.
- *
- * @return array of serializable types
- */
- JType[] getSerializableTypes();
-
- /**
- * Get the set of serializable types that are assignable to the requested
- * class, interface, primitive, parameterized, or array type. The set of types
- * for arrays will always be the inner most component type if it is
- * serializable or for parameterized types it will be the set of types
- * assignable to the raw parameterized type.
- *
- * @param type
- * @return array of serializable types that are assignable to the given type
- */
- JType[] getSerializableTypesAssignableTo(JType type);
-
- /**
* Returns the qualified name of the type serializer class for the given
* service interface.
*
- * @param serviceIntf service interface
+ * @param serviceIntf service interface
* @return name of the type serializer that handles the service interface
*/
String getTypeSerializerQualifiedName(JClassType serviceIntf);
@@ -145,30 +154,21 @@
String getTypeSerializerSimpleName(JClassType serviceIntf);
/**
- * Returns the custom field serializer associated with the given type. If there
- * is none, null is returned.
+ * Returns the custom field serializer associated with the given type. If
+ * there is none, null is returned.
*
- * @param type type that may have a custom field serializer
+ * @param type type that may have a custom field serializer
* @return custom field serializer or null if there is none
*/
JClassType hasCustomFieldSerializer(JType type);
/**
- * Returns the instantiate method on a custom field serializer if there is one
- * and it is valid or null if there is not.
+ * Returns true if the type is serializable. If a type is serializable then
+ * there is a secondary type called a FieldSerializer that provides the
+ * behavior necessary to serialize or deserialize the fields of an instance.
*
- * @param type
- * @return reference to a valid custom field serializer instantiation method
- * or null
+ * @param type the type that maybe serializable
+ * @return true if the type is serializable
*/
- JMethod getCustomFieldSerializerInstantiateMethodForType(JType type);
-
- /**
- * Returns the set of fields that are serializable for a given class type. This
- * method does not consider any superclass fields.
- *
- * @param classType the class for which we want serializable fields
- * @return array of fields that meet the serialization criteria.
- */
- JField[] applyFieldSerializationPolicy(JClassType classType);
+ boolean isSerializable(JType type);
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
index 3311111..1b39dd2 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleBuilder.java
@@ -41,8 +41,8 @@
/**
* This class is responsible for building an oracle can answer questions about
* the set of serializable types that are reachable from an interface that
- * extends the {@link com.google.gwt.user.client.rpc.RemoteService RemoteService}
- * interface.
+ * extends the
+ * {@link com.google.gwt.user.client.rpc.RemoteService RemoteService} interface.
*
* <p>
* A type is serializable if:
@@ -107,6 +107,34 @@
private static final String UNSERIALIZABLE_FIELD = "Field ''{0}'' is not of a serializable type nor does that type have serializable subtypes";
private static final String UNSERIALIZABLE_TYPE_ARG = "typeArg ''{0}'' is not of a serializable type, nor does that type have serializable subtypes";
+ /*
+ * A map of type to CustomSerializer entry that handles contains information
+ * about the custom serializer that handles it. If there is no entry then the
+ * type does not have a custom serializer.
+ */
+ private Map customSerializers;
+
+ private final JClassType objectType;
+
+ /*
+ * Set of types that are reachable from a service interface
+ */
+ private Map reachableTypes;
+
+ private final Map reasonsForUnserializability = new HashMap();
+
+ private final TreeLogger rootLogger;
+
+ /*
+ * Cache for the JClassType instance associated with the IsSerializable
+ * interface
+ */
+ private final JClassType serializationMarkerIntf;
+
+ private final JClassType stringType;
+
+ private final TypeOracle typeOracle;
+
public SerializableTypeOracleBuilder(TreeLogger rootLogger,
TypeOracle typeOracle) throws NotFoundException {
assert (rootLogger != null);
@@ -129,7 +157,7 @@
reachableTypes = new IdentityHashMap();
TreeLogger logger = rootLogger.branch(TreeLogger.DEBUG,
- "Analyzing serializability for " + types.length + " types", null);
+ "Analyzing serializability for " + types.length + " types", null);
customSerializers = initializeCustomSerializers(types);
if (customSerializers == null) {
@@ -183,18 +211,18 @@
String qualifiedTypeName = type.getQualifiedSourceName();
JClassType customSerializer = typeOracle.findType(qualifiedTypeName
- + CUSTOM_FIELD_SERIALIZER_SUFFIX);
+ + CUSTOM_FIELD_SERIALIZER_SUFFIX);
if (customSerializer != null) {
return customSerializer;
}
// Try with the regular name
String simpleSerializerName = qualifiedTypeName
- + CUSTOM_FIELD_SERIALIZER_SUFFIX;
+ + CUSTOM_FIELD_SERIALIZER_SUFFIX;
String[] packagePaths = getPackagePaths();
for (int i = 0; i < packagePaths.length; ++i) {
customSerializer = typeOracle.findType(packagePaths[i] + "."
- + simpleSerializerName);
+ + simpleSerializerName);
if (customSerializer != null) {
return customSerializer;
}
@@ -212,7 +240,7 @@
}
private String[] getPackagePaths() {
- return new String[]{"com.google.gwt.user.client.rpc.core"};
+ return new String[] {"com.google.gwt.user.client.rpc.core"};
}
private String getReasonForUnserializability(JType type) {
@@ -226,7 +254,7 @@
JType t1 = (JType) o1;
JType t2 = (JType) o2;
return t1.getParameterizedQualifiedSourceName().compareTo(
- t2.getParameterizedQualifiedSourceName());
+ t2.getParameterizedQualifiedSourceName());
}
});
@@ -281,7 +309,7 @@
if (!hasSerializableSubtypes(fieldType)) {
addReasonForUnserializability(type, MessageFormat.format(
- UNSERIALIZABLE_FIELD, new String[]{field.toString()}));
+ UNSERIALIZABLE_FIELD, new String[] {field.toString()}));
return false;
}
}
@@ -360,7 +388,7 @@
// Validate the list of potential custom field serializers
//
return CustomFieldSerializerValidator.validateCustomFieldSerializers(
- rootLogger, typeOracle, serializers);
+ rootLogger, typeOracle, serializers);
}
private void initializeSerializability(JType[] types) {
@@ -376,7 +404,7 @@
//
CustomSerializerInfo customSerializerInfo = (CustomSerializerInfo) customSerializers.get(type);
reachableTypes.put(type, new SerializableType(type, true,
- customSerializerInfo));
+ customSerializerInfo));
}
}
@@ -470,10 +498,10 @@
JType[] serializableTypes = getSortedArray(serializableTypesList);
if (serializableTypes.length > 0) {
TreeLogger localLogger = logger.branch(TreeLogger.DEBUG,
- "The following types were determined to be serializable:", null);
+ "The following types were determined to be serializable:", null);
for (int i = 0; i < serializableTypes.length; ++i) {
localLogger.log(TreeLogger.DEBUG,
- serializableTypes[i].getParameterizedQualifiedSourceName(), null);
+ serializableTypes[i].getParameterizedQualifiedSourceName(), null);
}
}
@@ -485,18 +513,18 @@
// will WARN, which will upgrade this branch.
//
TreeLogger localLogger = logger.branch(TreeLogger.DEBUG,
- "The following types were determined to be unserializable:", null);
+ "The following types were determined to be unserializable:", null);
for (int i = 0; i < unserializableTypes.length; ++i) {
JType unserializableType = unserializableTypes[i];
String reason = getReasonForUnserializability(unserializableType);
if (reason != null) {
TreeLogger branch = localLogger.branch(TreeLogger.INFO,
- unserializableType.getParameterizedQualifiedSourceName(), null);
+ unserializableType.getParameterizedQualifiedSourceName(), null);
branch.log(TreeLogger.INFO, reason, null);
} else {
localLogger.log(TreeLogger.DEBUG,
- unserializableType.getParameterizedQualifiedSourceName(), null);
+ unserializableType.getParameterizedQualifiedSourceName(), null);
}
}
}
@@ -588,8 +616,8 @@
if (!isSerializable(compType) && !hasSerializableSubtypes(compType)) {
addReasonForUnserializability(isArray, MessageFormat.format(
- NO_SERIALIZABLE_COMPONENT_TYPE,
- new String[]{compType.getQualifiedSourceName()}));
+ NO_SERIALIZABLE_COMPONENT_TYPE,
+ new String[] {compType.getQualifiedSourceName()}));
return true;
}
@@ -657,8 +685,8 @@
}
} else {
addReasonForUnserializability(type, MessageFormat.format(
- SUPERCLASS_IS_NOT_SERIALIZABLE,
- new String[]{superClass.getQualifiedSourceName()}));
+ SUPERCLASS_IS_NOT_SERIALIZABLE,
+ new String[] {superClass.getQualifiedSourceName()}));
}
} else {
addReasonForUnserializability(type, NOT_SERIALIZABLE);
@@ -687,8 +715,8 @@
JType rawType = parameterizedType.getRawType();
if (!isSerializable(rawType)) {
addReasonForUnserializability(parameterizedType, MessageFormat.format(
- RAW_TYPE_IS_NOT_SERIALIZABLE,
- new String[]{rawType.getQualifiedSourceName()}));
+ RAW_TYPE_IS_NOT_SERIALIZABLE,
+ new String[] {rawType.getQualifiedSourceName()}));
return true;
}
@@ -697,40 +725,12 @@
JType type = typeArgs[index];
if (!isSerializable(type) && !hasSerializableSubtypes(type)) {
addReasonForUnserializability(parameterizedType, MessageFormat.format(
- UNSERIALIZABLE_TYPE_ARG,
- new String[]{type.getParameterizedQualifiedSourceName()}));
+ UNSERIALIZABLE_TYPE_ARG,
+ new String[] {type.getParameterizedQualifiedSourceName()}));
return true;
}
}
return false;
}
-
- /*
- * A map of type to CustomSerializer entry that handles contains information
- * about the custom serializer that handles it. If there is no entry then the
- * type does not have a custom serializer.
- */
- private Map customSerializers;
-
- private final JClassType objectType;
-
- /*
- * Set of types that are reachable from a service interface
- */
- private Map reachableTypes;
-
- private final Map reasonsForUnserializability = new HashMap();
-
- private final TreeLogger rootLogger;
-
- /*
- * Cache for the JClassType instance associated with the IsSerializable
- * interface
- */
- private final JClassType serializationMarkerIntf;
-
- private final JClassType stringType;
-
- private final TypeOracle typeOracle;
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleImpl.java b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleImpl.java
index 264d627..1ecb7cc 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleImpl.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/SerializableTypeOracleImpl.java
@@ -47,6 +47,38 @@
private static final Set TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES = new HashSet();
+ static {
+ PRIMITIVE_TYPE_BINARY_NAMES.put("boolean", "Z");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("byte", "B");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("char", "C");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("double", "D");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("float", "F");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("int", "I");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("long", "J");
+ PRIMITIVE_TYPE_BINARY_NAMES.put("short", "S");
+
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Boolean");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Byte");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Character");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Double");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Exception");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Float");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Integer");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Long");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Object");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Short");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.String");
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Throwable");
+ }
+
+ private Map assignableTypeCache;
+
+ private JType objectType;
+
+ private Map reachableTypes;
+
+ private TypeOracle typeOracle;
+
public SerializableTypeOracleImpl(TypeOracle typeOracle, Map reachableTypes)
throws NotFoundException {
this.reachableTypes = reachableTypes;
@@ -86,7 +118,7 @@
public String encodeSerializedInstanceReference(JType instanceType) {
return getSerializedTypeName(instanceType) + "/"
- + getSerializationSignature(instanceType);
+ + getSerializationSignature(instanceType);
}
public String encodeSerializedInstanceReference(String qualifiedTypeName)
@@ -125,7 +157,7 @@
JClassType classType = type.isClassOrInterface();
if (classType != null) {
String[] name = Shared.synthesizeTopLevelClassName(classType,
- GENERATED_FIELD_SERIALIZER_SUFFIX);
+ GENERATED_FIELD_SERIALIZER_SUFFIX);
if (name[0].length() > 0) {
return name[0] + "." + name[1];
} else {
@@ -171,7 +203,7 @@
JPrimitiveType primitive = type.isPrimitive();
if (primitive != null) {
// Primitives are always serializable and assignable to themselves.
- return new JType[]{primitive};
+ return new JType[] {primitive};
}
// Order is important here since Parameterized types
@@ -212,7 +244,7 @@
Object val = PRIMITIVE_TYPE_BINARY_NAMES.get(primitiveType.getSimpleSourceName());
if (val == null) {
throw new RuntimeException("Unexpected primitive type '"
- + primitiveType.getQualifiedSourceName() + "'");
+ + primitiveType.getQualifiedSourceName() + "'");
}
return (String) val;
@@ -222,10 +254,10 @@
if (arrayType != null) {
JType componentType = arrayType.getComponentType();
boolean isClassOrInterface = (componentType.isArray() == null)
- && (componentType.isPrimitive() == null);
+ && (componentType.isPrimitive() == null);
return "[" + (isClassOrInterface ? "L" : "")
- + getSerializedTypeName(arrayType.getComponentType())
- + (isClassOrInterface ? ";" : "");
+ + getSerializedTypeName(arrayType.getComponentType())
+ + (isClassOrInterface ? ";" : "");
}
JParameterizedType parameterizedType = type.isParameterized();
@@ -239,7 +271,7 @@
JClassType enclosingType = classType.getEnclosingType();
if (enclosingType != null) {
return getSerializedTypeName(enclosingType) + "$"
- + classType.getSimpleSourceName();
+ + classType.getSimpleSourceName();
}
JPackage pkg = classType.getPackage();
@@ -258,7 +290,7 @@
Object val = PRIMITIVE_TYPE_BINARY_NAMES.get(type.getSimpleSourceName());
if (val == null) {
throw new RuntimeException("Unexpected primitive type '"
- + type.getQualifiedSourceName() + "'");
+ + type.getQualifiedSourceName() + "'");
}
return (String) val;
@@ -267,13 +299,14 @@
JArrayType arrayType = type.isArray();
if (arrayType != null) {
return "["
- + getSerializedTypeName(arrayType.getComponentType(), addTypeSignature);
+ + getSerializedTypeName(arrayType.getComponentType(),
+ addTypeSignature);
}
JParameterizedType parameterizedType = type.isParameterized();
if (parameterizedType != null) {
return getSerializedTypeName(parameterizedType.getRawType(),
- addTypeSignature);
+ addTypeSignature);
}
JClassType classType = type.isClassOrInterface();
@@ -299,7 +332,7 @@
JClassType customSerializer = hasCustomFieldSerializer(classType);
if (customSerializer != null) {
serializedTypeName += "/"
- + getSerializedInstanceReference(customSerializer);
+ + getSerializedInstanceReference(customSerializer);
}
}
@@ -309,11 +342,11 @@
public String getTypeSerializerQualifiedName(JClassType serviceIntf) {
if (serviceIntf.isInterface() == null) {
throw new IllegalArgumentException(serviceIntf.getQualifiedSourceName()
- + " is not a service interface");
+ + " is not a service interface");
}
String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- TYPE_SERIALIZER_SUFFIX);
+ TYPE_SERIALIZER_SUFFIX);
if (name[0].length() > 0) {
return name[0] + "." + name[1];
} else {
@@ -324,11 +357,11 @@
public String getTypeSerializerSimpleName(JClassType serviceIntf) {
if (serviceIntf.isInterface() == null) {
throw new IllegalArgumentException(serviceIntf.getQualifiedSourceName()
- + " is not a service interface");
+ + " is not a service interface");
}
String[] name = Shared.synthesizeTopLevelClassName(serviceIntf,
- TYPE_SERIALIZER_SUFFIX);
+ TYPE_SERIALIZER_SUFFIX);
return name[1];
}
@@ -355,7 +388,7 @@
JType componentType = arrayType.getComponentType();
JPrimitiveType primitiveType = componentType.isPrimitive();
String qualifiedSerializerName = DEFAULT_BUILTIN_CUSTOM_SERIALIZER_PACKAGE_NAME
- + ".";
+ + ".";
if (primitiveType != null) {
qualifiedSerializerName += primitiveType.getSimpleSourceName();
} else {
@@ -453,33 +486,4 @@
return (JType[]) assignableTypes.toArray(new JType[assignableTypes.size()]);
}
-
- static {
- PRIMITIVE_TYPE_BINARY_NAMES.put("boolean", "Z");
- PRIMITIVE_TYPE_BINARY_NAMES.put("byte", "B");
- PRIMITIVE_TYPE_BINARY_NAMES.put("char", "C");
- PRIMITIVE_TYPE_BINARY_NAMES.put("double", "D");
- PRIMITIVE_TYPE_BINARY_NAMES.put("float", "F");
- PRIMITIVE_TYPE_BINARY_NAMES.put("int", "I");
- PRIMITIVE_TYPE_BINARY_NAMES.put("long", "J");
- PRIMITIVE_TYPE_BINARY_NAMES.put("short", "S");
-
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Boolean");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Byte");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Character");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Double");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Exception");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Float");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Integer");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Long");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Object");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Short");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.String");
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add("java.lang.Throwable");
- }
-
- private Map assignableTypeCache;
- private JType objectType;
- private Map reachableTypes;
- private TypeOracle typeOracle;
}
diff --git a/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceValidator.java b/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceValidator.java
index 81674cd..37f6c59 100644
--- a/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceValidator.java
+++ b/user/src/com/google/gwt/user/rebind/rpc/ServiceInterfaceValidator.java
@@ -45,13 +45,13 @@
for (int index = 0; index < params.length; ++index) {
asyncParamTypes[index] = getUnparameterizedType(typeOracle,
- params[index].getType());
+ params[index].getType());
}
asyncParamTypes[params.length] = typeOracle.findType(AsyncCallback.class.getName());
if (asyncParamTypes[params.length] == null) {
throw new IllegalStateException("Unable to locate definition of "
- + AsyncCallback.class.getName());
+ + AsyncCallback.class.getName());
}
return asyncParamTypes;
@@ -86,13 +86,13 @@
private static void raiseInvalidAsyncIntf(TreeLogger logger,
JClassType serviceIntf) {
logger = logger.branch(TreeLogger.ERROR,
- "No valid asynchronous version for the service interface "
- + serviceIntf.getQualifiedSourceName(), null);
+ "No valid asynchronous version for the service interface "
+ + serviceIntf.getQualifiedSourceName(), null);
String correctAsyncIntf = synthesizeAsynchronousInterfaceDefinition(serviceIntf);
logger.log(TreeLogger.INFO,
- "A valid definition for an asychronous version of interface "
- + serviceIntf.getQualifiedSourceName() + " would be:\n"
- + correctAsyncIntf, null);
+ "A valid definition for an asychronous version of interface "
+ + serviceIntf.getQualifiedSourceName() + " would be:\n"
+ + correctAsyncIntf, null);
}
private static String synthesizeAsynchronousInterfaceDefinition(
@@ -146,6 +146,18 @@
return sb.toString();
}
+ private JClassType objectType;
+
+ private TreeLogger rootLogger;
+
+ private SerializableTypeOracle serializationOracle;
+
+ private JClassType serviceIntf;
+
+ private TypeOracle typeOracle;
+
+ private Map typeToFinalInstanceFieldCache = new IdentityHashMap();
+
public ServiceInterfaceValidator(TreeLogger logger, GeneratorContext genCtx,
SerializableTypeOracle serializationOracle, JClassType serviceIntf) {
this.rootLogger = logger;
@@ -156,7 +168,7 @@
this.objectType = typeOracle.getJavaLangObject();
if (this.objectType == null) {
logger.log(TreeLogger.ERROR,
- "Could not find a definition of java.lang.Object", null);
+ "Could not find a definition of java.lang.Object", null);
throw new RuntimeException();
}
}
@@ -168,8 +180,8 @@
*/
public boolean isValid() throws TypeOracleException {
TreeLogger logger = rootLogger.branch(TreeLogger.SPAM,
- "Validating service interface '" + serviceIntf.getQualifiedSourceName()
- + "'", null);
+ "Validating service interface '" + serviceIntf.getQualifiedSourceName()
+ + "'", null);
typeToFinalInstanceFieldCache.clear();
@@ -198,7 +210,7 @@
JField declField = declFields[i];
if (declField.isFinal() && !declField.isStatic()
- && !declField.isTransient()) {
+ && !declField.isTransient()) {
// we found an invalid final instance field
firstFinalInstField = declField;
break;
@@ -236,24 +248,24 @@
private void logSerializableArgumentTypes(TreeLogger logger,
JParameter param, JType[] serializableTypes) {
logger = logger.branch(TreeLogger.SPAM, "Argument '" + param.getName()
- + "' of type '" + param.getType().getQualifiedSourceName()
- + "' can only be serialized as: ", null);
+ + "' of type '" + param.getType().getQualifiedSourceName()
+ + "' can only be serialized as: ", null);
logSerializableTypes(logger, serializableTypes);
}
private void logSerializableExceptionTypes(TreeLogger logger, JType ex,
JType[] serializableTypes) {
logger = logger.branch(TreeLogger.SPAM, "Exception type "
- + ex.getQualifiedSourceName()
- + " can only be one of the following serializable types: ", null);
+ + ex.getQualifiedSourceName()
+ + " can only be one of the following serializable types: ", null);
logSerializableTypes(logger, serializableTypes);
}
private void logSerializableReturnTypes(TreeLogger logger, JType returnType,
JType[] serializableTypes) {
logger = logger.branch(TreeLogger.SPAM, "Return type "
- + returnType.getQualifiedSourceName()
- + " can only be one of the following serializable types: ", null);
+ + returnType.getQualifiedSourceName()
+ + " can only be one of the following serializable types: ", null);
logSerializableTypes(logger, serializableTypes);
}
@@ -270,17 +282,17 @@
}
TreeLogger branchedLog = logger.branch(TreeLogger.SPAM,
- classType.getParameterizedQualifiedSourceName(), null);
+ classType.getParameterizedQualifiedSourceName(), null);
JField problematicField = findFirstInvalidFinalField(classType);
if (problematicField != null && !hasCustomInstantiation(classType)) {
JType enclosingType = problematicField.getEnclosingType();
String warningMessage = "The field '" + problematicField.toString()
- + "'";
+ + "'";
if (enclosingType != classType) {
warningMessage += ", inherited from '"
- + enclosingType.getParameterizedQualifiedSourceName() + "',";
+ + enclosingType.getParameterizedQualifiedSourceName() + "',";
}
warningMessage += " will not be included because it is a 'final' instance field that is not also 'transient'";
@@ -297,32 +309,33 @@
private void raiseInvalidArgumentType(TreeLogger logger, JParameter param) {
if (param.getType() == objectType) {
logger.branch(
- TreeLogger.ERROR,
- "In order to produce smaller client-side code, methods cannot specify 'Object' for parameter types; please choose a more specific parameter type",
- null);
+ TreeLogger.ERROR,
+ "In order to produce smaller client-side code, methods cannot specify 'Object' for parameter types; please choose a more specific parameter type",
+ null);
} else {
logger.branch(TreeLogger.ERROR, "Parameter '" + param.getName()
- + "' of type '" + param.getType().getParameterizedQualifiedSourceName()
- + "' is not serializable and/or has no serializable subtypes", null);
+ + "' of type '"
+ + param.getType().getParameterizedQualifiedSourceName()
+ + "' is not serializable and/or has no serializable subtypes", null);
}
}
private void raiseInvalidExceptionType(TreeLogger logger, JType ex) {
logger.branch(TreeLogger.ERROR, "Exception type "
- + ex.getQualifiedSourceName()
- + " is not serializable and/or has no serializable subtypes", null);
+ + ex.getQualifiedSourceName()
+ + " is not serializable and/or has no serializable subtypes", null);
}
private void raiseInvalidReturnType(TreeLogger logger, JType returnType) {
if (returnType == objectType) {
logger.branch(
- TreeLogger.ERROR,
- "In order to produce smaller client-side code, methods cannot specify 'Object' for return types; please choose a more specific return type",
- null);
+ TreeLogger.ERROR,
+ "In order to produce smaller client-side code, methods cannot specify 'Object' for return types; please choose a more specific return type",
+ null);
} else {
logger.branch(TreeLogger.ERROR, "Return type "
- + returnType.getParameterizedQualifiedSourceName()
- + " is not serializable and/or has no serializable subtypes", null);
+ + returnType.getParameterizedQualifiedSourceName()
+ + " is not serializable and/or has no serializable subtypes", null);
}
}
@@ -353,11 +366,11 @@
JType[] asyncParamTypes = getAsyncParamTypes(method, typeOracle);
JMethod asyncMethod = asyncServiceIntf.findMethod(method.getName(),
- asyncParamTypes);
+ asyncParamTypes);
if (asyncMethod == null) {
logger.branch(TreeLogger.ERROR,
- "No asynchronous version of the synchronous method "
- + method.getReadableDeclaration(), null);
+ "No asynchronous version of the synchronous method "
+ + method.getReadableDeclaration(), null);
failed = true;
}
}
@@ -379,7 +392,7 @@
boolean failed = false;
logger = logger.branch(TreeLogger.SPAM, "Service interface: "
- + classOrInterface.getQualifiedSourceName(), null);
+ + classOrInterface.getQualifiedSourceName(), null);
JClassType intfs[] = classOrInterface.getImplementedInterfaces();
for (int index = 0; index < intfs.length; ++index) {
@@ -408,7 +421,7 @@
*/
private boolean validMethod(TreeLogger logger, JMethod method) {
logger = logger.branch(TreeLogger.SPAM, "Service method: "
- + method.getReadableDeclaration(), null);
+ + method.getReadableDeclaration(), null);
boolean failed = false;
JType returnType = method.getReturnType();
if (returnType != null && returnType != JPrimitiveType.VOID) {
@@ -488,7 +501,7 @@
boolean failed = false;
logger = logger.branch(TreeLogger.SPAM, "Service interface: "
- + serviceIntf.getQualifiedSourceName(), null);
+ + serviceIntf.getQualifiedSourceName(), null);
JClassType intfs[] = serviceIntf.getImplementedInterfaces();
for (int index = 0; index < intfs.length; ++index) {
@@ -510,11 +523,4 @@
return !failed;
}
-
- private JClassType objectType;
- private TreeLogger rootLogger;
- private SerializableTypeOracle serializationOracle;
- private JClassType serviceIntf;
- private TypeOracle typeOracle;
- private Map typeToFinalInstanceFieldCache = new IdentityHashMap();
}
diff --git a/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java b/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java
index 0e37238..d329c2a 100644
--- a/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java
+++ b/user/src/com/google/gwt/user/server/rpc/RemoteServiceServlet.java
@@ -64,6 +64,18 @@
*/
private static final int UNCOMPRESSED_BYTE_SIZE_LIMIT = 256;
+ static {
+ TYPE_NAMES = new HashMap();
+ TYPE_NAMES.put("Z", boolean.class);
+ TYPE_NAMES.put("B", byte.class);
+ TYPE_NAMES.put("C", char.class);
+ TYPE_NAMES.put("D", double.class);
+ TYPE_NAMES.put("F", float.class);
+ TYPE_NAMES.put("I", int.class);
+ TYPE_NAMES.put("J", long.class);
+ TYPE_NAMES.put("S", short.class);
+ }
+
/**
* Return true if the response object accepts Gzip encoding. This is done by
* checking that the accept-encoding header specifies gzip as a supported
@@ -106,7 +118,7 @@
Class[] superintfs = intf.getInterfaces();
for (int i = 0; i < superintfs.length; i++) {
Method method = findInterfaceMethod(superintfs[i], methodName,
- paramTypes, true);
+ paramTypes, true);
if (method != null) {
return method;
}
@@ -117,12 +129,20 @@
}
}
+ private final Set knownImplementedInterfaces = new HashSet();
+
+ private final ThreadLocal perThreadRequest = new ThreadLocal();
+
+ private final ThreadLocal perThreadResponse = new ThreadLocal();
+
+ private final ServerSerializableTypeOracle serializableTypeOracle;
+
/**
* The default constructor.
*/
public RemoteServiceServlet() {
serializableTypeOracle = new ServerSerializableTypeOracleImpl(
- getPackagePaths());
+ getPackagePaths());
}
/**
@@ -175,7 +195,7 @@
// Create a stream to deserialize the request.
//
ServerSerializationStreamReader streamReader = new ServerSerializationStreamReader(
- serializableTypeOracle);
+ serializableTypeOracle);
streamReader.prepareToRead(payload);
// Read the service interface
@@ -189,9 +209,9 @@
// Bad payload, possible hack attempt.
//
throw new SecurityException(
- "Blocked attempt to access interface '"
- + serviceIntfName
- + "', which is either not implemented by this servlet or which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
+ "Blocked attempt to access interface '"
+ + serviceIntfName
+ + "', which is either not implemented by this servlet or which doesn't extend RemoteService; this is either misconfiguration or a hack attempt");
}
// Actually get the service interface, so that we can query its methods.
@@ -201,7 +221,7 @@
serviceIntf = getClassFromName(serviceIntfName);
} catch (ClassNotFoundException e) {
throw new SerializationException("Unknown service interface class '"
- + serviceIntfName + "'", e);
+ + serviceIntfName + "'", e);
}
// Read the method name.
@@ -220,7 +240,7 @@
paramTypes[i] = getClassOrPrimitiveFromName(paramClassName);
} catch (ClassNotFoundException e) {
throw new SerializationException("Unknown parameter " + i + " type '"
- + paramClassName + "'", e);
+ + paramClassName + "'", e);
}
}
@@ -228,16 +248,19 @@
// and not just one that happens to be defined on this class.
//
Method serviceIntfMethod = findInterfaceMethod(serviceIntf, methodName,
- paramTypes, true);
+ paramTypes, true);
// If it wasn't found, don't continue.
//
if (serviceIntfMethod == null) {
// Bad payload, possible hack attempt.
//
- throw new SecurityException("Method '" + methodName
- + "' (or a particular overload) on interface '" + serviceIntfName
- + "' was not found, this is either misconfiguration or a hack attempt");
+ throw new SecurityException(
+ "Method '"
+ + methodName
+ + "' (or a particular overload) on interface '"
+ + serviceIntfName
+ + "' was not found, this is either misconfiguration or a hack attempt");
}
// Deserialize the parameters.
@@ -251,13 +274,13 @@
//
String responsePayload = GENERIC_FAILURE_MSG;
ServerSerializationStreamWriter streamWriter = new ServerSerializationStreamWriter(
- serializableTypeOracle);
+ serializableTypeOracle);
Throwable caught = null;
try {
Class returnType = serviceIntfMethod.getReturnType();
Object returnVal = serviceIntfMethod.invoke(this, args);
responsePayload = createResponse(streamWriter, returnType, returnVal,
- false);
+ false);
} catch (IllegalArgumentException e) {
caught = e;
} catch (IllegalAccessException e) {
@@ -275,7 +298,7 @@
if (isExpectedException(serviceIntfMethod, cause)) {
Class thrownClass = cause.getClass();
responsePayload = createResponse(streamWriter, thrownClass, cause,
- true);
+ true);
// Don't log the exception on the server
caught = null;
}
@@ -289,7 +312,7 @@
if (servletContext != null) {
// Log the exception server side
servletContext.log("Exception while dispatching incoming RPC call",
- caught);
+ caught);
}
}
@@ -379,6 +402,17 @@
}
/**
+ * Returns the {@link Class} instance for the named class.
+ *
+ * @param name the name of a class or primitive type
+ * @return Class instance for the given type name
+ * @throws ClassNotFoundException if the named type was not found
+ */
+ private Class getClassFromName(String name) throws ClassNotFoundException {
+ return Class.forName(name, false, this.getClass().getClassLoader());
+ }
+
+ /**
* Returns the {@link Class} instance for the named class or primitive type.
*
* @param name the name of a class or primitive type
@@ -396,17 +430,6 @@
}
/**
- * Returns the {@link Class} instance for the named class.
- *
- * @param name the name of a class or primitive type
- * @return Class instance for the given type name
- * @throws ClassNotFoundException if the named type was not found
- */
- private Class getClassFromName(String name) throws ClassNotFoundException {
- return Class.forName(name, false, this.getClass().getClassLoader());
- }
-
- /**
* Obtain the special package-prefixes we use to check for custom serializers
* that would like to live in a package that they cannot. For example,
* "java.util.ArrayList" is in a sealed package, so instead we use this prefix
@@ -416,7 +439,7 @@
* extensible, but it is imaginable, which is why it's implemented this way.
*/
private String[] getPackagePaths() {
- return new String[]{"com.google.gwt.user.client.rpc.core"};
+ return new String[] {"com.google.gwt.user.client.rpc.core"};
}
/**
@@ -545,7 +568,7 @@
}
if (!contentTypeIsOkay) {
throw new ServletException(
- "Content-Type must be 'text/plain' with 'charset=utf-8' (or unspecified charset)");
+ "Content-Type must be 'text/plain' with 'charset=utf-8' (or unspecified charset)");
}
InputStream in = request.getInputStream();
try {
@@ -557,7 +580,7 @@
byteCount = in.read(payload, offset, len);
if (byteCount == -1) {
throw new ServletException("Client did not send " + contentLength
- + " bytes as expected");
+ + " bytes as expected");
}
offset += byteCount;
len -= byteCount;
@@ -584,8 +607,8 @@
response.getWriter().write(GENERIC_FAILURE_MSG);
} catch (IOException e) {
servletContext.log(
- "sendError() failed while sending the previous failure to the client",
- caught);
+ "sendError() failed while sending the previous failure to the client",
+ caught);
}
}
@@ -596,7 +619,7 @@
String contentType = CONTENT_TYPE_TEXT_PLAIN_UTF8;
if (acceptsGzipEncoding(request)
- && shouldCompressResponse(request, response, responsePayload)) {
+ && shouldCompressResponse(request, response, responsePayload)) {
// Compress the reply and adjust headers.
//
ByteArrayOutputStream output = null;
@@ -637,21 +660,4 @@
response.setStatus(HttpServletResponse.SC_OK);
response.getOutputStream().write(reply);
}
-
- static {
- TYPE_NAMES = new HashMap();
- TYPE_NAMES.put("Z", boolean.class);
- TYPE_NAMES.put("B", byte.class);
- TYPE_NAMES.put("C", char.class);
- TYPE_NAMES.put("D", double.class);
- TYPE_NAMES.put("F", float.class);
- TYPE_NAMES.put("I", int.class);
- TYPE_NAMES.put("J", long.class);
- TYPE_NAMES.put("S", short.class);
- }
-
- private final Set knownImplementedInterfaces = new HashSet();
- private final ThreadLocal perThreadRequest = new ThreadLocal();
- private final ThreadLocal perThreadResponse = new ThreadLocal();
- private final ServerSerializableTypeOracle serializableTypeOracle;
}
diff --git a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializableTypeOracleImpl.java b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializableTypeOracleImpl.java
index 5419ab4..88c45d8 100644
--- a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializableTypeOracleImpl.java
+++ b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializableTypeOracleImpl.java
@@ -53,6 +53,31 @@
private static final Map SERIALIZED_PRIMITIVE_TYPE_NAMES = new HashMap();
private static final Set TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES = new HashSet();
+ static {
+
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(boolean.class.getName(), "Z");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(byte.class.getName(), "B");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(char.class.getName(), "C");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(double.class.getName(), "D");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(float.class.getName(), "F");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(int.class.getName(), "I");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(long.class.getName(), "J");
+ SERIALIZED_PRIMITIVE_TYPE_NAMES.put(short.class.getName(), "S");
+
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Boolean.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Byte.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Character.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Double.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Exception.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Float.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Integer.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Long.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Object.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Short.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(String.class);
+ TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Throwable.class);
+ }
+
private static boolean containsCachedSerializerForClass(Class instanceType) {
synchronized (classCustomSerializerCache) {
return classCustomSerializerCache.containsKey(instanceType);
@@ -84,6 +109,8 @@
}
}
+ private String[] packagePaths;
+
public ServerSerializableTypeOracleImpl(String[] packagePaths) {
this.packagePaths = packagePaths;
}
@@ -285,31 +312,4 @@
private String[] getPackagePaths() {
return packagePaths;
}
-
- static {
-
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(boolean.class.getName(), "Z");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(byte.class.getName(), "B");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(char.class.getName(), "C");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(double.class.getName(), "D");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(float.class.getName(), "F");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(int.class.getName(), "I");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(long.class.getName(), "J");
- SERIALIZED_PRIMITIVE_TYPE_NAMES.put(short.class.getName(), "S");
-
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Boolean.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Byte.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Character.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Double.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Exception.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Float.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Integer.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Long.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Object.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Short.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(String.class);
- TYPES_WHOSE_IMPLEMENTATION_IS_EXCLUDED_FROM_SIGNATURES.add(Throwable.class);
- }
-
- private String[] packagePaths;
}
diff --git a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java
index 71673f3..510adc9 100644
--- a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java
+++ b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamReader.java
@@ -33,6 +33,14 @@
public final class ServerSerializationStreamReader extends
AbstractSerializationStreamReader {
+ private ServerSerializableTypeOracle serializableTypeOracle;
+
+ private String[] stringTable;
+
+ private ArrayList tokenList = new ArrayList();
+
+ private int tokenListIndex;
+
public ServerSerializationStreamReader(
ServerSerializableTypeOracle serializableTypeOracle) {
this.serializableTypeOracle = serializableTypeOracle;
@@ -121,8 +129,7 @@
protected Object deserialize(String typeSignature)
throws SerializationException {
Object instance = null;
- SerializedInstanceReference serializedInstRef = serializableTypeOracle
- .decodeSerializedInstanceReference(typeSignature);
+ SerializedInstanceReference serializedInstRef = serializableTypeOracle.decodeSerializedInstanceReference(typeSignature);
try {
Class instanceClass = Class.forName(serializedInstRef.getName(), false,
@@ -135,8 +142,7 @@
validateTypeVersions(instanceClass, serializedInstRef);
- Class customSerializer = serializableTypeOracle
- .hasCustomFieldSerializer(instanceClass);
+ Class customSerializer = serializableTypeOracle.hasCustomFieldSerializer(instanceClass);
instance = instantiate(customSerializer, instanceClass);
@@ -214,8 +220,7 @@
Object instance) throws SerializationException, IllegalAccessException,
NoSuchMethodException, InvocationTargetException, ClassNotFoundException {
Field[] declFields = instanceClass.getDeclaredFields();
- Field[] serializableFields = serializableTypeOracle
- .applyFieldSerializationPolicy(declFields);
+ Field[] serializableFields = serializableTypeOracle.applyFieldSerializationPolicy(declFields);
for (int index = 0; index < serializableFields.length; ++index) {
Field declField = serializableFields[index];
@@ -241,8 +246,9 @@
Class superClass = instanceClass.getSuperclass();
if (superClass != null && serializableTypeOracle.isSerializable(superClass)) {
- deserializeImpl(serializableTypeOracle
- .hasCustomFieldSerializer(superClass), superClass, instance);
+ deserializeImpl(
+ serializableTypeOracle.hasCustomFieldSerializer(superClass),
+ superClass, instance);
}
}
@@ -285,17 +291,11 @@
return;
}
- String serverTypeSignature = serializableTypeOracle
- .getSerializationSignature(instanceClass);
+ String serverTypeSignature = serializableTypeOracle.getSerializationSignature(instanceClass);
if (!clientTypeSignature.equals(serverTypeSignature)) {
throw new SerializationException("Invalid type signature for "
+ instanceClass.getName());
}
}
-
- private ServerSerializableTypeOracle serializableTypeOracle;
- private String[] stringTable;
- private ArrayList tokenList = new ArrayList();
- private int tokenListIndex;
}
diff --git a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamWriter.java b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamWriter.java
index 0abfceb..421140d 100644
--- a/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamWriter.java
+++ b/user/src/com/google/gwt/user/server/rpc/impl/ServerSerializationStreamWriter.java
@@ -57,6 +57,19 @@
*/
private static final char JS_QUOTE_CHAR = '\"';
+ static {
+ JS_CHARS_ESCAPED['\u0000'] = '0';
+ JS_CHARS_ESCAPED['\b'] = 'b';
+ JS_CHARS_ESCAPED['\t'] = 't';
+ JS_CHARS_ESCAPED['\n'] = 'n';
+ // JavaScript Vertical Tab character '\v'
+ JS_CHARS_ESCAPED['\u000b'] = 'v';
+ JS_CHARS_ESCAPED['\f'] = 'f';
+ JS_CHARS_ESCAPED['\r'] = 'r';
+ JS_CHARS_ESCAPED[JS_ESCAPE_CHAR] = JS_ESCAPE_CHAR;
+ JS_CHARS_ESCAPED[JS_QUOTE_CHAR] = JS_QUOTE_CHAR;
+ }
+
/**
* This method takes a string and outputs a JavaScript string literal. The
* data is surrounded with quotes, and any contained characters that need to
@@ -87,6 +100,20 @@
return String.valueOf(output, 0, ++j);
}
+ private int objectCount;
+
+ private IdentityHashMap objectMap = new IdentityHashMap();
+
+ private ServerSerializableTypeOracle serializableTypeOracle;
+
+ private HashMap stringMap = new HashMap();
+
+ private ArrayList stringTable = new ArrayList();
+
+ private ArrayList tokenList = new ArrayList();
+
+ private int tokenListCharCount;
+
public ServerSerializationStreamWriter(
ServerSerializableTypeOracle serializableTypeOracle) {
this.serializableTypeOracle = serializableTypeOracle;
@@ -325,25 +352,4 @@
buffer.append("]");
}
- static {
- JS_CHARS_ESCAPED['\u0000'] = '0';
- JS_CHARS_ESCAPED['\b'] = 'b';
- JS_CHARS_ESCAPED['\t'] = 't';
- JS_CHARS_ESCAPED['\n'] = 'n';
- // JavaScript Vertical Tab character '\v'
- JS_CHARS_ESCAPED['\u000b'] = 'v';
- JS_CHARS_ESCAPED['\f'] = 'f';
- JS_CHARS_ESCAPED['\r'] = 'r';
- JS_CHARS_ESCAPED[JS_ESCAPE_CHAR] = JS_ESCAPE_CHAR;
- JS_CHARS_ESCAPED[JS_QUOTE_CHAR] = JS_QUOTE_CHAR;
- }
-
- private int objectCount;
- private IdentityHashMap objectMap = new IdentityHashMap();
- private ServerSerializableTypeOracle serializableTypeOracle;
- private HashMap stringMap = new HashMap();
- private ArrayList stringTable = new ArrayList();
- private ArrayList tokenList = new ArrayList();
- private int tokenListCharCount;
-
}
diff --git a/user/src/com/google/gwt/user/tools/ApplicationCreator.java b/user/src/com/google/gwt/user/tools/ApplicationCreator.java
index 48935e3..1b5dbdb 100644
--- a/user/src/com/google/gwt/user/tools/ApplicationCreator.java
+++ b/user/src/com/google/gwt/user/tools/ApplicationCreator.java
@@ -30,13 +30,13 @@
/**
* Creates a GWT application.
- *
+ *
*/
public final class ApplicationCreator extends ToolBase {
/**
* Arguments for the application creator.
- *
+ *
*/
protected class ArgHandlerAppClass extends ArgHandlerExtra {
@@ -49,7 +49,7 @@
// Check className for certain properties
if (!arg.matches("[\\w\\$]+(\\.[\\w\\$]+)+")) {
System.err.println("'" + arg
- + "' does not appear to be a valid fully-qualified Java class name");
+ + "' does not appear to be a valid fully-qualified Java class name");
return false;
}
@@ -57,16 +57,16 @@
//
if (arg.indexOf('$') != -1) {
System.err.println("'" + arg
- + "': This version of the tool does not support nested classes");
+ + "': This version of the tool does not support nested classes");
return false;
}
String[] parts = arg.split("\\.");
if (parts.length < 2 || !parts[parts.length - 2].equals("client")) {
System.err.println("'"
- + arg
- + "': Please use 'client' as the final package, as in 'com.example.foo.client.MyApp'.\n"
- + "It isn't technically necessary, but this tool enforces the best practice.");
+ + arg
+ + "': Please use 'client' as the final package, as in 'com.example.foo.client.MyApp'.\n"
+ + "It isn't technically necessary, but this tool enforces the best practice.");
return false;
}
@@ -79,7 +79,7 @@
}
public String[] getTagArgs() {
- return new String[]{"className"};
+ return new String[] {"className"};
}
public boolean isRequired() {
@@ -89,6 +89,12 @@
private static final String PACKAGE_PATH;
+ static {
+ String path = ApplicationCreator.class.getName();
+ path = path.substring(0, path.lastIndexOf('.') + 1);
+ PACKAGE_PATH = path.replace('.', '/');
+ }
+
public static void main(String[] args) {
ApplicationCreator creator = new ApplicationCreator();
if (creator.processArgs(args)) {
@@ -178,10 +184,10 @@
{
// Create the module
File moduleXML = Utility.createNormalFile(basePackageDir, className
- + ".gwt.xml", overwrite, ignore);
+ + ".gwt.xml", overwrite, ignore);
if (moduleXML != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "Module.gwt.xmlsrc");
+ + "Module.gwt.xmlsrc");
Utility.writeTemplateFile(moduleXML, out, replacements);
}
}
@@ -189,10 +195,10 @@
{
// Create a skeleton html file
File publicHTML = Utility.createNormalFile(publicDir,
- className + ".html", overwrite, ignore);
+ className + ".html", overwrite, ignore);
if (publicHTML != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "AppHtml.htmlsrc");
+ + "AppHtml.htmlsrc");
Utility.writeTemplateFile(publicHTML, out, replacements);
}
}
@@ -200,10 +206,10 @@
{
// Create a skeleton Application class
File javaClass = Utility.createNormalFile(clientDir, className + ".java",
- overwrite, ignore);
+ overwrite, ignore);
if (javaClass != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "AppClassTemplate.javasrc");
+ + "AppClassTemplate.javasrc");
Utility.writeTemplateFile(javaClass, out, replacements);
}
}
@@ -212,10 +218,10 @@
// Create an eclipse launch config
replacements.put("@projectName", eclipse);
File launchConfig = Utility.createNormalFile(outDir, className
- + ".launch", overwrite, ignore);
+ + ".launch", overwrite, ignore);
if (launchConfig != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "App.launchsrc");
+ + "App.launchsrc");
Utility.writeTemplateFile(launchConfig, out, replacements);
}
}
@@ -229,10 +235,10 @@
}
File gwtshell = Utility.createNormalFile(outDir, className + "-shell"
- + extension, overwrite, ignore);
+ + extension, overwrite, ignore);
if (gwtshell != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH + "gwtshell"
- + extension + "src");
+ + extension + "src");
Utility.writeTemplateFile(gwtshell, out, replacements);
if (extension.length() == 0) {
Runtime.getRuntime().exec("chmod u+x " + gwtshell.getAbsolutePath());
@@ -240,10 +246,10 @@
}
File gwtcompile = Utility.createNormalFile(outDir, className + "-compile"
- + extension, overwrite, ignore);
+ + extension, overwrite, ignore);
if (gwtcompile != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH + "gwtcompile"
- + extension + "src");
+ + extension + "src");
Utility.writeTemplateFile(gwtcompile, out, replacements);
if (extension.length() == 0) {
Runtime.getRuntime().exec("chmod u+x " + gwtcompile.getAbsolutePath());
@@ -251,6 +257,14 @@
}
}
+ private String eclipse = null;
+
+ private String fullClassName = null;
+
+ private boolean ignore = false;
+ private File outDir;
+ private boolean overwrite = false;
+
protected ApplicationCreator() {
registerHandler(new ArgHandlerEclipse() {
@@ -305,16 +319,4 @@
}
}
- static {
- String path = ApplicationCreator.class.getName();
- path = path.substring(0, path.lastIndexOf('.') + 1);
- PACKAGE_PATH = path.replace('.', '/');
- }
-
- private String eclipse = null;
- private String fullClassName = null;
- private boolean ignore = false;
- private File outDir;
- private boolean overwrite = false;
-
}
diff --git a/user/src/com/google/gwt/user/tools/ProjectCreator.java b/user/src/com/google/gwt/user/tools/ProjectCreator.java
index 52e44c0..d69559d 100644
--- a/user/src/com/google/gwt/user/tools/ProjectCreator.java
+++ b/user/src/com/google/gwt/user/tools/ProjectCreator.java
@@ -35,6 +35,12 @@
private static final String PACKAGE_PATH;
+ static {
+ String path = ProjectCreator.class.getName();
+ path = path.substring(0, path.lastIndexOf('.') + 1);
+ PACKAGE_PATH = path.replace('.', '/');
+ }
+
public static void main(String[] args) {
ProjectCreator creator = new ProjectCreator();
if (creator.processArgs(args)) {
@@ -72,10 +78,10 @@
// Create an ant build file
replacements.put("@projectName", ant);
File antXML = Utility.createNormalFile(outDir, ant + ".ant.xml",
- overwrite, ignore);
+ overwrite, ignore);
if (antXML != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + "project.ant.xmlsrc");
+ + "project.ant.xmlsrc");
Utility.writeTemplateFile(antXML, out, replacements);
}
}
@@ -84,7 +90,7 @@
// Create an eclipse project file
replacements.put("@projectName", eclipse);
File dotProject = Utility.createNormalFile(outDir, ".project", overwrite,
- ignore);
+ ignore);
if (dotProject != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH + ".projectsrc");
Utility.writeTemplateFile(dotProject, out, replacements);
@@ -92,15 +98,23 @@
// Create an eclipse classpath file
File dotClasspath = Utility.createNormalFile(outDir, ".classpath",
- overwrite, ignore);
+ overwrite, ignore);
if (dotClasspath != null) {
String out = Utility.getFileFromClassPath(PACKAGE_PATH
- + ".classpathsrc");
+ + ".classpathsrc");
Utility.writeTemplateFile(dotClasspath, out, replacements);
}
}
}
+ private String ant = null;
+
+ private String eclipse = null;
+
+ private boolean ignore = false;
+ private File outDir = null;
+ private boolean overwrite = false;
+
protected ProjectCreator() {
registerHandler(new ArgHandlerString() {
@@ -114,7 +128,7 @@
}
public String[] getTagArgs() {
- return new String[]{"projectName"};
+ return new String[] {"projectName"};
}
public boolean setString(String str) {
@@ -178,16 +192,4 @@
return false;
}
}
-
- static {
- String path = ProjectCreator.class.getName();
- path = path.substring(0, path.lastIndexOf('.') + 1);
- PACKAGE_PATH = path.replace('.', '/');
- }
-
- private String ant = null;
- private String eclipse = null;
- private boolean ignore = false;
- private File outDir = null;
- private boolean overwrite = false;
}
diff --git a/user/src/com/google/gwt/xml/client/CharacterData.java b/user/src/com/google/gwt/xml/client/CharacterData.java
index 9dc53a3..21a35b0 100644
--- a/user/src/com/google/gwt/xml/client/CharacterData.java
+++ b/user/src/com/google/gwt/xml/client/CharacterData.java
@@ -16,32 +16,74 @@
package com.google.gwt.xml.client;
/*
- * Implementation notes:
- * Opera has a length limit of 32k on any
- * <code>CharacterData</code> nodes.
+ * Implementation notes: Opera has a length limit of 32k on any <code>CharacterData</code>
+ * nodes.
*/
/**
- * This interface describes <code>CharacterData</code> XML nodes. These can be
- * either <code>Text</code>, <code>CDATASection</code> or <code>Comment</code>
- * nodes.
+ * This interface describes <code>CharacterData</code> XML nodes. These can be
+ * either <code>Text</code>, <code>CDATASection</code> or
+ * <code>Comment</code> nodes.
*/
-public interface CharacterData extends Node {
+public interface CharacterData extends Node {
/**
- * This method retrieves the data.
+ * This method appends <code>data</code> to the data in this
+ * <code>CharacterData</code>.
+ *
+ * @param appendedData the data to be appended to the end
+ */
+ public void appendData(String appendedData);
+
+ /**
+ * This method deletes data, starting at <code>offset</code>, and deleting
+ * <code>count</code> characters.
+ *
+ * @param offset how far from the beginning to start deleting
+ * @param count how many characters to delete
+ */
+ public void deleteData(int offset, int count);
+
+ /**
+ * This method retrieves the data.
*
* @return the data of this <code>CharacterData</code>
- */
+ */
public String getData();
/**
- * This method retrieves the length of the data.
+ * This method retrieves the length of the data.
*
* @return the length of the data contained in this <code>CharacterData</code>
- */
+ */
public int getLength();
/**
+ * This method inserts data at the specified offset.
+ *
+ * @param offset how far from the beginning to start inserting
+ * @param insertedData the data to be inserted
+ */
+ public void insertData(int offset, String insertedData);
+
+ /**
+ * This method replaces the substring of data indicated by <code>offset</code>
+ * and <code>count</code> with <code>replacementData</code>.
+ *
+ * @param offset how far from the beginning to start the replacement
+ * @param replacementData the data that will replace the deleted data
+ * @param count how many characters to delete before inserting
+ * <code>replacementData</code>
+ */
+ public void replaceData(int offset, int count, String replacementData);
+
+ /**
+ * This method sets the data to <code>data</code>.
+ *
+ * @param data the new data
+ */
+ public void setData(String data);
+
+ /**
* This method gets a substring of the character data.
*
* @param offset the place to start the substring
@@ -50,46 +92,4 @@
*/
public String substringData(int offset, int count);
- /**
- * This method sets the data to <code>data</code>.
- *
- * @param data the new data
- */
- public void setData(String data);
-
- /**
- * This method appends <code>data</code> to the data in this
- * <code>CharacterData</code>.
- *
- * @param appendedData the data to be appended to the end
- */
- public void appendData(String appendedData);
-
- /**
- * This method inserts data at the specified offset.
- *
- * @param offset how far from the beginning to start inserting
- * @param insertedData the data to be inserted
- */
- public void insertData(int offset, String insertedData);
-
- /**
- * This method deletes data, starting at <code>offset</code>, and deleting
- * <code>count</code> characters.
- *
- * @param offset how far from the beginning to start deleting
- * @param count how many characters to delete
- */
- public void deleteData(int offset, int count);
-
- /**
- * This method replaces the substring of data indicated by
- * <code>offset</code> and <code>count</code> with <code>replacementData</code>.
- *
- * @param offset how far from the beginning to start the replacement
- * @param replacementData the data that will replace the deleted data
- * @param count how many characters to delete before inserting <code>replacementData</code>
- */
- public void replaceData(int offset, int count, String replacementData);
-
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/xml/client/DOMException.java b/user/src/com/google/gwt/xml/client/DOMException.java
index 141e59e..4400153 100644
--- a/user/src/com/google/gwt/xml/client/DOMException.java
+++ b/user/src/com/google/gwt/xml/client/DOMException.java
@@ -16,11 +16,11 @@
package com.google.gwt.xml.client;
/**
- * Thrown when DOM exceptions occur. Two subclasses exist:
- * <code>DOMNodeException</code> and <code>DOMParseException</code> which give
- * more detailed information for DOM manipulation errors and parse errors,
- * respectively. All <code>DOMExceptions</code> thrown in this package
- * will be instances of one of those two classes.
+ * Thrown when DOM exceptions occur. Two subclasses exist:
+ * <code>DOMNodeException</code> and <code>DOMParseException</code> which
+ * give more detailed information for DOM manipulation errors and parse errors,
+ * respectively. All <code>DOMExceptions</code> thrown in this package will be
+ * instances of one of those two classes.
*/
public class DOMException extends RuntimeException {
@@ -30,13 +30,13 @@
public static final short INVALID_STATE_ERR = 11;
public static final short SYNTAX_ERR = 12;
+ protected short code;
+
public DOMException(short code, String message) {
super(message);
this.code = code;
}
- protected short code;
-
/**
* This method gets the code of this <code>DOMException</code>.
*
diff --git a/user/src/com/google/gwt/xml/client/Document.java b/user/src/com/google/gwt/xml/client/Document.java
index 9b9d438..7e34f85 100644
--- a/user/src/com/google/gwt/xml/client/Document.java
+++ b/user/src/com/google/gwt/xml/client/Document.java
@@ -16,100 +16,100 @@
package com.google.gwt.xml.client;
/*
- * Implementation notes:
- * Safari does not support mutable attributes, so no mechanism for creating Attr
- * objects has been supplied. IE does not support any of the xxxNS operations,
- * so they have been omitted as well. IE does not use importNode to copy nodes
- * from one document into another.
+ * Implementation notes: Safari does not support mutable attributes, so no
+ * mechanism for creating Attr objects has been supplied. IE does not support
+ * any of the xxxNS operations, so they have been omitted as well. IE does not
+ * use importNode to copy nodes from one document into another.
*/
/**
- * <code>Document</code> objects represent XML documents. Each
- * <code>Document</code> can contain exactly one <code>Element</code> node, and
- * any number of other node types.
+ * <code>Document</code> objects represent XML documents. Each
+ * <code>Document</code> can contain exactly one <code>Element</code> node,
+ * and any number of other node types.
*/
-public interface Document extends Node {
+public interface Document extends Node {
/**
- * This method retrieves the document element. Each document has at most one
- * <code>Element</code> as its direct child, and this node is returned if it
- * exists. <code>null</code> is returned otherwise.
- *
- * @return the document element of this <code>Document</code>
- */
- public Element getDocumentElement();
-
- /**
- * This method retrieves any descendent elements which have a tag name of
- * <code>tagname</code>.
- *
- * @return the <code>NodeList</code> of elements which has a tag name of
- * <code>tagname</code> and belong to this <code>Document</code>
- */
- public NodeList getElementsByTagName(String tagname);
-
- /**
- * This method retrieves the unique descendent elements which has an id of
- * <code>elementId</code>. Note the attribute which is used as an ID must
- * be supplied in the DTD of the document. It is not sufficient to give the
- * <code>Element</code> to be retrieved an attribute named 'id'.
- *
- * @return the <code>Element</code> which has an id of
- * <code>elementId</code> and belongs to this <code>Document</code>
- */
- public Element getElementById(String elementId);
-
- /**
- * This method creates a new <code>Element</code>.
- *
- * @param tagName the tag name of the new <code>Element</code>
- * @return the newly created <code>Element</code>
- */
- public Element createElement(String tagName);
-
- /**
- * This method creates a new <code>DocumentFragment</code>.
- *
- * @return the newly created <code>DocumentFragment</code>
- */
- public DocumentFragment createDocumentFragment();
-
- /**
- * This method creates a new <code>Text</code>.
- *
- * @param data the data of the new <code>Text</code>
- * @return the newly created <code>Text</code>
- */
- public Text createTextNode(String data);
-
- /**
- * This method creates a new <code>Comment</code>.
- *
- * @param data the data of the new <code>Comment</code>
- * @return the newly created <code>Comment</code>
- */
- public Comment createComment(String data);
-
- /**
- * This method creates a new <code>CDATASection</code>.
+ * This method creates a new <code>CDATASection</code>.
*
* @param data the data of the new <code>CDATASection</code>
* @return the newly created <code>CDATASection</code>
- */
+ */
public CDATASection createCDATASection(String data);
/**
- * This method creates a new <code>ProcessingInstruction</code>.
+ * This method creates a new <code>Comment</code>.
+ *
+ * @param data the data of the new <code>Comment</code>
+ * @return the newly created <code>Comment</code>
+ */
+ public Comment createComment(String data);
+
+ /**
+ * This method creates a new <code>DocumentFragment</code>.
+ *
+ * @return the newly created <code>DocumentFragment</code>
+ */
+ public DocumentFragment createDocumentFragment();
+
+ /**
+ * This method creates a new <code>Element</code>.
+ *
+ * @param tagName the tag name of the new <code>Element</code>
+ * @return the newly created <code>Element</code>
+ */
+ public Element createElement(String tagName);
+
+ /**
+ * This method creates a new <code>ProcessingInstruction</code>.
*
* @param target the target of the new <code>ProcessingInstruction</code>
* @param data the data of the new <code>ProcessingInstruction</code>
* @return the newly created <code>ProcessingInstruction</code>
- */
- public ProcessingInstruction createProcessingInstruction(String target, String data);
+ */
+ public ProcessingInstruction createProcessingInstruction(String target,
+ String data);
/**
- * This method imports a node into the current <code>Document</code>.
+ * This method creates a new <code>Text</code>.
+ *
+ * @param data the data of the new <code>Text</code>
+ * @return the newly created <code>Text</code>
+ */
+ public Text createTextNode(String data);
+
+ /**
+ * This method retrieves the document element. Each document has at most one
+ * <code>Element</code> as its direct child, and this node is returned if it
+ * exists. <code>null</code> is returned otherwise.
+ *
+ * @return the document element of this <code>Document</code>
+ */
+ public Element getDocumentElement();
+
+ /**
+ * This method retrieves the unique descendent elements which has an id of
+ * <code>elementId</code>. Note the attribute which is used as an ID must
+ * be supplied in the DTD of the document. It is not sufficient to give the
+ * <code>Element</code> to be retrieved an attribute named 'id'.
+ *
+ * @return the <code>Element</code> which has an id of
+ * <code>elementId</code> and belongs to this <code>Document</code>
+ */
+ public Element getElementById(String elementId);
+
+ /**
+ * This method retrieves any descendent elements which have a tag name of
+ * <code>tagname</code>.
+ *
+ * @return the <code>NodeList</code> of elements which has a tag name of
+ * <code>tagname</code> and belong to this <code>Document</code>
+ */
+ public NodeList getElementsByTagName(String tagname);
+
+ /**
+ * This method imports a node into the current <code>Document</code>.
*
* @param deep whether to recurse to children
* @return the node <code>Node</code> imported
- */
+ */
public Node importNode(Node importedNode, boolean deep);
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/xml/client/Element.java b/user/src/com/google/gwt/xml/client/Element.java
index aab53db..6809ebc 100644
--- a/user/src/com/google/gwt/xml/client/Element.java
+++ b/user/src/com/google/gwt/xml/client/Element.java
@@ -16,86 +16,83 @@
package com.google.gwt.xml.client;
/*
- * Implementation notes:
- * Internet Explorer does not support any of the namespace methods, so
- * xxxNS is not supported for all xxx.
- * Safari does not support Attribute node modification; use
- * <code>setAttribute</code> instead.
-
+ * Implementation notes: Internet Explorer does not support any of the namespace
+ * methods, so xxxNS is not supported for all xxx. Safari does not support
+ * Attribute node modification; use <code>setAttribute</code> instead.
+ *
*/
/**
- * This interface represents XML DOM elements, which are the basic building
- * block of XML. An example follows:
+ * This interface represents XML DOM elements, which are the basic building
+ * block of XML. An example follows:
+ *
* <pre>
* <sample my_attribute="one">
* Some text<child/> more text
* </sample>
* </pre>
*/
-public interface Element extends Node {
+public interface Element extends Node {
/**
- * This method retrieves the tag name.
- *
- * @return the tag name of this <code>Element</code>
- */
- public String getTagName();
-
- /**
- * This method retrieves the attribute which has a name of
- * <code>name</code>.
+ * This method retrieves the attribute which has a name of <code>name</code>.
*
* @param name the name of the attribute to get the value of
* @return the value of the attribute specified by <code>name</code>
- */
+ */
public String getAttribute(String name);
/**
- * This method sets the attribute specified by <code>name</code>
- * to <code>value</code>.
- *
- * @param name the name of the attribute to set
- * @param value the new value this attribute is to have
- */
- public void setAttribute(String name, String value);
-
- /**
- * This method removes the attribute which has the specified name.
- *
- * @param name the name of the attribute to remove
- */
- public void removeAttribute(String name);
-
- /**
- * This method retrieves the attribute node which has a name of
- * <code>name</code>.
- * This <code>Attr</code> will have the same value as would be gotten with
- * <code>getAttribute</code>.
+ * This method retrieves the attribute node which has a name of
+ * <code>name</code>. This <code>Attr</code> will have the same value as
+ * would be gotten with <code>getAttribute</code>.
*
* @param name the name of the <code>Attr</code> to get
- * @return the attribute node of this <code>Element</code>which has a name
- * of <code>name</code>
- */
+ * @return the attribute node of this <code>Element</code>which has a name
+ * of <code>name</code>
+ */
public Attr getAttributeNode(String name);
/**
- * This method retrieves the elements by tag name which has a name of
- * <code>name</code>.
+ * This method retrieves the elements by tag name which has a name of
+ * <code>name</code>.
*
* @param name the name of the <code>Element</code> to get
- * @return the elements by tag name of this <code>Element</code> which has a
- * name of <code>name</code>
- */
+ * @return the elements by tag name of this <code>Element</code> which has a
+ * name of <code>name</code>
+ */
public NodeList getElementsByTagName(String name);
/**
- * This method determines whether this <code>Element</code> has an
- * attribute with the supplied name.
+ * This method retrieves the tag name.
+ *
+ * @return the tag name of this <code>Element</code>
+ */
+ public String getTagName();
+
+ /**
+ * This method determines whether this <code>Element</code> has an attribute
+ * with the supplied name.
*
* @param name the name of the attribute
* @return <code>true</code> if this <code>Element</code> has an attribute
- * that name.
- */
+ * that name.
+ */
public boolean hasAttribute(String name);
+ /**
+ * This method removes the attribute which has the specified name.
+ *
+ * @param name the name of the attribute to remove
+ */
+ public void removeAttribute(String name);
+
+ /**
+ * This method sets the attribute specified by <code>name</code> to
+ * <code>value</code>.
+ *
+ * @param name the name of the attribute to set
+ * @param value the new value this attribute is to have
+ */
+ public void setAttribute(String name, String value);
+
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/xml/client/NamedNodeMap.java b/user/src/com/google/gwt/xml/client/NamedNodeMap.java
index bb7fc27..d337961 100644
--- a/user/src/com/google/gwt/xml/client/NamedNodeMap.java
+++ b/user/src/com/google/gwt/xml/client/NamedNodeMap.java
@@ -14,20 +14,28 @@
* the License.
*/
package com.google.gwt.xml.client;
+
/*
- * This is an immutable object because Safari
- * does not support mutable attribute maps.
+ * This is an immutable object because Safari does not support mutable attribute
+ * maps.
*/
/**
- * Represents a string-to-node map, used in <code>getAttributes</code>.
+ * Represents a string-to-node map, used in <code>getAttributes</code>.
*/
public interface NamedNodeMap {
/**
+ * Returns the number of items in this <code>NamedNodeMap</code>.
+ *
+ * @return the number of items in this <code>NamedNodeMap</code>
+ */
+ public int getLength();
+
+ /**
* This method gets the item having the given name.
*
* @param name - the name used to look up the item
- * @return the item retrieved
+ * @return the item retrieved
*/
public Node getNamedItem(String name);
@@ -38,11 +46,4 @@
* @return the item retrieved
*/
public Node item(int index);
-
- /**
- * Returns the number of items in this <code>NamedNodeMap</code>.
- *
- * @return the number of items in this <code>NamedNodeMap</code>
- */
- public int getLength();
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/xml/client/Node.java b/user/src/com/google/gwt/xml/client/Node.java
index 1307efc..520bc21 100644
--- a/user/src/com/google/gwt/xml/client/Node.java
+++ b/user/src/com/google/gwt/xml/client/Node.java
@@ -16,229 +16,232 @@
package com.google.gwt.xml.client;
/**
- * This is the base interface for DOM nodes, as obtained from using
- * <code>XMLParser</code> methods. Methods for iterating over and accessing values
- * from nodes are supplied here.
+ * This is the base interface for DOM nodes, as obtained from using
+ * <code>XMLParser</code> methods. Methods for iterating over and accessing
+ * values from nodes are supplied here.
*/
-public interface Node {
+public interface Node {
/**
* The constant 1 denotes DOM nodes of type Element.
- */
+ */
public static final short ELEMENT_NODE = 1;
/**
* The constant 2 denotes DOM nodes of type Attribute.
- */
+ */
public static final short ATTRIBUTE_NODE = 2;
/**
* The constant 3 denotes DOM nodes of type Text.
- */
+ */
public static final short TEXT_NODE = 3;
/**
* The constant 4 denotes DOM nodes of type CdataSection.
- */
+ */
public static final short CDATA_SECTION_NODE = 4;
/**
* The constant 5 denotes DOM nodes of type EntityReference.
- */
+ */
public static final short ENTITY_REFERENCE_NODE = 5;
/**
* The constant 6 denotes DOM nodes of type Entity.
- */
+ */
public static final short ENTITY_NODE = 6;
/**
* The constant 7 denotes DOM nodes of type ProcessingInstruction.
- */
+ */
public static final short PROCESSING_INSTRUCTION_NODE = 7;
/**
* The constant 8 denotes DOM nodes of type Comment.
- */
+ */
public static final short COMMENT_NODE = 8;
/**
* The constant 9 denotes DOM nodes of type Document.
- */
+ */
public static final short DOCUMENT_NODE = 9;
/**
* The constant 10 denotes DOM nodes of type DocumentType.
- */
+ */
public static final short DOCUMENT_TYPE_NODE = 10;
/**
* The constant 11 denotes DOM nodes of type DocumentFragment.
- */
+ */
public static final short DOCUMENT_FRAGMENT_NODE = 11;
/**
* The constant 12 denotes DOM nodes of type Notation.
- */
+ */
public static final short NOTATION_NODE = 12;
/**
- * This method retrieves the name.
- *
- * @return the name of this <code>Node</code>
- */
- public String getNodeName();
-
- /**
- * This method retrieves the value.
- *
- * @return the value of this <code>Node</code>
- */
- public String getNodeValue();
-
- /**
- * This method sets the value to <code>nodeValue</code>.
- *
- * @param nodeValue the new value
- */
- public void setNodeValue(String nodeValue);
-
- /**
- * This method retrieves the type.
- *
- * @return the type of this <code>Node</code>
- */
- public short getNodeType();
-
- /**
- * This method retrieves the parent.
- *
- * @return the parent of this <code>Node</code>
- */
- public Node getParentNode();
-
- /**
- * This method retrieves the child nodes.
- *
- * @return the child nodes of this <code>Node</code>
- */
- public NodeList getChildNodes();
-
- /**
- * This method retrieves the first child.
- *
- * @return the first child of this <code>Node</code>
- */
- public Node getFirstChild();
-
- /**
- * This method retrieves the last child.
- *
- * @return the last child of this <code>Node</code>
- */
- public Node getLastChild();
-
- /**
- * This method retrieves the previous sibling.
- *
- * @return the previous sibling of this <code>Node</code>
- */
- public Node getPreviousSibling();
-
- /**
- * This method retrieves the next sibling.
- *
- * @return the next sibling of this <code>Node</code>
- */
- public Node getNextSibling();
-
- /**
- * This method retrieves the attributes.
- *
- * @return the attributes of this <code>Node</code>
- */
- public NamedNodeMap getAttributes();
-
- /**
- * This method retrieves the owner document.
- *
- * @return the owner document of this <code>Node</code>
- */
- public Document getOwnerDocument();
-
- /**
- * This method inserts before <code>newChild</code>.
- *
- * @param newChild the <code>Node</code> to be added
- * @param refChild the <code>Node</code> which determines the position to insert
- * @return the before <code>Node</code> inserted
- */
- public Node insertBefore(Node newChild, Node refChild);
-
- /**
- * This method replaces the child <code>oldChild</code> with <code>newChild</code>.
- *
- * @param newChild the <code>Node</code> to be added
- * @param oldChild the <code>Node</code> to be removed
- * @return the child <code>Node</code> replaced
- */
- public Node replaceChild(Node newChild, Node oldChild);
-
- /**
- * This method removes child <code>oldChild</code>.
- *
- * @param oldChild the <code>Node</code> to be removed
- * @return the child <code>Node</code> removed
- */
- public Node removeChild(Node oldChild);
-
- /**
- * This method appends child <code>newChild</code>.
+ * This method appends child <code>newChild</code>.
*
* @param newChild the <code>Node</code> to be added
* @return the child <code>Node</code> appended
- */
+ */
public Node appendChild(Node newChild);
/**
- * This method determines whether this <code>Node</code> has any child nodes.
- *
- * @return <code>true</code> if this <code>Node</code> has any child nodes
- */
- public boolean hasChildNodes();
-
- /**
- * This method copies this <code>Node</code>.
+ * This method copies this <code>Node</code>.
*
* @param deep whether to recurse to children
* @return <code>Node</code> cloned
- */
+ */
public Node cloneNode(boolean deep);
/**
+ * This method retrieves the attributes.
+ *
+ * @return the attributes of this <code>Node</code>
+ */
+ public NamedNodeMap getAttributes();
+
+ /**
+ * This method retrieves the child nodes.
+ *
+ * @return the child nodes of this <code>Node</code>
+ */
+ public NodeList getChildNodes();
+
+ /**
+ * This method retrieves the first child.
+ *
+ * @return the first child of this <code>Node</code>
+ */
+ public Node getFirstChild();
+
+ /**
+ * This method retrieves the last child.
+ *
+ * @return the last child of this <code>Node</code>
+ */
+ public Node getLastChild();
+
+ /**
+ * This method retrieves the namespace URI.
+ *
+ * @return the namespace URI of this <code>Node</code>
+ */
+ public String getNamespaceURI();
+
+ /**
+ * This method retrieves the next sibling.
+ *
+ * @return the next sibling of this <code>Node</code>
+ */
+ public Node getNextSibling();
+
+ /**
+ * This method retrieves the name.
+ *
+ * @return the name of this <code>Node</code>
+ */
+ public String getNodeName();
+
+ /**
+ * This method retrieves the type.
+ *
+ * @return the type of this <code>Node</code>
+ */
+ public short getNodeType();
+
+ /**
+ * This method retrieves the value.
+ *
+ * @return the value of this <code>Node</code>
+ */
+ public String getNodeValue();
+
+ /**
+ * This method retrieves the owner document.
+ *
+ * @return the owner document of this <code>Node</code>
+ */
+ public Document getOwnerDocument();
+
+ /**
+ * This method retrieves the parent.
+ *
+ * @return the parent of this <code>Node</code>
+ */
+ public Node getParentNode();
+
+ /**
+ * This method retrieves the prefix.
+ *
+ * @return the prefix of this <code>Node</code>
+ */
+ public String getPrefix();
+
+ /**
+ * This method retrieves the previous sibling.
+ *
+ * @return the previous sibling of this <code>Node</code>
+ */
+ public Node getPreviousSibling();
+
+ /**
+ * This method determines whether this <code>Node</code> has any attributes.
+ *
+ * @return <code>true</code> if this <code>Node</code> has any attributes
+ */
+ public boolean hasAttributes();
+
+ /**
+ * This method determines whether this <code>Node</code> has any child
+ * nodes.
+ *
+ * @return <code>true</code> if this <code>Node</code> has any child nodes
+ */
+ public boolean hasChildNodes();
+
+ /**
+ * This method inserts before <code>newChild</code>.
+ *
+ * @param newChild the <code>Node</code> to be added
+ * @param refChild the <code>Node</code> which determines the position to
+ * insert
+ * @return the before <code>Node</code> inserted
+ */
+ public Node insertBefore(Node newChild, Node refChild);
+
+ /**
* This method may collapse adjacent text nodes into one text node, depending
* on the implementation.
- */
+ */
public void normalize();
/**
- * This method retrieves the namespace URI.
+ * This method removes child <code>oldChild</code>.
*
- * @return the namespace URI of this <code>Node</code>
- */
- public String getNamespaceURI();
+ * @param oldChild the <code>Node</code> to be removed
+ * @return the child <code>Node</code> removed
+ */
+ public Node removeChild(Node oldChild);
/**
- * This method retrieves the prefix.
+ * This method replaces the child <code>oldChild</code> with
+ * <code>newChild</code>.
*
- * @return the prefix of this <code>Node</code>
- */
- public String getPrefix();
+ * @param newChild the <code>Node</code> to be added
+ * @param oldChild the <code>Node</code> to be removed
+ * @return the child <code>Node</code> replaced
+ */
+ public Node replaceChild(Node newChild, Node oldChild);
/**
- * This method determines whether this <code>Node</code> has any attributes.
+ * This method sets the value to <code>nodeValue</code>.
*
- * @return <code>true</code> if this <code>Node</code> has any attributes
- */
- public boolean hasAttributes();
+ * @param nodeValue the new value
+ */
+ public void setNodeValue(String nodeValue);
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/xml/client/ProcessingInstruction.java b/user/src/com/google/gwt/xml/client/ProcessingInstruction.java
index ba3514a..7464a10 100644
--- a/user/src/com/google/gwt/xml/client/ProcessingInstruction.java
+++ b/user/src/com/google/gwt/xml/client/ProcessingInstruction.java
@@ -16,28 +16,29 @@
package com.google.gwt.xml.client;
/**
- * This interface documents the ProcessingInstruction node type.
- * An example is <pre><?target some data?></pre>.
+ * This interface documents the ProcessingInstruction node type. An example is
+ *
+ * <pre><?target some data?></pre>.
*/
-public interface ProcessingInstruction extends Node {
+public interface ProcessingInstruction extends Node {
/**
- * This method retrieves the target.
- *
- * @return the target of this <code>ProcessingInstruction</code>
- */
- public String getTarget();
-
- /**
- * This method retrieves the data.
+ * This method retrieves the data.
*
* @return the data of this <code>ProcessingInstruction</code>
- */
+ */
public String getData();
/**
- * This method sets the data to <code>data</code>.
+ * This method retrieves the target.
+ *
+ * @return the target of this <code>ProcessingInstruction</code>
+ */
+ public String getTarget();
+
+ /**
+ * This method sets the data to <code>data</code>.
*
* @param data the new data
- */
+ */
public void setData(String data);
}
\ No newline at end of file
diff --git a/user/src/com/google/gwt/xml/client/impl/DOMItem.java b/user/src/com/google/gwt/xml/client/impl/DOMItem.java
index eb6dd70..8a63d3e 100644
--- a/user/src/com/google/gwt/xml/client/impl/DOMItem.java
+++ b/user/src/com/google/gwt/xml/client/impl/DOMItem.java
@@ -23,6 +23,8 @@
*/
class DOMItem {
+ private JavaScriptObject jsObject;
+
protected DOMItem(JavaScriptObject jso) {
this.jsObject = jso;
}
@@ -42,7 +44,7 @@
*/
if (o instanceof DOMItem) {
return DOM.compare(castToElement(this.getJsObject()),
- castToElement(((DOMItem) o).getJsObject()));
+ castToElement(((DOMItem) o).getJsObject()));
}
return false;
}
@@ -55,6 +57,4 @@
JavaScriptObject toBeCast) /*-{
return toBeCast;
}-*/;
-
- private JavaScriptObject jsObject;
}
diff --git a/user/src/com/google/gwt/xml/client/impl/DOMNodeException.java b/user/src/com/google/gwt/xml/client/impl/DOMNodeException.java
index 434c175..e4e29ac 100644
--- a/user/src/com/google/gwt/xml/client/impl/DOMNodeException.java
+++ b/user/src/com/google/gwt/xml/client/impl/DOMNodeException.java
@@ -22,6 +22,8 @@
*/
public class DOMNodeException extends DOMException {
+ private DOMItem item;
+
public DOMNodeException() {
super((short) 0, "node exception");
}
@@ -31,7 +33,7 @@
// allow any statements before the super, so
// toString must be evaluated twice
super(code, "Error during DOM manipulation of: "
- + DOMParseException.summarize(item.toString()));
+ + DOMParseException.summarize(item.toString()));
initCause(e);
this.item = item;
}
@@ -40,6 +42,4 @@
return item;
}
- private DOMItem item;
-
}
diff --git a/user/src/com/google/gwt/xml/client/impl/DOMParseException.java b/user/src/com/google/gwt/xml/client/impl/DOMParseException.java
index fdcf373..b54a923 100644
--- a/user/src/com/google/gwt/xml/client/impl/DOMParseException.java
+++ b/user/src/com/google/gwt/xml/client/impl/DOMParseException.java
@@ -23,7 +23,7 @@
public class DOMParseException extends DOMException {
/**
- * Maximum size of error message in summary.
+ * Maximum size of error message in summary.
*/
private static final int MAX_SUMMARY_LENGTH = 128;
@@ -31,19 +31,19 @@
return text.substring(0, Math.min(text.length(), MAX_SUMMARY_LENGTH));
}
+ private String contents;
+
public DOMParseException() {
super(DOMException.SYNTAX_ERR, "Parse error");
}
public DOMParseException(String contents) {
- super(DOMException.SYNTAX_ERR, "Failed to parse: "
- + summarize(contents));
+ super(DOMException.SYNTAX_ERR, "Failed to parse: " + summarize(contents));
this.contents = contents;
}
public DOMParseException(String contents, Throwable e) {
- super(DOMException.SYNTAX_ERR, "Failed to parse: "
- + summarize(contents));
+ super(DOMException.SYNTAX_ERR, "Failed to parse: " + summarize(contents));
initCause(e);
this.contents = contents;
}
@@ -51,6 +51,4 @@
public String getContents() {
return contents;
}
-
- private String contents;
}
diff --git a/user/src/com/google/gwt/xml/client/impl/DocumentImpl.java b/user/src/com/google/gwt/xml/client/impl/DocumentImpl.java
index c9ce7c6..048ac03 100644
--- a/user/src/com/google/gwt/xml/client/impl/DocumentImpl.java
+++ b/user/src/com/google/gwt/xml/client/impl/DocumentImpl.java
@@ -38,40 +38,13 @@
}
/**
- * This function delegates to the native method <code>getDocumentElement</code>
- * in XMLParserImpl.
- */
- public Element getDocumentElement() {
- return (Element) NodeImpl.build(XMLParserImpl.getDocumentElement(this
- .getJsObject()));
- }
-
- /**
- * This function delegates to the native method <code>getElementById</code>
- * in XMLParserImpl.
- */
- public Element getElementById(String elementId) {
- return (Element) NodeImpl.build(XMLParserImpl.getElementById(this
- .getJsObject(), elementId));
- }
-
- /**
- * This function delegates to the native method <code>getElementsByTagName</code>
- * in XMLParserImpl.
- */
- public NodeList getElementsByTagName(String tagName) {
- return new NodeListImpl(XMLParserImpl.getElementsByTagName(this
- .getJsObject(), tagName));
- }
-
- /**
* This function delegates to the native method
* <code>createCDATASection</code> in XMLParserImpl.
*/
public CDATASection createCDATASection(String data) {
try {
return (CDATASection) NodeImpl.build(XMLParserImpl.createCDATASection(
- this.getJsObject(), data));
+ this.getJsObject(), data));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_CHARACTER_ERR, e, this);
}
@@ -83,8 +56,8 @@
*/
public Comment createComment(String data) {
try {
- return (Comment) NodeImpl.build(XMLParserImpl.createComment(this
- .getJsObject(), data));
+ return (Comment) NodeImpl.build(XMLParserImpl.createComment(
+ this.getJsObject(), data));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_CHARACTER_ERR, e, this);
}
@@ -96,8 +69,7 @@
*/
public DocumentFragment createDocumentFragment() {
try {
- return (DocumentFragment) NodeImpl.build(XMLParserImpl
- .createDocumentFragment(this.getJsObject()));
+ return (DocumentFragment) NodeImpl.build(XMLParserImpl.createDocumentFragment(this.getJsObject()));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_CHARACTER_ERR, e, this);
}
@@ -109,8 +81,8 @@
*/
public Element createElement(String tagName) {
try {
- return (Element) NodeImpl.build(XMLParserImpl.createElement(this
- .getJsObject(), tagName));
+ return (Element) NodeImpl.build(XMLParserImpl.createElement(
+ this.getJsObject(), tagName));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_CHARACTER_ERR, e, this);
}
@@ -123,8 +95,8 @@
public ProcessingInstruction createProcessingInstruction(String target,
String data) {
try {
- return (ProcessingInstruction) NodeImpl.build(XMLParserImpl
- .createProcessingInstruction(this.getJsObject(), target, data));
+ return (ProcessingInstruction) NodeImpl.build(XMLParserImpl.createProcessingInstruction(
+ this.getJsObject(), target, data));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_CHARACTER_ERR, e, this);
}
@@ -136,31 +108,57 @@
*/
public Text createTextNode(String data) {
try {
- return (Text) NodeImpl.build(XMLParserImpl.createTextNode(this
- .getJsObject(), data));
+ return (Text) NodeImpl.build(XMLParserImpl.createTextNode(
+ this.getJsObject(), data));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_CHARACTER_ERR, e, this);
}
}
/**
+ * This function delegates to the native method
+ * <code>getDocumentElement</code> in XMLParserImpl.
+ */
+ public Element getDocumentElement() {
+ return (Element) NodeImpl.build(XMLParserImpl.getDocumentElement(this.getJsObject()));
+ }
+
+ /**
+ * This function delegates to the native method <code>getElementById</code>
+ * in XMLParserImpl.
+ */
+ public Element getElementById(String elementId) {
+ return (Element) NodeImpl.build(XMLParserImpl.getElementById(
+ this.getJsObject(), elementId));
+ }
+
+ /**
+ * This function delegates to the native method
+ * <code>getElementsByTagName</code> in XMLParserImpl.
+ */
+ public NodeList getElementsByTagName(String tagName) {
+ return new NodeListImpl(XMLParserImpl.getElementsByTagName(
+ this.getJsObject(), tagName));
+ }
+
+ /**
* This function delegates to the native method <code>importNode</code> in
* XMLParserImpl.
*/
public Node importNode(Node importedNode, boolean deep) {
try {
return NodeImpl.build(XMLParserImpl.importNode(this.getJsObject(),
- ((DOMItem) importedNode).getJsObject(), deep));
+ ((DOMItem) importedNode).getJsObject(), deep));
} catch (JavaScriptException e) {
throw new DOMNodeException(DOMException.INVALID_STATE_ERR, e, this);
}
}
/**
- * This method returns the string representation of this
+ * This method returns the string representation of this
* <code>DocumentImpl</code>.
- * @return the string representation of this
- * <code>DocumentImpl</code>.
+ *
+ * @return the string representation of this <code>DocumentImpl</code>.
* @see java.lang.Object#toString()
*/
public String toString() {
diff --git a/user/src/com/google/gwt/xml/client/impl/ProcessingInstructionImpl.java b/user/src/com/google/gwt/xml/client/impl/ProcessingInstructionImpl.java
index 1852fd9..2970353 100644
--- a/user/src/com/google/gwt/xml/client/impl/ProcessingInstructionImpl.java
+++ b/user/src/com/google/gwt/xml/client/impl/ProcessingInstructionImpl.java
@@ -31,14 +31,6 @@
}
/**
- * This function delegates to the native method <code>getTarget</code> in
- * XMLParserImpl.
- */
- public String getTarget() {
- return XMLParserImpl.getTarget(this.getJsObject());
- }
-
- /**
* This function delegates to the native method <code>getData</code> in
* XMLParserImpl.
*/
@@ -47,6 +39,14 @@
}
/**
+ * This function delegates to the native method <code>getTarget</code> in
+ * XMLParserImpl.
+ */
+ public String getTarget() {
+ return XMLParserImpl.getTarget(this.getJsObject());
+ }
+
+ /**
* This function delegates to the native method <code>setData</code> in
* XMLParserImpl.
*/
diff --git a/user/src/com/google/gwt/xml/client/impl/XMLParserImplStandard.java b/user/src/com/google/gwt/xml/client/impl/XMLParserImplStandard.java
index 2128f04..8c53973 100644
--- a/user/src/com/google/gwt/xml/client/impl/XMLParserImplStandard.java
+++ b/user/src/com/google/gwt/xml/client/impl/XMLParserImplStandard.java
@@ -18,8 +18,8 @@
import com.google.gwt.core.client.JavaScriptObject;
/**
- * This class implements the methods for standard browsers that use the DOMParser
- * model of XML parsing.
+ * This class implements the methods for standard browsers that use the
+ * DOMParser model of XML parsing.
*/
class XMLParserImplStandard extends XMLParserImpl {
@@ -27,6 +27,8 @@
return new DOMParser();
}-*/;
+ protected final JavaScriptObject domParser = createDOMParser();
+
protected native JavaScriptObject createDocumentImpl() /*-{
return document.implementation.createDocument("", "", null);
}-*/;
@@ -35,12 +37,12 @@
JavaScriptObject document, String id) /*-{
return document.getElementById(id);
}-*/;
-
- protected native JavaScriptObject getElementsByTagNameImpl(JavaScriptObject o,
- String tagName) /*-{
+
+ protected native JavaScriptObject getElementsByTagNameImpl(
+ JavaScriptObject o, String tagName) /*-{
return o.getElementsByTagNameNS("*",tagName);
}-*/;
-
+
protected String getPrefixImpl(JavaScriptObject jsObject) {
String fullName = XMLParserImpl.getNodeName(jsObject);
if (fullName != null && fullName.indexOf(":") != -1) {
@@ -54,7 +56,7 @@
var out = jsObject.importNode(importedNode, deep);
return (out == null) ? null : out;
}-*/;
-
+
protected native JavaScriptObject parseImpl(String contents) /*-{
var domParser = this.@com.google.gwt.xml.client.impl.XMLParserImplStandard::domParser;
var result = domParser.parseFromString(contents,"text/xml");
@@ -66,7 +68,5 @@
}
return result;
}-*/;
-
- protected final JavaScriptObject domParser = createDOMParser();
}