Package javax.servlet.jsp.tagext

Examples of javax.servlet.jsp.tagext.BodyContent


        int partialRedBlockIndex = (int) Math.floor((value - fullRedBlockCount * blockWidth) / unitSize);
        int partialBlueBlockIndex1 = (partialRedBlockIndex > 0 ? Math.min((int) Math.floor(value2 / unitSize), partialBlocks - partialRedBlockIndex) : 0);
        int fullBlueBlockCount = Math.max(0, (int) Math.floor(value2 / blockWidth) - (partialRedBlockIndex > 0 ? 1 : 0));
        int partialBlueBlockIndex2 = (int) Math.floor((value2 - (fullBlueBlockCount * blockWidth) - (partialBlueBlockIndex1 * unitSize)) / unitSize);

        BodyContent bc = getBodyContent();
        String body = bc.getString().trim();

        StringBuffer buf = new StringBuffer();

        // Beginning
        if (showA) {
            String format = "a0";
            if (fullRedBlockCount > 0 || partialRedBlockIndex > 0) {
                format = "a1";
            } else if (partialBlueBlockIndex1 == 0 && (fullBlueBlockCount > 0 || partialBlueBlockIndex2 > 0)) {
                format = "a2";
            }
            buf.append(MessageFormat.format(body, new Object[]{format}));
        }

        // Full red blocks
        String fullRedBody = MessageFormat.format(body, new Object[]{partialBlocks + "+0"});
        for (int i = 0; i < fullRedBlockCount; i++) {
            buf.append(fullRedBody);
        }

        // Mixed red/blue block (mid-block transition)
        if (partialRedBlockIndex > 0) {
            String partialBody = MessageFormat.format(body, new Object[]{partialRedBlockIndex + "+" + partialBlueBlockIndex1});
            buf.append(partialBody);
        }

        // Full blue blocks
        String fullBlueBody = MessageFormat.format(body, new Object[]{"0+" + partialBlocks});
        for (int i = 0; i < fullBlueBlockCount; i++) {
            buf.append(fullBlueBody);
        }

        // Partial blue block
        if (partialBlueBlockIndex2 > 0) {
            String partialBody = MessageFormat.format(body, new Object[]{"0+" + partialBlueBlockIndex2});
            buf.append(partialBody);
        }

        // Empty blocks
        int emptyBlocks = showEmptyBlocks ? fullBlocks - (fullRedBlockCount + fullBlueBlockCount + (partialRedBlockIndex > 0 ? 1 : 0) + (partialBlueBlockIndex2 > 0 ? 1 : 0)) : 0;
        if (emptyBlocks > 0) {
            String emptyBody = MessageFormat.format(body, new Object[]{"0+0"});
            for (int i = 0; i < emptyBlocks; i++) {
                buf.append(emptyBody);
            }
        }

        // End
        if (showB) {
            String format = "b0";
            if (fullRedBlockCount == fullBlocks) {
                format = "b1";
            } else if (fullRedBlockCount + (partialRedBlockIndex + partialBlueBlockIndex1 == partialBlocks ? 1 : 0) + fullBlueBlockCount == fullBlocks) {
                format = "b2";
            }
            buf.append(MessageFormat.format(body, new Object[]{format}));
        }

        try {
            JspWriter out = bc.getEnclosingWriter();
            out.print(buf.toString());
        } catch (IOException ioe) {
            throw new JspException("Error:IOException while writing to client" + ioe.getMessage());
        }

View Full Code Here


    return SKIP_BODY;
  }

  public int doEndTag() throws JspException
  {
    BodyContent body = (BodyContent) getBodyContent();

    if (body != null) {
      String value = body.getString().trim();
     
      if (_var != null)
        doSetValue(value);
      else
        doSetProperty(value);
View Full Code Here

      }

      if (_xml != null)
        source = getSource(_xml, getCanonicalURL(pageContext, _xmlSystemId));
      else {
        BodyContent body = getBodyContent();
       
        TempCharReader tempReader = (TempCharReader) body.getReader();
        int ch;

        while (Character.isWhitespace((ch = tempReader.read()))) {
        }
View Full Code Here

    }
  }

  public int doEndTag() throws JspException
  {
    BodyContent body = (BodyContent) getBodyContent();

    if (body != null) {
      if (var != null)
        setValue(body.getString().trim());
      else
        setProperty(body.getString().trim());
    }

    return EVAL_PAGE;
  }
View Full Code Here

      }

      if (_xml != null)
        source = getSource(_xml, _xmlSystemId);
      else {
        BodyContent bodyContent = getBodyContent();

        source = new StreamSource(bodyContent.getReader());
        source.setSystemId(((HttpServletRequest) pageContext.getRequest()).getRequestURI());
      }

      Result result;
      Node top = null;
View Full Code Here

    // test for bugzilla #49900 that bodyContent is not released

    @Test
    public void testBodyContentIsRelease() {
        BodyContent b = EasyMock.createMock(BodyContent.class);
        tag.setBodyContent(b);
        tag.release();
        Assert.assertNull(tag.getBodyContent());
    }
View Full Code Here

    }

    @Test
    public void testResultFromBodyContent() throws JspException {
        tag = new MockSetSupport();
        BodyContent bodyContent = createMock(BodyContent.class);
        expect(bodyContent.getString()).andStubReturn("  Hello  ");
        replay(bodyContent);
        tag.setBodyContent(bodyContent);
        Assert.assertEquals(VALUE, tag.getResult());
    }
View Full Code Here

    }

    @Test
    public void testResultFromEmptyBodyContent() throws JspException {
        tag = new MockSetSupport();
        BodyContent bodyContent = createMock(BodyContent.class);
        expect(bodyContent.getString()).andStubReturn(null);
        Assert.assertEquals("", tag.getResult());
    }
View Full Code Here

    @Override
    public int doEndTag() throws JspException {
        Generator generator = getAbdera().getFactory().newGenerator();
        if (uri != null) generator.setUri(uri);
        if (version != null) generator.setVersion(version);
        BodyContent bc = getBodyContent();
        generator.setText(bc.getString());

        getFeed().setGenerator(generator);

        return super.doEndTag();
    }
View Full Code Here

   
    private static final String NOT_PROCESS_PARAMETER = "granule";

    public int doAfterBody() throws JspTagException {
        HttpServletRequest httpRequest = (HttpServletRequest) pageContext.getRequest();
        BodyContent bc = getBodyContent();
        String oldBody = bc.getString();
        bc.clearBody();
        if (httpRequest.getParameter(NOT_PROCESS_PARAMETER) != null) {
            boolean b = CompressorSettings.getBoolean(httpRequest.getParameter(NOT_PROCESS_PARAMETER), false);
            if (!b)
                httpRequest.getSession().setAttribute(NOT_PROCESS_PARAMETER, true);
            else httpRequest.getSession().removeAttribute(NOT_PROCESS_PARAMETER);
View Full Code Here

TOP

Related Classes of javax.servlet.jsp.tagext.BodyContent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.