You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pivot.apache.org by rw...@apache.org on 2017/01/17 17:52:39 UTC
svn commit: r1779224 - in /pivot/trunk: ./
core/src/org/apache/pivot/beans/BXMLSerializer.java
Author: rwhitcomb
Date: Tue Jan 17 17:52:38 2017
New Revision: 1779224
URL: http://svn.apache.org/viewvc?rev=1779224&view=rev
Log:
PIVOT-965: Add "defaultLanguage" attribute to BXMLSerializer so that custom
scripting language (for instance, "rhino" for compatibility) can be made the
default for scripts.
Note: this change is not quite the same as the suggested patch in two ways:
1. This code accepts "null" for the default language, which will set it back
to our installation default (namely "javascript").
2. This installation default cannot be "rhino" as suggested or all the scripts
break in Java 1.8. Not quite ready for that yet. But applications that
really need "rhino" as default should be able to do that with a custom
subclass that always sets the default language as needed.
This is a merge of revision 1779093 from branches/2.0.x to trunk.
Modified:
pivot/trunk/ (props changed)
pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
Propchange: pivot/trunk/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jan 17 17:52:38 2017
@@ -1 +1 @@
-/pivot/branches/2.0.x:1388236,1388681,1391496,1392533,1446780,1447977,1448356,1458918,1459950,1460982,1461332,1479613,1505062,1523284,1538840,1542170,1551768,1551992,1580958,1602230,1602233,1692157,1703029,1703276,1703292,1756437
+/pivot/branches/2.0.x:1388236,1388681,1391496,1392533,1446780,1447977,1448356,1458918,1459950,1460982,1461332,1479613,1505062,1523284,1538840,1542170,1551768,1551992,1580958,1602230,1602233,1692157,1703029,1703276,1703292,1756437,1779093
Modified: pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java
URL: http://svn.apache.org/viewvc/pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java?rev=1779224&r1=1779223&r2=1779224&view=diff
==============================================================================
--- pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java (original)
+++ pivot/trunk/core/src/org/apache/pivot/beans/BXMLSerializer.java Tue Jan 17 17:52:38 2017
@@ -106,19 +106,19 @@ public class BXMLSerializer implements S
}
/* private static void printBindings(java.util.Map<String,Object> bindings) {
- System.out.format("=== Bindings %1$s ===%n", bindings);
- for (String key : bindings.keySet()) {
- Object value = bindings.get(key);
- System.out.format("key: %1$s, value: %2$s [%3$s]%n", key, value, Integer.toHexString(System.identityHashCode(value)));
- if (key.equals(NASHORN_GLOBAL)) {
- Bindings globalBindings = (Bindings)value;
- for (String globalKey : globalBindings.keySet()) {
- Object globalValue = globalBindings.get(globalKey);
- System.out.format(" global key: %1$s, value: %2$s [%3$s]%n", globalKey, globalValue, Integer.toHexString(System.identityHashCode(globalValue)));
- }
- }
- }
- System.out.println("=====================");
+ System.out.format("=== Bindings %1$s ===%n", bindings);
+ for (String key : bindings.keySet()) {
+ Object value = bindings.get(key);
+ System.out.format("key: %1$s, value: %2$s [%3$s]%n", key, value, Integer.toHexString(System.identityHashCode(value)));
+ if (key.equals(NASHORN_GLOBAL)) {
+ Bindings globalBindings = (Bindings)value;
+ for (String globalKey : globalBindings.keySet()) {
+ Object globalValue = globalBindings.get(globalKey);
+ System.out.format(" global key: %1$s, value: %2$s [%3$s]%n", globalKey, globalValue, Integer.toHexString(System.identityHashCode(globalValue)));
+ }
+ }
+ }
+ System.out.println("=====================");
}
*/
private class AttributeInvocationHandler implements InvocationHandler {
@@ -253,6 +253,7 @@ public class BXMLSerializer implements S
private Element element = null;
private Object root = null;
+ private String defaultLanguage = DEFAULT_LANGUAGE;
private String language = null;
private int nextID = 0;
@@ -740,7 +741,7 @@ public class BXMLSerializer implements S
// Initialize the page language
if (language == null) {
- language = DEFAULT_LANGUAGE;
+ language = getDefaultLanguage();
}
// Get element properties
@@ -1855,4 +1856,24 @@ public class BXMLSerializer implements S
throw new SerializationException(exception);
}
}
+
+ /**
+ * Set the default script language to use for all scripts.
+ *
+ * @param defaultLanguage Name of the new default script language,
+ * or {@code null} to set the default, default value.
+ * @see #DEFAULT_LANGUAGE
+ */
+ protected void setDefaultLanguage(String defaultLanguage) {
+ if (defaultLanguage == null) {
+ this.defaultLanguage = DEFAULT_LANGUAGE;
+ } else {
+ this.defaultLanguage = defaultLanguage;
+ }
+ }
+
+ protected String getDefaultLanguage() {
+ return this.defaultLanguage;
+ }
+
}