Example usage for org.apache.wicket.markup IMarkupFragment getMarkupResourceStream

List of usage examples for org.apache.wicket.markup IMarkupFragment getMarkupResourceStream

Introduction

In this page you can find the example usage for org.apache.wicket.markup IMarkupFragment getMarkupResourceStream.

Prototype

MarkupResourceStream getMarkupResourceStream();

Source Link

Document

Get the underlying markup resource stream, which might contain more than just the markup portion represented by the IMarkupFragment.

Usage

From source file:org.cast.isi.ISIXmlComponent.java

License:Open Source License

/**
 *  If an IMarkupFragment contains unicode d7, converts it into one that uses the corresponding character entity.
 *
 * @param fragment/*from   w w w  . ja va  2  s  . co  m*/
 * @return
 * @throws ResourceStreamNotFoundException
 */
protected static IMarkupFragment hackUnicodeD7(IMarkupFragment fragment)
        throws IOException, ResourceStreamNotFoundException {
    MarkupResourceStream markupStream = fragment.getMarkupResourceStream();
    InputStream is = markupStream.getInputStream();
    String x = getStringFromInputStream(is);
    if (x.contains("\u00d7")) {
        log.debug("Fixing instances of unicode D7");
        x = x.replaceAll("\u00d7", "×");
        return createMarkupFragmentFromString(x);
    } else {
        return fragment;
    }
}

From source file:org.cast.isi.ISIXmlComponentTest.java

License:Open Source License

@Test
public void testCreateMarkupFragmentFromString() throws Exception {
    String s = "<span>some markup</span>";
    IMarkupFragment fragment = ISIXmlComponent.createMarkupFragmentFromString(s);
    MarkupResourceStream markupStream = fragment.getMarkupResourceStream();
    InputStream is = markupStream.getInputStream();
    String x = ISIXmlComponent.getStringFromInputStream(is);
    assertEquals("Expected no changes to input string", s, x);
}

From source file:org.cast.isi.ISIXmlComponentTest.java

License:Open Source License

@Test
public void testCreateMarkupFragmentFromNullString() throws Exception {
    String s = null;//from   www .j a v  a  2 s  . c om
    IMarkupFragment fragment = ISIXmlComponent.createMarkupFragmentFromString(s);
    try {
        MarkupResourceStream markupStream = fragment.getMarkupResourceStream();
        InputStream is = markupStream.getInputStream();
        String x = ISIXmlComponent.getStringFromInputStream(is);
        fail("Expected NullPointerException didn't happen");
    } catch (NullPointerException x) {
    }
}