Package com.caucho.util

Examples of com.caucho.util.CharBuffer


          ch = parseExtension(parent, name);
        }
        else if (ch == '(') {
          addText(parent);
          Element elt = xsl.createElementNS(XSLNS, "xsl:value-of");
          CharBuffer test = CharBuffer.allocate();
          lexToRparen(test);
          elt.setAttribute("select", test.close());
          parent.appendChild(elt);
          ch = read();
        }
        else {
          addText('$');
View Full Code Here


        addText(String.valueOf(code));
        return ch;
      }
    }

    CharBuffer cb = CharBuffer.allocate();
    for (; ch >= 'a' && ch <= 'z'; ch = read())
      cb.append((char) ch);

    if (ch != ';') {
      addText('&');
      addText(cb.close());
    }
    else if (cb.matches("lt")) {
      addText('<');
      return read();
    }
    else if (cb.matches("gt")) {
      addText('>');
      return read();
    }
    else if (cb.matches("amp")) {
      addText('&');
      return read();
    }
    else if (cb.matches("quot")) {
      addText('"');
      return read();
    }
    else if (cb.matches("apos")) {
      addText('\'');
      return read();
    }
    else {
      addText('&');
      addText(cb.close());
    }

    return ch;
  }
View Full Code Here

        return parseExtension(parent, name);
      }
      else if (ch == '(') {
        Element elt = xsl.createElementNS(XSLNS, "xsl:value-of");
        CharBuffer test = CharBuffer.allocate();
        lexToRparen(test);
        elt.setAttribute("select", test.close());
        parent.appendChild(elt);
        return read();
      }
      else
        throw error(L.l("expected statement at {0}", badChar(ch)));
View Full Code Here

      else if ((ch = read()) != '(') {
        peek = ch;
        return parseStatement(elt, ch);
      }
      else {
        CharBuffer test = CharBuffer.allocate();
        lexToRparen(test);
        elt.setAttribute("select", test.close());
        return read();
      }
    }

    QElement elt = (QElement) xsl.createElement(name);
View Full Code Here

    choose.setLocation(is.getURL(), is.getUserPath(), line, 0);
    parent.appendChild(choose);

    while (true) {
      lexExpect(ch, '(');
      CharBuffer test = CharBuffer.allocate();
      lexToRparen(test);

      QElement elt = (QElement) xsl.createElementNS(XSLNS, "xsl:when");
      choose.appendChild(elt);
      elt.setLocation(is.getURL(), is.getUserPath(), line, 0);
      elt.setAttribute("test", test.close());

      ch = parseStatement(elt, skipWhitespace(read()));

      ch = skipWhitespace(ch);
      if (ch != '$')
View Full Code Here

  }

  private String parseName(int ch)
    throws IOException, XslParseException
  {
    CharBuffer cb = CharBuffer.allocate();

    for (; XmlChar.isNameChar(ch); ch = read())
      cb.append((char) ch);

    peek = ch;

    return cb.close();
  }
View Full Code Here

  }

  private void parseArgs(Element elt, String arg)
    throws IOException, XslParseException
  {
    CharBuffer cb = CharBuffer.allocate();
    String key = null;
    boolean isFirst = true;
    int ch;
   
    for (ch = read(); ch >= 0 && ch != ')'; ch = read()) {
      cb.append((char) ch);
     
      switch (ch) {
      case '(':
        lexToRparen(cb);
        cb.append(')');
        break;

      case '"': case '\'':
        lexString(cb, ch);
        break;
       
      case '=':
        ch = read();
        if (ch == '>') {
          cb.setLength(cb.length() - 1);
          key = cb.toString().trim();
          cb.clear();
        }
        else {
          peek = ch;
        }
        break;
       
      case ',':
        cb.setLength(cb.length() - 1);
        if (key != null)
          elt.setAttribute(key, cb.toString());
        else if (arg != null && isFirst)
          elt.setAttribute(arg, cb.toString());
        else
          throw error(L.l("unexpected arg `{0}'", cb));
        cb.clear();
        isFirst = false;
        key = null;
        break;
      }

    }

    if (ch != ')')
      throw error(L.l("expected `{0}' at {1}", ")", badChar(ch)));

    if (key != null)
      elt.setAttribute(key, cb.close());
    else if (arg != null && cb.length() > 0 && isFirst)
      elt.setAttribute(arg, cb.close());
    else if (cb.length() > 0)
      throw error(L.l("unexpected arg `{0}'", cb));
  }
