You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xalan.apache.org by ga...@locus.apache.org on 2000/11/28 01:44:39 UTC
cvs commit: xml-xalan/java/src/org/apache/xpath XPathContext.java
garyp 00/11/27 16:44:37
Modified: java/src/org/apache/xpath XPathContext.java
Log:
If no ErrorListener is set, obtain one from the owner, if available. Otherwise, create a default one.
Revision Changes Path
1.15 +42 -3 xml-xalan/java/src/org/apache/xpath/XPathContext.java
Index: XPathContext.java
===================================================================
RCS file: /home/cvs/xml-xalan/java/src/org/apache/xpath/XPathContext.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- XPathContext.java 2000/11/23 04:58:56 1.14
+++ XPathContext.java 2000/11/28 00:44:35 1.15
@@ -62,6 +62,8 @@
import java.util.Stack;
+import java.lang.reflect.Method;
+
// Xalan imports
import org.apache.xml.utils.IntStack;
import org.apache.xml.utils.NSInfo;
@@ -121,6 +123,10 @@
public XPathContext(Object owner)
{
m_owner = owner;
+ try {
+ m_ownerGetErrorListener = m_owner.getClass().getMethod("getErrorListener", new Class[] {});
+ }
+ catch (NoSuchMethodException nsme) {}
}
/**
@@ -162,9 +168,16 @@
return m_saxLocation;
}
- /** NEEDSDOC Field m_owner */
+ /** The owner context of this XPathContext. In the case of XSLT, this will be a
+ * Transformer object.
+ */
private Object m_owner;
+ /** The owner context of this XPathContext. In the case of XSLT, this will be a
+ * Transformer object.
+ */
+ private Method m_ownerGetErrorListener;
+
/**
* Get the "owner" context of this context, which should be,
* in the case of XSLT, the Transformer object. This is needed
@@ -316,6 +329,11 @@
/** The ErrorListener where errors and warnings are to be reported. */
private ErrorListener m_errorListener;
+ /** A default ErrorListener in case our m_errorListener was not specified and our
+ * owner either does not have an ErrorListener or has a null one.
+ */
+ private ErrorListener m_defaultErrorListener;
+
/**
* Get the ErrorListener where errors and warnings are to be reported.
*
@@ -323,7 +341,26 @@
*/
public final ErrorListener getErrorListener()
{
- return m_errorListener;
+
+ if (null != m_errorListener)
+ return m_errorListener;
+
+ ErrorListener retval = null;
+
+ try {
+ if (null != m_ownerGetErrorListener)
+ retval = (ErrorListener) m_ownerGetErrorListener.invoke(m_owner, new Object[] {});
+ }
+ catch (Exception e) {}
+
+ if (null == retval)
+ {
+ if (null == m_defaultErrorListener)
+ m_defaultErrorListener = new org.apache.xml.utils.DefaultErrorHandler();
+ retval = m_defaultErrorListener;
+ }
+
+ return retval;
}
/**
@@ -331,8 +368,10 @@
*
* @param listener A non-null ErrorListener reference.
*/
- public void setErrorListener(ErrorListener listener)
+ public void setErrorListener(ErrorListener listener) throws IllegalArgumentException
{
+ if (listener == null)
+ throw new IllegalArgumentException("Null error handler");
m_errorListener = listener;
}