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

The following examples show how to use com.sun.org.apache.xml.internal.serializer.utils.WrappedRuntimeException. 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 File: ToStream.java    From openjdk-jdk8u-backup with 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 #2
Source File: ToStream.java    From openjdk-8 with 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 #3
Source File: ToStream.java    From openjdk-8-source with 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 File: CharInfo.java    From hottub with 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 File: ToStream.java    From hottub with 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 File: CharInfo.java    From openjdk-jdk9 with 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 File: CharInfo.java    From Bytecoder with 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 #8
Source File: CharInfo.java    From openjdk-jdk8u-backup with 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 #9
Source File: CharInfo.java    From openjdk-jdk8u with 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 #10
Source File: ToStream.java    From openjdk-jdk8u with 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 #11
Source File: CharInfo.java    From JDKSourceCode1.8 with 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 #12
Source File: ToStream.java    From jdk1.8-source-analysis with 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 #13
Source File: CharInfo.java    From jdk1.8-source-analysis with 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 File: CharInfo.java    From jdk8u60 with 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 File: ToStream.java    From TencentKona-8 with 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 File: CharInfo.java    From TencentKona-8 with 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 File: ToStream.java    From jdk8u60 with 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 File: ToStream.java    From JDKSourceCode1.8 with 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 #19
Source File: DOM3SerializerImpl.java    From openjdk-jdk9 with GNU General Public License v2.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 File: ToStream.java    From openjdk-jdk9 with 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 #21
Source File: ToStream.java    From Bytecoder with 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 #22
Source File: DOM3SerializerImpl.java    From Bytecoder with 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 #23
Source File: OutputPropertiesFactory.java    From jdk8u60 with GNU General Public License v2.0 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 #24
Source File: OutputPropertiesFactory.java    From openjdk-jdk9 with GNU General Public License v2.0 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 #25
Source File: OutputPropertiesFactory.java    From jdk1.8-source-analysis with Apache License 2.0 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 #26
Source File: OutputPropertiesFactory.java    From hottub with GNU General Public License v2.0 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
Source File: OutputPropertiesFactory.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 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 #28
Source File: OutputPropertiesFactory.java    From TencentKona-8 with GNU General Public License v2.0 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 #29
Source File: OutputPropertiesFactory.java    From openjdk-8-source with GNU General Public License v2.0 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 #30
Source File: OutputPropertiesFactory.java    From JDKSourceCode1.8 with 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);
}