Java源码示例:com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException

示例1
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例2
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例3
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例4
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例5
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例6
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例7
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例8
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例9
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例10
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例11
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例12
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例13
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例14
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例15
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例16
/**
 * Constructs a CharInfo object using the following process to try reading
 * the entitiesFileName parameter:
 *
 *   1) attempt to load it as a ResourceBundle
 *   2) try using the class loader to find the specified file
 *   3) try opening it as an URI
 *
 * In case of 2 and 3, the resource file must be encoded in UTF-8 and have the
 * following format:
 * <pre>
 * # First char # is a comment
 * Entity numericValue
 * quot 34
 * amp 38
 * </pre>
 *
 * @param entitiesFileName Name of entities resource file that should
 * be loaded, which describes the mapping of characters to entity references.
 * @param method the output method type, which should be one of "xml", "html", and "text".
 * @return an instance of CharInfo
 */
static CharInfo getCharInfo(String entitiesFileName, String method)
{
    try {
        return new CharInfo(entitiesFileName, method, false);
    } catch (Exception e) {}

    String absoluteEntitiesFileName;

    if (entitiesFileName.indexOf(':') < 0) {
        absoluteEntitiesFileName =
            SystemIDResolver.getAbsoluteURIFromRelative(entitiesFileName);
    } else {
        try {
            absoluteEntitiesFileName =
                SystemIDResolver.getAbsoluteURI(entitiesFileName, null);
        } catch (TransformerException te) {
            throw new WrappedRuntimeException(te);
        }
    }

    return new CharInfo(absoluteEntitiesFileName, method, false);
}
 
示例17
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例18
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException
{

    try
    {
        TreeWalker walker =
            new TreeWalker(this);

        walker.traverse(node);
    }
    catch (org.xml.sax.SAXException se)
    {
        throw new WrappedRuntimeException(se);
    }
}
 
示例19
/**
 * Serializes the Level 3 DOM node by creating an instance of DOM3TreeWalker
 * which traverses the DOM tree and invokes handler events to serialize
 * the DOM NOde. Throws an exception only if an I/O exception occured
 * while serializing.
 * This interface is a public API.
 *
 * @param node the Level 3 DOM node to serialize
 * @throws IOException if an I/O exception occured while serializing
 */
public void serializeDOM3(Node node) throws IOException {
    try {
        DOM3TreeWalker walker = new DOM3TreeWalker(fSerializationHandler,
                fErrorHandler, fSerializerFilter, fNewLine);

        walker.traverse(node);
    } catch (org.xml.sax.SAXException se) {
        throw new WrappedRuntimeException(se);
    }
}
 
示例20
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException {
    try {
        TreeWalker walker = new TreeWalker(this);
        walker.traverse(node);
    } catch (org.xml.sax.SAXException se) {
        throw new WrappedRuntimeException(se);
    }
}
 
示例21
/**
 * Serializes the Level 3 DOM node by creating an instance of DOM3TreeWalker
 * which traverses the DOM tree and invokes handler events to serialize
 * the DOM NOde. Throws an exception only if an I/O exception occured
 * while serializing.
 * This interface is a public API.
 *
 * @param node the Level 3 DOM node to serialize
 * @throws IOException if an I/O exception occured while serializing
 */
public void serializeDOM3(Node node) throws IOException {
    try {
        DOM3TreeWalker walker = new DOM3TreeWalker(fSerializationHandler,
                fErrorHandler, fSerializerFilter, fNewLine);

        walker.traverse(node);
    } catch (org.xml.sax.SAXException se) {
        throw new WrappedRuntimeException(se);
    }
}
 
示例22
/**
 * Serializes the DOM node. Throws an exception only if an I/O
 * exception occured while serializing.
 *
 * @param node Node to serialize.
 * @throws IOException An I/O exception occured while serializing
 */
public void serialize(Node node) throws IOException {
    try {
        TreeWalker walker = new TreeWalker(this);
        walker.traverse(node);
    } catch (org.xml.sax.SAXException se) {
        throw new WrappedRuntimeException(se);
    }
}
 
示例23
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例24
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例25
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例26
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例27
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例28
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例29
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}
 
示例30
/**
 * Creates an empty OutputProperties with the property key/value defaults specified by
 * a property file.  The method argument is used to construct a string of
 * the form output_[method].properties (for instance, output_html.properties).
 * The output_xml.properties file is always used as the base.
 *
 * <p>Anything other than 'text', 'xml', and 'html', will
 * use the output_xml.properties file.</p>
 *
 * @param   method non-null reference to method name.
 *
 * @return Properties object that holds the defaults for the given method.
 */
static public final Properties getDefaultMethodProperties(String method)
{
    String fileName = null;
    Properties defaultProperties = null;
    // According to this article : Double-check locking does not work
    // http://www.javaworld.com/javaworld/jw-02-2001/jw-0209-toolbox.html
    try
    {
        synchronized (m_synch_object)
        {
            if (null == m_xml_properties) // double check
            {
                fileName = PROP_FILE_XML;
                m_xml_properties = loadPropertiesFile(fileName, null);
            }
        }

        if (method.equals(Method.XML))
        {
            defaultProperties = m_xml_properties;
        }
        else if (method.equals(Method.HTML))
        {
            if (null == m_html_properties) // double check
            {
                fileName = PROP_FILE_HTML;
                m_html_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_html_properties;
        }
        else if (method.equals(Method.TEXT))
        {
            if (null == m_text_properties) // double check
            {
                fileName = PROP_FILE_TEXT;
                m_text_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
                if (null
                    == m_text_properties.getProperty(OutputKeys.ENCODING))
                {
                    String mimeEncoding = Encodings.getMimeEncoding(null);
                    m_text_properties.put(
                        OutputKeys.ENCODING,
                        mimeEncoding);
                }
            }

            defaultProperties = m_text_properties;
        }
        else if (method.equals(com.sun.org.apache.xml.internal.serializer.Method.UNKNOWN))
        {
            if (null == m_unknown_properties) // double check
            {
                fileName = PROP_FILE_UNKNOWN;
                m_unknown_properties =
                    loadPropertiesFile(fileName, m_xml_properties);
            }

            defaultProperties = m_unknown_properties;
        }
        else
        {
            // TODO: Calculate res file from name.
            defaultProperties = m_xml_properties;
        }
    }
    catch (IOException ioe)
    {
        throw new WrappedRuntimeException(
            Utils.messages.createMessage(
                MsgKey.ER_COULD_NOT_LOAD_METHOD_PROPERTY,
                new Object[] { fileName, method }),
            ioe);
    }
    // wrap these cached defaultProperties in a new Property object just so
    // that the caller of this method can't modify the default values
    return new Properties(defaultProperties);
}