Package com.caucho.util

Examples of com.caucho.util.StringCharCursor


   * parse the content-type, possibly changing character-encoding.
   */
  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()));
View Full Code Here


      Attr attr = (Attr) iter.next();
      String name = attr.getNodeName();
      String value = attr.getNodeValue();

      if (name.equals("import")) {
        StringCharCursor cursor = new StringCharCursor(value);
        CharBuffer cb = new CharBuffer();
        while (cursor.current() != cursor.DONE) {
          char ch;
          commaDelimScanner.skip(cursor);

          cb.clear();
          ch = commaDelimScanner.scan(cursor, cb);
View Full Code Here

  }

  public void addImportList(String value)
    throws XslParseException
  {
    StringCharCursor cursor = new StringCharCursor(value);
    CharBuffer cb = new CharBuffer();
    while (cursor.current() != cursor.DONE) {
      char ch;
      commaDelimScanner.skip(cursor);

      cb.clear();
      ch = commaDelimScanner.scan(cursor, cb);
View Full Code Here

   * @param to a list of new recipients
   */
  public void addTo(String to)
    throws IOException
  {
    StringCharCursor cursor = new StringCharCursor(to);

    ArrayList<MailtoPath.Recipient> list = MailtoPath.parseAddressList(cursor);

    for (int i = 0; i < list.size(); i++)
      _to.add(list.get(i));
View Full Code Here

   * @param to a list of new recipients
   */
  public void addCc(String to)
    throws IOException
  {
    StringCharCursor cursor = new StringCharCursor(to);

    ArrayList<MailtoPath.Recipient> list = MailtoPath.parseAddressList(cursor);

    if (_cc == null)
      _cc = list;
View Full Code Here

   * @param to a list of new recipients
   */
  public void addBcc(String to)
    throws IOException
  {
    StringCharCursor cursor = new StringCharCursor(to);

    ArrayList<MailtoPath.Recipient> list = MailtoPath.parseAddressList(cursor);

    if (_bcc == null)
      _bcc = list;
View Full Code Here

    String cnonce = null;
    String nc = null;
    String qop = null;
    String digest = null;

    CharCursor cursor = new StringCharCursor(value);

    String key = scanKey(cursor);

    if (! "Digest".equalsIgnoreCase(key))
      return null;
View Full Code Here

    }

    CharBuffer cb = _cb;
    while (headers.hasMoreElements()) {
      String header = headers.nextElement();
      StringCharCursor cursor = new StringCharCursor(header);

      while (cursor.current() != CharacterIterator.DONE) {
        char ch;
        for (; Character.isWhitespace(cursor.current()); cursor.next()) {
        }

        cb.clear();
        for (; (ch = cursor.current()) >= 'a' && ch <= 'z' ||
               ch >= 'A' && ch <= 'Z' ||
               ch >= '0' && ch <= '0';
             cursor.next()) {
          cb.append(cursor.current());
        }

        String language = cb.toString();
        String country = "";
        if (cursor.current() == '_' || cursor.current() == '-') {
          cb.clear();
          for (cursor.next();
               (ch = cursor.current()) >= 'a' && ch <= 'z' ||
               ch >= 'A' && ch <= 'Z' ||
               ch >= '0' && ch <= '9';
               cursor.next()) {
            cb.append(cursor.current());
          }
          country = cb.toString();
        }

        if (language.length() > 0) {
          Locale locale = new Locale(language, country);
          _locales.add(locale);
        }

        for (;
             cursor.current() != CharacterIterator.DONE && cursor.current() != ',';
             cursor.next()) {
        }
        cursor.next();
      }
    }

    if (_locales.size() == 0)
      _locales.add(Locale.getDefault());
View Full Code Here

                               String query,
                               String javaEncoding,
                               boolean isTop)
    throws IOException
  {
    CharCursor is = new StringCharCursor(query);

    ByteToChar converter = _converter;
    try {
      converter.setEncoding(javaEncoding);
    } catch (UnsupportedEncodingException e) {
      log.log(Level.FINE, e.toString(), e);
    }

    int ch = is.current();
    while (ch != CharacterIterator.DONE) {
      for (; Character.isWhitespace((char) ch) || ch == '&'; ch = is.next()) {
      }

      converter.clear();
      for (; ch != CharacterIterator.DONE && ch != '=' && ch != '&'; ch = is.next())
        readChar(converter, is, ch, isTop);

      String key = converter.getConvertedString();

      converter.clear();
      if (ch == '=')
        ch = is.next();
      for (; ch != CharacterIterator.DONE && ch != '&'; ch = is.next())
        readChar(converter, is, ch, isTop);
     
      String value = converter.getConvertedString();

      if (log.isLoggable(Level.FINE))
View Full Code Here

   * Parse the scheme for the recipient and the attributes.
   */
  protected Path schemeWalk(String userPath, Map<String,Object> attributes,
                            String uri, int offset)
  {
    StringCharCursor cursor = new StringCharCursor(uri, offset);
   
    ArrayList<Recipient> to = parseAddressList(cursor);
    HashMap<String,Object> attr = new HashMap<String,Object>();

    CharBuffer buf = new CharBuffer();
    if (cursor.current() == '?') {
      char ch = cursor.next();
      while (isUserChar(ch)) {
        buf.clear();
        for (; isUserChar(ch); ch = cursor.next())
          buf.append(ch);
        String key = buf.toString();

        if (ch != '=')
          throw new RuntimeException("broken attribute at: " + ch);
        buf.clear();
        for (ch = cursor.next();
             ch != cursor.DONE && ch != '&';
             ch = cursor.next())
          buf.append(ch);

        attr.put(key, buf.toString());

        while (ch == '&' || ch == ' ' || ch == '\t')
          ch = cursor.next();
      }
    }

    return new MailtoPath(this, userPath, to, attr);
  }
View Full Code Here

TOP

Related Classes of com.caucho.util.StringCharCursor

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.