From a442ef030837fa1907a7292d938fad6f9169f848 Mon Sep 17 00:00:00 2001 From: "nboyd%atg.com" Date: Wed, 14 Jan 2009 13:31:23 +0000 Subject: [PATCH] Add ability for embeddings to set options on the XML implementation. git-svn-id: svn://10.0.0.236/trunk@255805 18797224-902f-48f8-a5cc-f745e15eee43 --- .../org/mozilla/javascript/xml/XMLLib.java | 40 ++++++++++++++++++ .../rhino/testsrc/doctests/xmlOptions.doctest | 15 +++++++ .../javascript/xmlimpl/XMLLibImpl.java | 41 +++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100755 mozilla/js/rhino/testsrc/doctests/xmlOptions.doctest diff --git a/mozilla/js/rhino/src/org/mozilla/javascript/xml/XMLLib.java b/mozilla/js/rhino/src/org/mozilla/javascript/xml/XMLLib.java index da92dde2cb2..343c938c9f0 100644 --- a/mozilla/js/rhino/src/org/mozilla/javascript/xml/XMLLib.java +++ b/mozilla/js/rhino/src/org/mozilla/javascript/xml/XMLLib.java @@ -130,4 +130,44 @@ public abstract class XMLLib * Construct namespace for default xml statement. */ public abstract Object toDefaultXmlNamespace(Context cx, Object uriValue); + + public void setIgnoreComments(boolean b) { + throw new UnsupportedOperationException(); + } + + public void setIgnoreWhitespace(boolean b) { + throw new UnsupportedOperationException(); + } + + public void setIgnoreProcessingInstructions(boolean b) { + throw new UnsupportedOperationException(); + } + + public void setPrettyPrinting(boolean b) { + throw new UnsupportedOperationException(); + } + + public void setPrettyIndent(int i) { + throw new UnsupportedOperationException(); + } + + public boolean isIgnoreComments() { + throw new UnsupportedOperationException(); + } + + public boolean isIgnoreProcessingInstructions() { + throw new UnsupportedOperationException(); + } + + public boolean isIgnoreWhitespace() { + throw new UnsupportedOperationException(); + } + + public boolean isPrettyPrinting() { + throw new UnsupportedOperationException(); + } + + public int getPrettyIndent() { + throw new UnsupportedOperationException(); + } } diff --git a/mozilla/js/rhino/testsrc/doctests/xmlOptions.doctest b/mozilla/js/rhino/testsrc/doctests/xmlOptions.doctest new file mode 100755 index 00000000000..f9b1bffabf1 --- /dev/null +++ b/mozilla/js/rhino/testsrc/doctests/xmlOptions.doctest @@ -0,0 +1,15 @@ +js> var x = 1; +js> x + + + 1 + + +js> var xmlLib = org.mozilla.javascript.xml.XMLLib.extractFromScope(this); +js> xmlLib.isPrettyPrinting(); +true +js> xmlLib.setPrettyPrinting(false); +js> xmlLib.isPrettyPrinting(); +false +js> x +1 \ No newline at end of file diff --git a/mozilla/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLLibImpl.java b/mozilla/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLLibImpl.java index 1713b01049e..23a70bdb58d 100644 --- a/mozilla/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLLibImpl.java +++ b/mozilla/js/rhino/xmlimplsrc/org/mozilla/javascript/xmlimpl/XMLLibImpl.java @@ -72,6 +72,47 @@ public final class XMLLibImpl extends XMLLib implements Serializable { lib.exportToScope(sealed); } } + + public void setIgnoreComments(boolean b) { + options.setIgnoreComments(b); + } + + public void setIgnoreWhitespace(boolean b) { + options.setIgnoreWhitespace(b); + } + + public void setIgnoreProcessingInstructions(boolean b) { + options.setIgnoreProcessingInstructions(b); + } + + public void setPrettyPrinting(boolean b) { + options.setPrettyPrinting(b); + } + + public void setPrettyIndent(int i) { + options.setPrettyIndent(i); + } + + public boolean isIgnoreComments() { + return options.isIgnoreComments(); + } + + public boolean isIgnoreProcessingInstructions() { + return options.isIgnoreProcessingInstructions(); + } + + public boolean isIgnoreWhitespace() { + return options.isIgnoreWhitespace(); + } + + public boolean isPrettyPrinting() { + return options.isPrettyPrinting(); + } + + public int getPrettyIndent() { + return options.getPrettyIndent(); + } + private Scriptable globalScope;