Java Code Examples for com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException

The following examples show how to use com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: jdk1.8-source-analysis   Source File: ToStream.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 2
Source Project: jdk1.8-source-analysis   Source File: CharInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 3
Source Project: TencentKona-8   Source File: ToStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 4
Source Project: TencentKona-8   Source File: CharInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 5
Source Project: jdk8u60   Source File: ToStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 6
Source Project: jdk8u60   Source File: CharInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 7
Source Project: JDKSourceCode1.8   Source File: ToStream.java    License: MIT License 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 8
Source Project: JDKSourceCode1.8   Source File: CharInfo.java    License: MIT License 6 votes vote down vote up
/**
 * 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);
}
 
Example 9
Source Project: openjdk-jdk8u   Source File: ToStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 10
Source Project: openjdk-jdk8u   Source File: CharInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 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);
    }
}
 
Example 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);
}
 
Example 13
Source Project: Bytecoder   Source File: CharInfo.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 14
Source Project: openjdk-jdk9   Source File: CharInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 15
Source Project: hottub   Source File: ToStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 16
Source Project: hottub   Source File: CharInfo.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
}
 
Example 17
Source Project: openjdk-8-source   Source File: ToStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 18
Source Project: openjdk-8   Source File: ToStream.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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);
    }
}
 
Example 19
Source Project: Bytecoder   Source File: DOM3SerializerImpl.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 20
Source Project: Bytecoder   Source File: ToStream.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 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);
    }
}
 
Example 22
Source Project: openjdk-jdk9   Source File: ToStream.java    License: GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
    }
}
 
Example 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);
}
 
Example 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);
}
 
Example 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);
}
 
Example 26
Source Project: JDKSourceCode1.8   Source File: OutputPropertiesFactory.java    License: MIT License 4 votes vote down vote up
/**
 * 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);
}
 
Example 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);
}
 
Example 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);
}
 
Example 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);
}
 
Example 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);
}