Package com.caucho.util

Examples of com.caucho.util.CharSegment


    _headerKeys = new CharSegment[_headerCapacity];
    _headerValues = new CharSegment[_headerCapacity];
   
    for (int i = 0; i < _headerCapacity; i++) {
      _headerKeys[i] = new CharSegment();
      _headerValues[i] = new CharSegment();
    }
  }
View Full Code Here


   * Returns the header.
   */
  public String getMethod()
  {
    if (_methodString == null) {
      CharSegment cb = getMethodBuffer();
      if (cb.length() == 0) {
        _methodString = "GET";
        return _methodString;
      }

      switch (cb.charAt(0)) {
      case 'G':
        _methodString = cb.equals(_getCb) ? "GET" : cb.toString();
        break;

      case 'H':
        _methodString = cb.equals(_headCb) ? "HEAD" : cb.toString();
        break;

      case 'P':
        _methodString = cb.equals(_postCb) ? "POST" : cb.toString();
        break;

      default:
        _methodString = cb.toString();
      }
    }

    return _methodString;

View Full Code Here

  /**
   * Returns the header.
   */
  public String getHeader(String key)
  {
    CharSegment buf = getHeaderBuffer(key);
    if (buf != null)
      return buf.toString();
    else
      return null;
  }
View Full Code Here

   * Returns the header.
   */
  public String getMethod()
  {
    if (_methodString == null) {
      CharSegment cb = getMethodBuffer();
      if (cb.length() == 0) {
        _methodString = "GET";
        return _methodString;
      }

      /*
      switch (cb.charAt(0)) {
      case 'G':
        _methodString = cb.equals(_getCb) ? "GET" : cb.toString();
        break;

      case 'H':
        _methodString = cb.equals(_headCb) ? "HEAD" : cb.toString();
        break;

      case 'P':
        _methodString = cb.equals(_postCb) ? "POST" : cb.toString();
        break;

      default:
        _methodString = cb.toString();
      }
      */

      _methodString = cb.toString();
    }

    return _methodString;

  }
View Full Code Here

  /**
   * Returns the header.
   */
  public String getHeader(String key)
  {
    CharSegment buf = getHeaderBuffer(key);
    if (buf != null)
      return buf.toString();
    else
      return null;
  }
View Full Code Here

  {
    char []keyBuf = _headerBuffer;
    CharSegment []headerKeys = _headerKeys;

    for (int i = _headerSize - 1; i >= 0; i--) {
      CharSegment key = headerKeys[i];

      if (key.length() != length)
        continue;

      int offset = key.getOffset();
      int j;
      for (j = length - 1; j >= 0; j--) {
        char a = testBuf[j];
        char b = keyBuf[offset + j];
        if (a == b)
View Full Code Here

    int length = key.length();

    char []keyBuf = _headerBuffer;

    for (; i < size; i++) {
      CharSegment header = _headerKeys[i];

      if (header.length() != length)
        continue;

      int offset = header.getOffset();

      int j;
      for (j = 0; j < length; j++) {
        char a = key.charAt(j);
        char b = keyBuf[offset + j];
View Full Code Here

  public Enumeration getHeaderNames()
  {
    ArrayList<String> names = new ArrayList<String>();

    for (int i = 0; i < _headerSize; i++) {
      CharSegment name = _headerKeys[i];

      int j;
      for (j = 0; j < names.size(); j++) {
        String oldName = names.get(j);
        if (name.matches(oldName))
          break;
      }
      if (j == names.size())
        names.add(j, name.toString());
    }

    return Collections.enumeration(names);
  }
View Full Code Here

        return;
      }
      break;
    }

    CharSegment headerKey = _headerKeys[_headerSize];
    CharSegment headerValue = _headerValues[_headerSize];
    char []headerBuffer = _headerBuffer;

    if (keyLength > 5
        && ch == 'H'
        && key[1] == 'T'
        && key[2] == 'T'
        && key[3] == 'P'
        && key[4] == '_') {

      int headerOffset = _headerOffset;

      for (int i = 5; i < keyLength; i++) {
        ch = (char) (key[i] & 0xff);

        if (ch == '_')
          ch = '-';

        headerBuffer[headerOffset++] = (char) ch;
      }

      headerKey.init(headerBuffer, _headerOffset, keyLength - 5);

      is.readAll(headerBuffer, headerOffset, valueLength);

      headerValue.init(headerBuffer, headerOffset, valueLength);

      _headerOffset = headerOffset + valueLength;

      _headerSize++;
View Full Code Here

    */

    CharSequence rawHost;
    if (host == null && (rawHost = getHost()) != null) {
      if (rawHost instanceof CharSegment) {
        CharSegment cb = (CharSegment) rawHost;

        char []buffer = cb.getBuffer();
        int offset = cb.getOffset();
        int length = cb.getLength();

        for (int i = length - 1; i >= 0; i--) {
          char ch = buffer[i + offset];

          if ('A' <= ch && ch <= 'Z')
View Full Code Here

TOP

Related Classes of com.caucho.util.CharSegment

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.