You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commons-cvs@xml.apache.org by mr...@apache.org on 2005/06/15 02:51:32 UTC

cvs commit: xml-commons/java/external/src/org/xml/sax/helpers NewInstance.java

mrglavas    2005/06/14 17:51:32

  Modified:    java/external/src/javax/xml/transform
                        TransformerException.java
               java/external/src/javax/xml/transform/stream
                        StreamResult.java
               java/external/src/org/xml/sax/helpers NewInstance.java
  Log:
  Suppress varargs call warning emitted from Java 5.0 compiler.
  
  Revision  Changes    Path
  1.7       +376 -376  xml-commons/java/external/src/javax/xml/transform/TransformerException.java
  
  Index: TransformerException.java
  ===================================================================
  RCS file: /home/cvs/xml-commons/java/external/src/javax/xml/transform/TransformerException.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TransformerException.java	14 Jun 2005 19:13:40 -0000	1.6
  +++ TransformerException.java	15 Jun 2005 00:51:32 -0000	1.7
  @@ -1,376 +1,376 @@
  -/*
  - * Copyright 2003-2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *     http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -// $Id$
  -
  -package javax.xml.transform;
  -
  -import java.lang.reflect.Method;
  -import java.lang.reflect.InvocationTargetException;
  -
  -/**
  - * This class specifies an exceptional condition that occured
  - * during the transformation process.
  - */
  -public class TransformerException extends Exception {
  -
  -    /** Field locator specifies where the error occured */
  -    SourceLocator locator;
  -
  -    /**
  -     * Method getLocator retrieves an instance of a SourceLocator
  -     * object that specifies where an error occured.
  -     *
  -     * @return A SourceLocator object, or null if none was specified.
  -     */
  -    public SourceLocator getLocator() {
  -        return locator;
  -    }
  -
  -    /**
  -     * Method setLocator sets an instance of a SourceLocator
  -     * object that specifies where an error occured.
  -     *
  -     * @param location A SourceLocator object, or null to clear the location.
  -     */
  -    public void setLocator(SourceLocator location) {
  -        locator = location;
  -    }
  -
  -    /** Field containedException specifies a wrapped exception.  May be null. */
  -    Throwable containedException;
  -
  -    /**
  -     * This method retrieves an exception that this exception wraps.
  -     *
  -     * @return An Throwable object, or null.
  -     * @see #getCause
  -     */
  -    public Throwable getException() {
  -        return containedException;
  -    }
  -
  -    /**
  -     * Returns the cause of this throwable or <code>null</code> if the
  -     * cause is nonexistent or unknown.  (The cause is the throwable that
  -     * caused this throwable to get thrown.)
  -     */
  -    public Throwable getCause() {
  -
  -        return ((containedException == this)
  -                ? null
  -                : containedException);
  -    }
  -
  -    /**
  -     * Initializes the <i>cause</i> of this throwable to the specified value.
  -     * (The cause is the throwable that caused this throwable to get thrown.)
  -     *
  -     * <p>This method can be called at most once.  It is generally called from
  -     * within the constructor, or immediately after creating the
  -     * throwable.  If this throwable was created
  -     * with {@link #TransformerException(Throwable)} or
  -     * {@link #TransformerException(String,Throwable)}, this method cannot be called
  -     * even once.
  -     *
  -     * @param  cause the cause (which is saved for later retrieval by the
  -     *         {@link #getCause()} method).  (A <tt>null</tt> value is
  -     *         permitted, and indicates that the cause is nonexistent or
  -     *         unknown.)
  -     * @return  a reference to this <code>Throwable</code> instance.
  -     * @throws IllegalArgumentException if <code>cause</code> is this
  -     *         throwable.  (A throwable cannot
  -     *         be its own cause.)
  -     * @throws IllegalStateException if this throwable was
  -     *         created with {@link #TransformerException(Throwable)} or
  -     *         {@link #TransformerException(String,Throwable)}, or this method has already
  -     *         been called on this throwable.
  -     */
  -    public synchronized Throwable initCause(Throwable cause) {
  -
  -        if (this.containedException != null) {
  -            throw new IllegalStateException("Can't overwrite cause");
  -        }
  -
  -        if (cause == this) {
  -            throw new IllegalArgumentException(
  -                "Self-causation not permitted");
  -        }
  -
  -        this.containedException = cause;
  -
  -        return this;
  -    }
  -
  -    /**
  -     * Create a new TransformerException.
  -     *
  -     * @param message The error or warning message.
  -     */
  -    public TransformerException(String message) {
  -
  -        super(message);
  -
  -        this.containedException = null;
  -        this.locator            = null;
  -    }
  -
  -    /**
  -     * Create a new TransformerException wrapping an existing exception.
  -     *
  -     * @param e The exception to be wrapped.
  -     */
  -    public TransformerException(Throwable e) {
  -
  -        super(e.toString());
  -
  -        this.containedException = e;
  -        this.locator            = null;
  -    }
  -
  -    /**
  -     * Wrap an existing exception in a TransformerException.
  -     *
  -     * <p>This is used for throwing processor exceptions before
  -     * the processing has started.</p>
  -     *
  -     * @param message The error or warning message, or null to
  -     *                use the message from the embedded exception.
  -     * @param e Any exception
  -     */
  -    public TransformerException(String message, Throwable e) {
  -
  -        super(((message == null) || (message.length() == 0))
  -              ? e.toString()
  -              : message);
  -
  -        this.containedException = e;
  -        this.locator            = null;
  -    }
  -
  -    /**
  -     * Create a new TransformerException from a message and a Locator.
  -     *
  -     * <p>This constructor is especially useful when an application is
  -     * creating its own exception from within a DocumentHandler
  -     * callback.</p>
  -     *
  -     * @param message The error or warning message.
  -     * @param locator The locator object for the error or warning.
  -     */
  -    public TransformerException(String message, SourceLocator locator) {
  -
  -        super(message);
  -
  -        this.containedException = null;
  -        this.locator            = locator;
  -    }
  -
  -    /**
  -     * Wrap an existing exception in a TransformerException.
  -     *
  -     * @param message The error or warning message, or null to
  -     *                use the message from the embedded exception.
  -     * @param locator The locator object for the error or warning.
  -     * @param e Any exception
  -     */
  -    public TransformerException(String message, SourceLocator locator,
  -                                Throwable e) {
  -
  -        super(message);
  -
  -        this.containedException = e;
  -        this.locator            = locator;
  -    }
  -
  -    /**
  -     * Get the error message with location information
  -     * appended.
  -     *
  -     * @return A <code>String</code> representing the error message with
  -     *         location information appended.
  -     */
  -    public String getMessageAndLocation() {
  -
  -        StringBuffer sbuffer = new StringBuffer();
  -        String       message = super.getMessage();
  -
  -        if (null != message) {
  -            sbuffer.append(message);
  -        }
  -
  -        if (null != locator) {
  -            String systemID = locator.getSystemId();
  -            int    line     = locator.getLineNumber();
  -            int    column   = locator.getColumnNumber();
  -
  -            if (null != systemID) {
  -                sbuffer.append("; SystemID: ");
  -                sbuffer.append(systemID);
  -            }
  -
  -            if (0 != line) {
  -                sbuffer.append("; Line#: ");
  -                sbuffer.append(line);
  -            }
  -
  -            if (0 != column) {
  -                sbuffer.append("; Column#: ");
  -                sbuffer.append(column);
  -            }
  -        }
  -
  -        return sbuffer.toString();
  -    }
  -
  -    /**
  -     * Get the location information as a string.
  -     *
  -     * @return A string with location info, or null
  -     * if there is no location information.
  -     */
  -    public String getLocationAsString() {
  -
  -        if (null != locator) {
  -            StringBuffer sbuffer  = new StringBuffer();
  -            String       systemID = locator.getSystemId();
  -            int          line     = locator.getLineNumber();
  -            int          column   = locator.getColumnNumber();
  -
  -            if (null != systemID) {
  -                sbuffer.append("; SystemID: ");
  -                sbuffer.append(systemID);
  -            }
  -
  -            if (0 != line) {
  -                sbuffer.append("; Line#: ");
  -                sbuffer.append(line);
  -            }
  -
  -            if (0 != column) {
  -                sbuffer.append("; Column#: ");
  -                sbuffer.append(column);
  -            }
  -
  -            return sbuffer.toString();
  -        } else {
  -            return null;
  -        }
  -    }
  -
  -    /**
  -     * Print the the trace of methods from where the error
  -     * originated.  This will trace all nested exception
  -     * objects, as well as this object.
  -     */
  -    public void printStackTrace() {
  -        printStackTrace(new java.io.PrintWriter(System.err, true));
  -    }
  -
  -    /**
  -     * Print the the trace of methods from where the error
  -     * originated.  This will trace all nested exception
  -     * objects, as well as this object.
  -     * @param s The stream where the dump will be sent to.
  -     */
  -    public void printStackTrace(java.io.PrintStream s) {
  -        printStackTrace(new java.io.PrintWriter(s));
  -    }
  -
  -    /**
  -     * Print the the trace of methods from where the error
  -     * originated.  This will trace all nested exception
  -     * objects, as well as this object.
  -     * @param s The writer where the dump will be sent to.
  -     */
  -    public void printStackTrace(java.io.PrintWriter s) {
  -
  -        if (s == null) {
  -            s = new java.io.PrintWriter(System.err, true);
  -        }
  -
  -        try {
  -            String locInfo = getLocationAsString();
  -
  -            if (null != locInfo) {
  -                s.println(locInfo);
  -            }
  -
  -            super.printStackTrace(s);
  -        } catch (Throwable e) {}
  -
  -        boolean isJdk14OrHigher = false;
  -        try {
  -        	Throwable.class.getMethod("getCause",null);
  -        	isJdk14OrHigher = true;
  -        } catch (NoSuchMethodException nsme) {
  -        	// do nothing
  -        }
  -
  -        // The printStackTrace method of the Throwable class in jdk 1.4 
  -        // and higher will include the cause when printing the backtrace.
  -        // The following code is only required when using jdk 1.3 or lower                 
  -        if (!isJdk14OrHigher) {
  -            Throwable exception = getException();
  -
  -            for (int i = 0; (i < 10) && (null != exception); i++) {
  -                s.println("---------");
  -
  -                try {
  -                    if (exception instanceof TransformerException) {
  -                        String locInfo =
  -                            ((TransformerException) exception)
  -                            .getLocationAsString();
  -
  -                        if (null != locInfo) {
  -                            s.println(locInfo);
  -                        }
  -                    }
  -
  -                    exception.printStackTrace(s);
  -                } catch (Throwable e) {
  -                    s.println("Could not print stack trace...");
  -                }
  -
  -                try {
  -                    Method meth =
  -                        ((Object) exception).getClass().getMethod("getException",
  -                        null);
  -
  -                    if (null != meth) {
  -                        Throwable prev = exception;
  -
  -                        exception = (Throwable) meth.invoke(exception, null);
  -
  -                        if (prev == exception) {
  -                            break;
  -                        }
  -                    } else {
  -                        exception = null;
  -                    }
  -                } catch (InvocationTargetException ite) {
  -                    exception = null;
  -                } catch (IllegalAccessException iae) {
  -                    exception = null;
  -                } catch (NoSuchMethodException nsme) {
  -                    exception = null;
  -                }
  -            }
  -        }
  -        // insure output is written
  -        s.flush();
  -    }
  -}
  +/*
  + * Copyright 2003-2004 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +// $Id$
  +
  +package javax.xml.transform;
  +
  +import java.lang.reflect.Method;
  +import java.lang.reflect.InvocationTargetException;
  +
  +/**
  + * This class specifies an exceptional condition that occured
  + * during the transformation process.
  + */
  +public class TransformerException extends Exception {
  +
  +    /** Field locator specifies where the error occured */
  +    SourceLocator locator;
  +
  +    /**
  +     * Method getLocator retrieves an instance of a SourceLocator
  +     * object that specifies where an error occured.
  +     *
  +     * @return A SourceLocator object, or null if none was specified.
  +     */
  +    public SourceLocator getLocator() {
  +        return locator;
  +    }
  +
  +    /**
  +     * Method setLocator sets an instance of a SourceLocator
  +     * object that specifies where an error occured.
  +     *
  +     * @param location A SourceLocator object, or null to clear the location.
  +     */
  +    public void setLocator(SourceLocator location) {
  +        locator = location;
  +    }
  +
  +    /** Field containedException specifies a wrapped exception.  May be null. */
  +    Throwable containedException;
  +
  +    /**
  +     * This method retrieves an exception that this exception wraps.
  +     *
  +     * @return An Throwable object, or null.
  +     * @see #getCause
  +     */
  +    public Throwable getException() {
  +        return containedException;
  +    }
  +
  +    /**
  +     * Returns the cause of this throwable or <code>null</code> if the
  +     * cause is nonexistent or unknown.  (The cause is the throwable that
  +     * caused this throwable to get thrown.)
  +     */
  +    public Throwable getCause() {
  +
  +        return ((containedException == this)
  +                ? null
  +                : containedException);
  +    }
  +
  +    /**
  +     * Initializes the <i>cause</i> of this throwable to the specified value.
  +     * (The cause is the throwable that caused this throwable to get thrown.)
  +     *
  +     * <p>This method can be called at most once.  It is generally called from
  +     * within the constructor, or immediately after creating the
  +     * throwable.  If this throwable was created
  +     * with {@link #TransformerException(Throwable)} or
  +     * {@link #TransformerException(String,Throwable)}, this method cannot be called
  +     * even once.
  +     *
  +     * @param  cause the cause (which is saved for later retrieval by the
  +     *         {@link #getCause()} method).  (A <tt>null</tt> value is
  +     *         permitted, and indicates that the cause is nonexistent or
  +     *         unknown.)
  +     * @return  a reference to this <code>Throwable</code> instance.
  +     * @throws IllegalArgumentException if <code>cause</code> is this
  +     *         throwable.  (A throwable cannot
  +     *         be its own cause.)
  +     * @throws IllegalStateException if this throwable was
  +     *         created with {@link #TransformerException(Throwable)} or
  +     *         {@link #TransformerException(String,Throwable)}, or this method has already
  +     *         been called on this throwable.
  +     */
  +    public synchronized Throwable initCause(Throwable cause) {
  +
  +        if (this.containedException != null) {
  +            throw new IllegalStateException("Can't overwrite cause");
  +        }
  +
  +        if (cause == this) {
  +            throw new IllegalArgumentException(
  +                "Self-causation not permitted");
  +        }
  +
  +        this.containedException = cause;
  +
  +        return this;
  +    }
  +
  +    /**
  +     * Create a new TransformerException.
  +     *
  +     * @param message The error or warning message.
  +     */
  +    public TransformerException(String message) {
  +
  +        super(message);
  +
  +        this.containedException = null;
  +        this.locator            = null;
  +    }
  +
  +    /**
  +     * Create a new TransformerException wrapping an existing exception.
  +     *
  +     * @param e The exception to be wrapped.
  +     */
  +    public TransformerException(Throwable e) {
  +
  +        super(e.toString());
  +
  +        this.containedException = e;
  +        this.locator            = null;
  +    }
  +
  +    /**
  +     * Wrap an existing exception in a TransformerException.
  +     *
  +     * <p>This is used for throwing processor exceptions before
  +     * the processing has started.</p>
  +     *
  +     * @param message The error or warning message, or null to
  +     *                use the message from the embedded exception.
  +     * @param e Any exception
  +     */
  +    public TransformerException(String message, Throwable e) {
  +
  +        super(((message == null) || (message.length() == 0))
  +              ? e.toString()
  +              : message);
  +
  +        this.containedException = e;
  +        this.locator            = null;
  +    }
  +
  +    /**
  +     * Create a new TransformerException from a message and a Locator.
  +     *
  +     * <p>This constructor is especially useful when an application is
  +     * creating its own exception from within a DocumentHandler
  +     * callback.</p>
  +     *
  +     * @param message The error or warning message.
  +     * @param locator The locator object for the error or warning.
  +     */
  +    public TransformerException(String message, SourceLocator locator) {
  +
  +        super(message);
  +
  +        this.containedException = null;
  +        this.locator            = locator;
  +    }
  +
  +    /**
  +     * Wrap an existing exception in a TransformerException.
  +     *
  +     * @param message The error or warning message, or null to
  +     *                use the message from the embedded exception.
  +     * @param locator The locator object for the error or warning.
  +     * @param e Any exception
  +     */
  +    public TransformerException(String message, SourceLocator locator,
  +                                Throwable e) {
  +
  +        super(message);
  +
  +        this.containedException = e;
  +        this.locator            = locator;
  +    }
  +
  +    /**
  +     * Get the error message with location information
  +     * appended.
  +     *
  +     * @return A <code>String</code> representing the error message with
  +     *         location information appended.
  +     */
  +    public String getMessageAndLocation() {
  +
  +        StringBuffer sbuffer = new StringBuffer();
  +        String       message = super.getMessage();
  +
  +        if (null != message) {
  +            sbuffer.append(message);
  +        }
  +
  +        if (null != locator) {
  +            String systemID = locator.getSystemId();
  +            int    line     = locator.getLineNumber();
  +            int    column   = locator.getColumnNumber();
  +
  +            if (null != systemID) {
  +                sbuffer.append("; SystemID: ");
  +                sbuffer.append(systemID);
  +            }
  +
  +            if (0 != line) {
  +                sbuffer.append("; Line#: ");
  +                sbuffer.append(line);
  +            }
  +
  +            if (0 != column) {
  +                sbuffer.append("; Column#: ");
  +                sbuffer.append(column);
  +            }
  +        }
  +
  +        return sbuffer.toString();
  +    }
  +
  +    /**
  +     * Get the location information as a string.
  +     *
  +     * @return A string with location info, or null
  +     * if there is no location information.
  +     */
  +    public String getLocationAsString() {
  +
  +        if (null != locator) {
  +            StringBuffer sbuffer  = new StringBuffer();
  +            String       systemID = locator.getSystemId();
  +            int          line     = locator.getLineNumber();
  +            int          column   = locator.getColumnNumber();
  +
  +            if (null != systemID) {
  +                sbuffer.append("; SystemID: ");
  +                sbuffer.append(systemID);
  +            }
  +
  +            if (0 != line) {
  +                sbuffer.append("; Line#: ");
  +                sbuffer.append(line);
  +            }
  +
  +            if (0 != column) {
  +                sbuffer.append("; Column#: ");
  +                sbuffer.append(column);
  +            }
  +
  +            return sbuffer.toString();
  +        } else {
  +            return null;
  +        }
  +    }
  +
  +    /**
  +     * Print the the trace of methods from where the error
  +     * originated.  This will trace all nested exception
  +     * objects, as well as this object.
  +     */
  +    public void printStackTrace() {
  +        printStackTrace(new java.io.PrintWriter(System.err, true));
  +    }
  +
  +    /**
  +     * Print the the trace of methods from where the error
  +     * originated.  This will trace all nested exception
  +     * objects, as well as this object.
  +     * @param s The stream where the dump will be sent to.
  +     */
  +    public void printStackTrace(java.io.PrintStream s) {
  +        printStackTrace(new java.io.PrintWriter(s));
  +    }
  +
  +    /**
  +     * Print the the trace of methods from where the error
  +     * originated.  This will trace all nested exception
  +     * objects, as well as this object.
  +     * @param s The writer where the dump will be sent to.
  +     */
  +    public void printStackTrace(java.io.PrintWriter s) {
  +
  +        if (s == null) {
  +            s = new java.io.PrintWriter(System.err, true);
  +        }
  +
  +        try {
  +            String locInfo = getLocationAsString();
  +
  +            if (null != locInfo) {
  +                s.println(locInfo);
  +            }
  +
  +            super.printStackTrace(s);
  +        } catch (Throwable e) {}
  +
  +        boolean isJdk14OrHigher = false;
  +        try {
  +        	Throwable.class.getMethod("getCause",(Class[]) null);
  +        	isJdk14OrHigher = true;
  +        } catch (NoSuchMethodException nsme) {
  +        	// do nothing
  +        }
  +
  +        // The printStackTrace method of the Throwable class in jdk 1.4 
  +        // and higher will include the cause when printing the backtrace.
  +        // The following code is only required when using jdk 1.3 or lower                 
  +        if (!isJdk14OrHigher) {
  +            Throwable exception = getException();
  +
  +            for (int i = 0; (i < 10) && (null != exception); i++) {
  +                s.println("---------");
  +
  +                try {
  +                    if (exception instanceof TransformerException) {
  +                        String locInfo =
  +                            ((TransformerException) exception)
  +                            .getLocationAsString();
  +
  +                        if (null != locInfo) {
  +                            s.println(locInfo);
  +                        }
  +                    }
  +
  +                    exception.printStackTrace(s);
  +                } catch (Throwable e) {
  +                    s.println("Could not print stack trace...");
  +                }
  +
  +                try {
  +                    Method meth =
  +                        ((Object) exception).getClass().getMethod("getException",
  +                        (Class[]) null);
  +
  +                    if (null != meth) {
  +                        Throwable prev = exception;
  +
  +                        exception = (Throwable) meth.invoke(exception, (Object[]) null);
  +
  +                        if (prev == exception) {
  +                            break;
  +                        }
  +                    } else {
  +                        exception = null;
  +                    }
  +                } catch (InvocationTargetException ite) {
  +                    exception = null;
  +                } catch (IllegalAccessException iae) {
  +                    exception = null;
  +                } catch (NoSuchMethodException nsme) {
  +                    exception = null;
  +                }
  +            }
  +        }
  +        // insure output is written
  +        s.flush();
  +    }
  +}
  
  
  
  1.7       +217 -217  xml-commons/java/external/src/javax/xml/transform/stream/StreamResult.java
  
  Index: StreamResult.java
  ===================================================================
  RCS file: /home/cvs/xml-commons/java/external/src/javax/xml/transform/stream/StreamResult.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- StreamResult.java	14 Jun 2005 19:17:19 -0000	1.6
  +++ StreamResult.java	15 Jun 2005 00:51:32 -0000	1.7
  @@ -1,217 +1,217 @@
  -/*
  - * Copyright 2003-2004 The Apache Software Foundation.
  - *
  - * Licensed under the Apache License, Version 2.0 (the "License");
  - * you may not use this file except in compliance with the License.
  - * You may obtain a copy of the License at
  - *
  - *     http://www.apache.org/licenses/LICENSE-2.0
  - *
  - * Unless required by applicable law or agreed to in writing, software
  - * distributed under the License is distributed on an "AS IS" BASIS,
  - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - * See the License for the specific language governing permissions and
  - * limitations under the License.
  - */
  -
  -// $Id$
  -
  -package javax.xml.transform.stream;
  -
  -import java.lang.reflect.Method;
  -import javax.xml.transform.Result;
  -
  -import java.io.File;
  -import java.io.OutputStream;
  -import java.io.Writer;
  -import java.net.MalformedURLException;
  -
  -/**
  - * <p>Acts as an holder for a transformation result,
  - * which may be XML, plain Text, HTML, or some other form of markup.</p>
  - *
  - * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
  - */
  -public class StreamResult implements Result {
  -
  -    /** If {@link javax.xml.transform.TransformerFactory#getFeature}
  -     * returns true when passed this value as an argument,
  -     * the Transformer supports Result output of this type.
  -     */
  -    public static final String FEATURE =
  -        "http://javax.xml.transform.stream.StreamResult/feature";
  -
  -    /**
  -     * Zero-argument default constructor.
  -     */
  -    public StreamResult() {
  -    }
  -
  -    /**
  -     * Construct a StreamResult from a byte stream.  Normally,
  -     * a stream should be used rather than a reader, so that
  -     * the transformer may use instructions contained in the
  -     * transformation instructions to control the encoding.
  -     *
  -     * @param outputStream A valid OutputStream reference.
  -     */
  -    public StreamResult(OutputStream outputStream) {
  -        setOutputStream(outputStream);
  -    }
  -
  -    /**
  -     * Construct a StreamResult from a character stream.  Normally,
  -     * a stream should be used rather than a reader, so that
  -     * the transformer may use instructions contained in the
  -     * transformation instructions to control the encoding.  However,
  -     * there are times when it is useful to write to a character
  -     * stream, such as when using a StringWriter.
  -     *
  -     * @param writer  A valid Writer reference.
  -     */
  -    public StreamResult(Writer writer) {
  -        setWriter(writer);
  -    }
  -
  -    /**
  -     * Construct a StreamResult from a URL.
  -     *
  -     * @param systemId Must be a String that conforms to the URI syntax.
  -     */
  -    public StreamResult(String systemId) {
  -        this.systemId = systemId;
  -    }
  -
  -    /**
  -     * Construct a StreamResult from a File.
  -     *
  -     * @param f Must a non-null File reference.
  -     */
  -    public StreamResult(File f) {
  -        setSystemId(f);
  -    }
  -
  -    /**
  -     * Set the ByteStream that is to be written to.  Normally,
  -     * a stream should be used rather than a reader, so that
  -     * the transformer may use instructions contained in the
  -     * transformation instructions to control the encoding.
  -     *
  -     * @param outputStream A valid OutputStream reference.
  -     */
  -    public void setOutputStream(OutputStream outputStream) {
  -        this.outputStream = outputStream;
  -    }
  -
  -    /**
  -     * Get the byte stream that was set with setOutputStream.
  -     *
  -     * @return The byte stream that was set with setOutputStream, or null
  -     * if setOutputStream or the ByteStream constructor was not called.
  -     */
  -    public OutputStream getOutputStream() {
  -        return outputStream;
  -    }
  -
  -    /**
  -     * Set the writer that is to receive the result.  Normally,
  -     * a stream should be used rather than a writer, so that
  -     * the transformer may use instructions contained in the
  -     * transformation instructions to control the encoding.  However,
  -     * there are times when it is useful to write to a writer,
  -     * such as when using a StringWriter.
  -     *
  -     * @param writer  A valid Writer reference.
  -     */
  -    public void setWriter(Writer writer) {
  -        this.writer = writer;
  -    }
  -
  -    /**
  -     * Get the character stream that was set with setWriter.
  -     *
  -     * @return The character stream that was set with setWriter, or null
  -     * if setWriter or the Writer constructor was not called.
  -     */
  -    public Writer getWriter() {
  -        return writer;
  -    }
  -
  -    /**
  -     * Set the systemID that may be used in association
  -     * with the byte or character stream, or, if neither is set, use
  -     * this value as a writeable URI (probably a file name).
  -     *
  -     * @param systemId The system identifier as a URI string.
  -     */
  -    public void setSystemId(String systemId) {
  -        this.systemId = systemId;
  -    }
  -
  -    /**
  -     * <p>Set the system ID from a <code>File</code> reference.</p>
  -     * 
  -     * <p>Note the use of {@link File#toURI()} and {@link File#toURL()}.
  -     * <code>toURI()</code> is prefered and used if possible.
  -     * To allow JAXP 1.3 to run on J2SE 1.3, <code>toURL()</code>
  -     * is used if a {@link NoSuchMethodException} is thrown by the attempt
  -     * to use <code>toURI()</code>.</p>
  -     *
  -     * @param f Must a non-null File reference.
  -     */
  -    public void setSystemId(File f) {
  -    	
  -    	try {
  -    		// use reflection to call f.toURI().toString().
  -    		// Avoid compile time dependency on J2SE 1.4.
  -    		Method toURIMethod = f.getClass().getMethod("toURI", null);
  -    		Object uri = toURIMethod.invoke(f, null);
  -    		Method toStringMethod = uri.getClass().getMethod("toString", null);
  -    		this.systemId = (String)toStringMethod.invoke(uri, null);
  -    	} 
  -    	catch (Exception exception)
  -	{
  -    		// running on J2SE 1.3?
  -    		try {
  -        		this.systemId = f.toURL().toString();
  -    		} catch (MalformedURLException malformedURLException) {
  -    			this.systemId = null;
  -    			throw new RuntimeException(
  -    					"javax.xml.transform.stream.StreamResult#setSystemId(File f) with MalformedURLException: "
  -    					+ malformedURLException.toString()
  -    			);
  -    		}
  -        }
  -    }
  -
  -    /**
  -     * Get the system identifier that was set with setSystemId.
  -     *
  -     * @return The system identifier that was set with setSystemId, or null
  -     * if setSystemId was not called.
  -     */
  -    public String getSystemId() {
  -        return systemId;
  -    }
  -
  -    //////////////////////////////////////////////////////////////////////
  -    // Internal state.
  -    //////////////////////////////////////////////////////////////////////
  -
  -    /**
  -     * The systemID that may be used in association
  -     * with the byte or character stream, or, if neither is set, use
  -     * this value as a writeable URI (probably a file name).
  -     */
  -    private String systemId;
  -
  -    /**
  -     * The byte stream that is to be written to.
  -     */
  -    private OutputStream outputStream;
  -
  -    /**
  -     * The character stream that is to be written to.
  -     */
  -    private Writer writer;
  -}
  +/*
  + * Copyright 2003-2004 The Apache Software Foundation.
  + *
  + * Licensed under the Apache License, Version 2.0 (the "License");
  + * you may not use this file except in compliance with the License.
  + * You may obtain a copy of the License at
  + *
  + *     http://www.apache.org/licenses/LICENSE-2.0
  + *
  + * Unless required by applicable law or agreed to in writing, software
  + * distributed under the License is distributed on an "AS IS" BASIS,
  + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  + * See the License for the specific language governing permissions and
  + * limitations under the License.
  + */
  +
  +// $Id$
  +
  +package javax.xml.transform.stream;
  +
  +import java.lang.reflect.Method;
  +import javax.xml.transform.Result;
  +
  +import java.io.File;
  +import java.io.OutputStream;
  +import java.io.Writer;
  +import java.net.MalformedURLException;
  +
  +/**
  + * <p>Acts as an holder for a transformation result,
  + * which may be XML, plain Text, HTML, or some other form of markup.</p>
  + *
  + * @author <a href="Jeff.Suttor@Sun.com">Jeff Suttor</a>
  + */
  +public class StreamResult implements Result {
  +
  +    /** If {@link javax.xml.transform.TransformerFactory#getFeature}
  +     * returns true when passed this value as an argument,
  +     * the Transformer supports Result output of this type.
  +     */
  +    public static final String FEATURE =
  +        "http://javax.xml.transform.stream.StreamResult/feature";
  +
  +    /**
  +     * Zero-argument default constructor.
  +     */
  +    public StreamResult() {
  +    }
  +
  +    /**
  +     * Construct a StreamResult from a byte stream.  Normally,
  +     * a stream should be used rather than a reader, so that
  +     * the transformer may use instructions contained in the
  +     * transformation instructions to control the encoding.
  +     *
  +     * @param outputStream A valid OutputStream reference.
  +     */
  +    public StreamResult(OutputStream outputStream) {
  +        setOutputStream(outputStream);
  +    }
  +
  +    /**
  +     * Construct a StreamResult from a character stream.  Normally,
  +     * a stream should be used rather than a reader, so that
  +     * the transformer may use instructions contained in the
  +     * transformation instructions to control the encoding.  However,
  +     * there are times when it is useful to write to a character
  +     * stream, such as when using a StringWriter.
  +     *
  +     * @param writer  A valid Writer reference.
  +     */
  +    public StreamResult(Writer writer) {
  +        setWriter(writer);
  +    }
  +
  +    /**
  +     * Construct a StreamResult from a URL.
  +     *
  +     * @param systemId Must be a String that conforms to the URI syntax.
  +     */
  +    public StreamResult(String systemId) {
  +        this.systemId = systemId;
  +    }
  +
  +    /**
  +     * Construct a StreamResult from a File.
  +     *
  +     * @param f Must a non-null File reference.
  +     */
  +    public StreamResult(File f) {
  +        setSystemId(f);
  +    }
  +
  +    /**
  +     * Set the ByteStream that is to be written to.  Normally,
  +     * a stream should be used rather than a reader, so that
  +     * the transformer may use instructions contained in the
  +     * transformation instructions to control the encoding.
  +     *
  +     * @param outputStream A valid OutputStream reference.
  +     */
  +    public void setOutputStream(OutputStream outputStream) {
  +        this.outputStream = outputStream;
  +    }
  +
  +    /**
  +     * Get the byte stream that was set with setOutputStream.
  +     *
  +     * @return The byte stream that was set with setOutputStream, or null
  +     * if setOutputStream or the ByteStream constructor was not called.
  +     */
  +    public OutputStream getOutputStream() {
  +        return outputStream;
  +    }
  +
  +    /**
  +     * Set the writer that is to receive the result.  Normally,
  +     * a stream should be used rather than a writer, so that
  +     * the transformer may use instructions contained in the
  +     * transformation instructions to control the encoding.  However,
  +     * there are times when it is useful to write to a writer,
  +     * such as when using a StringWriter.
  +     *
  +     * @param writer  A valid Writer reference.
  +     */
  +    public void setWriter(Writer writer) {
  +        this.writer = writer;
  +    }
  +
  +    /**
  +     * Get the character stream that was set with setWriter.
  +     *
  +     * @return The character stream that was set with setWriter, or null
  +     * if setWriter or the Writer constructor was not called.
  +     */
  +    public Writer getWriter() {
  +        return writer;
  +    }
  +
  +    /**
  +     * Set the systemID that may be used in association
  +     * with the byte or character stream, or, if neither is set, use
  +     * this value as a writeable URI (probably a file name).
  +     *
  +     * @param systemId The system identifier as a URI string.
  +     */
  +    public void setSystemId(String systemId) {
  +        this.systemId = systemId;
  +    }
  +
  +    /**
  +     * <p>Set the system ID from a <code>File</code> reference.</p>
  +     * 
  +     * <p>Note the use of {@link File#toURI()} and {@link File#toURL()}.
  +     * <code>toURI()</code> is prefered and used if possible.
  +     * To allow JAXP 1.3 to run on J2SE 1.3, <code>toURL()</code>
  +     * is used if a {@link NoSuchMethodException} is thrown by the attempt
  +     * to use <code>toURI()</code>.</p>
  +     *
  +     * @param f Must a non-null File reference.
  +     */
  +    public void setSystemId(File f) {
  +    	
  +    	try {
  +    		// use reflection to call f.toURI().toString().
  +    		// Avoid compile time dependency on J2SE 1.4.
  +    		Method toURIMethod = f.getClass().getMethod("toURI", (Class[]) null);
  +    		Object uri = toURIMethod.invoke(f, (Object[]) null);
  +    		Method toStringMethod = uri.getClass().getMethod("toString", (Class[]) null);
  +    		this.systemId = (String)toStringMethod.invoke(uri, (Object[]) null);
  +    	} 
  +    	catch (Exception exception)
  +	{
  +    		// running on J2SE 1.3?
  +    		try {
  +        		this.systemId = f.toURL().toString();
  +    		} catch (MalformedURLException malformedURLException) {
  +    			this.systemId = null;
  +    			throw new RuntimeException(
  +    					"javax.xml.transform.stream.StreamResult#setSystemId(File f) with MalformedURLException: "
  +    					+ malformedURLException.toString()
  +    			);
  +    		}
  +        }
  +    }
  +
  +    /**
  +     * Get the system identifier that was set with setSystemId.
  +     *
  +     * @return The system identifier that was set with setSystemId, or null
  +     * if setSystemId was not called.
  +     */
  +    public String getSystemId() {
  +        return systemId;
  +    }
  +
  +    //////////////////////////////////////////////////////////////////////
  +    // Internal state.
  +    //////////////////////////////////////////////////////////////////////
  +
  +    /**
  +     * The systemID that may be used in association
  +     * with the byte or character stream, or, if neither is set, use
  +     * this value as a writeable URI (probably a file name).
  +     */
  +    private String systemId;
  +
  +    /**
  +     * The byte stream that is to be written to.
  +     */
  +    private OutputStream outputStream;
  +
  +    /**
  +     * The character stream that is to be written to.
  +     */
  +    private Writer writer;
  +}
  
  
  
  1.5       +79 -79    xml-commons/java/external/src/org/xml/sax/helpers/NewInstance.java
  
  Index: NewInstance.java
  ===================================================================
  RCS file: /home/cvs/xml-commons/java/external/src/org/xml/sax/helpers/NewInstance.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- NewInstance.java	8 Apr 2005 10:53:24 -0000	1.4
  +++ NewInstance.java	15 Jun 2005 00:51:32 -0000	1.5
  @@ -1,79 +1,79 @@
  -// NewInstance.java - create a new instance of a class by name.
  -// http://www.saxproject.org
  -// Written by Edwin Goei, edwingo@apache.org
  -// and by David Brownell, dbrownell@users.sourceforge.net
  -// NO WARRANTY!  This class is in the Public Domain.
  -// $Id$
  -
  -package org.xml.sax.helpers;
  -
  -import java.lang.reflect.Method;
  -import java.lang.reflect.InvocationTargetException;
  -
  -/**
  - * Create a new instance of a class by name.
  - *
  - * <blockquote>
  - * <em>This module, both source code and documentation, is in the
  - * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  - * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
  - * for further information.
  - * </blockquote>
  - *
  - * <p>This class contains a static method for creating an instance of a
  - * class from an explicit class name.  It tries to use the thread's context
  - * ClassLoader if possible and falls back to using
  - * Class.forName(String).</p>
  - *
  - * <p>This code is designed to compile and run on JDK version 1.1 and later
  - * including versions of Java 2.</p>
  - *
  - * @author Edwin Goei, David Brownell
  - * @version 2.0.1 (sax2r2)
  - */
  -class NewInstance {
  -
  -    /**
  -     * Creates a new instance of the specified class name
  -     *
  -     * Package private so this code is not exposed at the API level.
  -     */
  -    static Object newInstance (ClassLoader classLoader, String className)
  -        throws ClassNotFoundException, IllegalAccessException,
  -            InstantiationException
  -    {
  -        Class driverClass;
  -        if (classLoader == null) {
  -            driverClass = Class.forName(className);
  -        } else {
  -            driverClass = classLoader.loadClass(className);
  -        }
  -        return driverClass.newInstance();
  -    }
  -
  -    /**
  -     * Figure out which ClassLoader to use.  For JDK 1.2 and later use
  -     * the context ClassLoader.
  -     */           
  -    static ClassLoader getClassLoader ()
  -    {
  -        Method m = null;
  -
  -        try {
  -            m = Thread.class.getMethod("getContextClassLoader", null);
  -        } catch (NoSuchMethodException e) {
  -            // Assume that we are running JDK 1.1, use the current ClassLoader
  -            return NewInstance.class.getClassLoader();
  -        }
  -
  -        try {
  -            return (ClassLoader) m.invoke(Thread.currentThread(), null);
  -        } catch (IllegalAccessException e) {
  -            // assert(false)
  -            throw new UnknownError(e.getMessage());
  -        } catch (InvocationTargetException e) {
  -            // assert(e.getTargetException() instanceof SecurityException)
  -            throw new UnknownError(e.getMessage());
  -        }
  -    }
  -}
  +// NewInstance.java - create a new instance of a class by name.
  +// http://www.saxproject.org
  +// Written by Edwin Goei, edwingo@apache.org
  +// and by David Brownell, dbrownell@users.sourceforge.net
  +// NO WARRANTY!  This class is in the Public Domain.
  +// $Id$
  +
  +package org.xml.sax.helpers;
  +
  +import java.lang.reflect.Method;
  +import java.lang.reflect.InvocationTargetException;
  +
  +/**
  + * Create a new instance of a class by name.
  + *
  + * <blockquote>
  + * <em>This module, both source code and documentation, is in the
  + * Public Domain, and comes with <strong>NO WARRANTY</strong>.</em>
  + * See <a href='http://www.saxproject.org'>http://www.saxproject.org</a>
  + * for further information.
  + * </blockquote>
  + *
  + * <p>This class contains a static method for creating an instance of a
  + * class from an explicit class name.  It tries to use the thread's context
  + * ClassLoader if possible and falls back to using
  + * Class.forName(String).</p>
  + *
  + * <p>This code is designed to compile and run on JDK version 1.1 and later
  + * including versions of Java 2.</p>
  + *
  + * @author Edwin Goei, David Brownell
  + * @version 2.0.1 (sax2r2)
  + */
  +class NewInstance {
  +
  +    /**
  +     * Creates a new instance of the specified class name
  +     *
  +     * Package private so this code is not exposed at the API level.
  +     */
  +    static Object newInstance (ClassLoader classLoader, String className)
  +        throws ClassNotFoundException, IllegalAccessException,
  +            InstantiationException
  +    {
  +        Class driverClass;
  +        if (classLoader == null) {
  +            driverClass = Class.forName(className);
  +        } else {
  +            driverClass = classLoader.loadClass(className);
  +        }
  +        return driverClass.newInstance();
  +    }
  +
  +    /**
  +     * Figure out which ClassLoader to use.  For JDK 1.2 and later use
  +     * the context ClassLoader.
  +     */           
  +    static ClassLoader getClassLoader ()
  +    {
  +        Method m = null;
  +
  +        try {
  +            m = Thread.class.getMethod("getContextClassLoader", (Class[]) null);
  +        } catch (NoSuchMethodException e) {
  +            // Assume that we are running JDK 1.1, use the current ClassLoader
  +            return NewInstance.class.getClassLoader();
  +        }
  +
  +        try {
  +            return (ClassLoader) m.invoke(Thread.currentThread(), (Object[]) null);
  +        } catch (IllegalAccessException e) {
  +            // assert(false)
  +            throw new UnknownError(e.getMessage());
  +        } catch (InvocationTargetException e) {
  +            // assert(e.getTargetException() instanceof SecurityException)
  +            throw new UnknownError(e.getMessage());
  +        }
  +    }
  +}