Example usage for org.jsoup.nodes Document html

List of usage examples for org.jsoup.nodes Document html

Introduction

In this page you can find the example usage for org.jsoup.nodes Document html.

Prototype

@Override
    public <T extends Appendable> T html(T appendable) 

Source Link

Usage

From source file:org.jasig.portlet.proxy.service.proxy.document.ContentClippingFilter.java

@Override
public void filter(final Document document, final IContentResponse proxyResponse, final RenderRequest request,
        final RenderResponse response) {

    // get the clipping selector for this portlet configuration
    final PortletPreferences preferences = request.getPreferences();
    final String selector = preferences.getValue(SELECTOR_KEY, null);

    // locate the matching element in the document and replace the document
    // with just that node subtree
    final Elements elements = document.select(selector);
    if (elements.size() > 0) {
        document.html("").appendChild(elements.get(0));
    }//from   www  .  j a  v  a2s  . com
}

From source file:org.jasig.portlet.proxy.service.proxy.document.HeaderFooterFilter.java

@Override
public void filter(Document document, IContentResponse proxyResponse, RenderRequest portletRequest,
        RenderResponse portletResponse) {

    // get any configured header / footer content from the portlet preferences
    final PortletPreferences preferences = portletRequest.getPreferences();
    final String header = preferences.getValue(HEADER_KEY, null);
    final String footer = preferences.getValue(FOOTER_KEY, null);

    // If both a header and footer have been specified, there's some chance they 
    // could be intended to wrap the proxied content.  We can't wrap content 
    // using the prepend / append methods, since those would automatically 
    // close partial elements in each header / footer
    if (StringUtils.isNotBlank(header) && StringUtils.isNotBlank(footer)) {
        document.html(header.concat(document.html()).concat(footer));
    }//www.  j  av a  2  s. co m

    else if (StringUtils.isNotBlank(header)) {
        document.prepend(header);
    }

    else if (StringUtils.isNotBlank(footer)) {
        document.append(footer);
    }

}