View Full Code Here

  private void parseContentType(Node parent, String contentType)
    throws IOException, XslParseException
  {
    CharCursor cursor = new StringCharCursor(contentType);

    CharBuffer buf = new CharBuffer();
    wsScanner.skip(cursor);
    delimScanner.scan(cursor, buf);

    if (buf.length() <= 0)
      return;

    Element output = xsl.createElementNS(XSLNS, "xsl:output");
    parent.appendChild(output);
    output.setAttribute("media-type", buf.toString());
    delimScanner.skip(cursor);

    buf.clear();
    delimScanner.scan(cursor, buf);
    wsScanner.skip(cursor);
    if (cursor.current() == '=' && buf.toString().equals("charset")) {
      delimScanner.skip(cursor);
      buf.clear();
      delimScanner.scan(cursor, buf);
      if (buf.length() > 0) {
        output.setAttribute("encoding", Encoding.getMimeName(buf.toString()));
        is.setEncoding(buf.toString());
      }
    }
  }
View Full Code Here

    return AuthorizationResult.DENY;
  }

  public String toString()
  {
    CharBuffer cb = new CharBuffer();

    cb.append(getClass().getSimpleName());
    cb.append("[");
    for (int i = 0; i < _roles.length; i++) {
      if (i != 0)
        cb.append(',');
      cb.append(_roles[i]);
    }
    cb.append("]");
   
    return cb.close();
  }
View Full Code Here

   * Parses the access log string.
   */
  private ArrayList<Segment> parseFormat(String format)
  {
    ArrayList<Segment> segments = new ArrayList<Segment>();
    CharBuffer cb = new CharBuffer();

    int i = 0;
    while (i < _format.length()) {
      char ch = _format.charAt(i++);

      if (ch != '%' || i >= _format.length()) {
        cb.append((char) ch);
        continue;
      }

      String arg = null;
      ch = _format.charAt(i++);
      if (ch == '>')
        ch = _format.charAt(i++);
      else if (ch == '{') {
        if (cb.length() > 0)
          segments.add(new Segment(this, Segment.TEXT, cb.toString()));
        cb.clear();
        while (i < _format.length() && _format.charAt(i++) != '}')
          cb.append(_format.charAt(i - 1));
        arg = cb.toString();
        cb.clear();

        ch = _format.charAt(i++);
      }

      switch (ch) {
      case 'b': case 'c':
      case 'h': case 'i': case 'l': case 'n':
      case 'r': case 's':
      case 'T': case 'D': case 'o':
      case 'u': case 'U':
      case 'v': case 'S':
        if (cb.length() > 0)
          segments.add(new Segment(this, Segment.TEXT, cb.toString()));
        cb.clear();
        segments.add(new Segment(this, ch, arg));
        break;

      case 't':
        if (cb.length() > 0)
          segments.add(new Segment(this, Segment.TEXT, cb.toString()));
        cb.clear();
        if (arg != null)
          _timeFormat = arg;
        segments.add(new Segment(this, ch, arg));
        break;

      default:
        cb.append('%');
        i--;
        break;
      }
    }

    cb.append(CauchoSystem.getNewlineString());
    segments.add(new Segment(this, Segment.TEXT, cb.toString()));

    return segments;
  }
View Full Code Here

TOP

Related Classes of com.caucho.util.CharBuffer

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.