public void init()

in flow/src/java/org/apache/struts/flow/core/source/impl/URLSource.java [83:140]


    public void init(URL url, Map parameters) throws IOException
    {
        String systemId = url.toExternalForm();
        setSystemId(systemId);
        setScheme(SourceUtil.getScheme(systemId));

        m_url = url;
        m_isPost = false;
        // get the default system encoding in case no encoding is specified
        try {
            m_encoding = System.getProperty("file.property", "ISO-8859-1");
        } catch (SecurityException e) {
            m_encoding = "ISO-8859-1"; 
        }

        if (null != parameters)
        {
            m_parameters = (SourceParameters) parameters.get(SourceResolver.URI_PARAMETERS);
            final String method = (String) parameters.get(SourceResolver.METHOD);

            if ("POST".equalsIgnoreCase(method))
                m_isPost = true;

            final String encoding = (String) parameters.get(SourceResolver.URI_ENCODING);
            if (encoding != null && !"".equals(encoding))
                m_encoding = encoding;
        }

        if (null != m_parameters && m_parameters.hasParameters() && !m_isPost)
        {
            StringBuffer urlBuffer = new StringBuffer(systemId);
            String key;
            final Iterator i = m_parameters.getParameterNames();
            Iterator values;
            String value;
            boolean first = (systemId.indexOf('?') == -1);
            if (first == true)
                urlBuffer.append('?');
            while (i.hasNext())
            {
                key = (String) i.next();
                values = m_parameters.getParameterValues(key);
                while (values.hasNext() == true)
                {
                    value = SourceUtil.encode((String) values.next(), m_encoding);
                    if (first == false)
                        urlBuffer.append('&');
                    first = false;
                    urlBuffer.append(key);
                    urlBuffer.append('=');
                    urlBuffer.append(value);
                }
            }

            m_url = new URL(urlBuffer.toString());
            m_parameters = null;
        }
    }