Logo Search packages:      
Sourcecode: icedtea-web version File versions  Download package

URL net::sourceforge::jnlp::Parser::getURL ( Node  node,
String  name,
URL  base 
) throws ParseException [inline]

Returns a URL object from a href string relative to the code base. If the href denotes a relative URL, it must reference a location that is a subdirectory of the codebase.

Parameters:
node the node
name the attribute containing an href
base the base URL
Exceptions:
ParseException if the JNLP file is invalid

Definition at line 1001 of file Parser.java.

References base, getAttribute(), and strict.

Referenced by getApplet(), getJRE(), getRelatedContent(), getRequiredURL(), and Parser().

                                                                              {
        String href = getAttribute(node, name, null);
        if (href == null)
            return null; // so that code can throw an exception if attribute was required

        try {
            if (base == null)
                return new URL(href);
            else {
                try {
                    return new URL(href);
                }
                catch (MalformedURLException ex) {
                    // is relative
                }

                URL result = new URL(base, href);

                // check for going above the codebase
                if (! result.toString().startsWith( base.toString()) )
                    if (strict)
                        throw new ParseException(R("PUrlNotInCodebase", node.getNodeName(), href, base));

                return result;
            }

        }
        catch (MalformedURLException ex) {
            if (base == null)
                throw new ParseException(R("PBadNonrelativeUrl", node.getNodeName(), href));
            else
                throw new ParseException(R("PBadRelativeUrl", node.getNodeName(), href, base));
        }
    }


Generated by  Doxygen 1.6.0   Back to index