Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.StringValue


  public PhpBinaryInput(Env env)
  {
    super(env);
   
    StringValue inputData = env.getInputData();
   
    if (inputData == null)
      inputData = env.getEmptyString();
   
    init(new ReadStream(new VfsStream(inputData.toInputStream(), null)));
  }
View Full Code Here


      Regexp regexp = _cache[(head + i) % MAX_SIZE];
     
      if (regexp == null)
        break;
      else {
        StringValue rawRegexp = regexp.getRawRegexp();
       
        if (rawRegexp == str || rawRegexp.equals(str))
          return regexp;
      }
    }
   
    Regexp regexp = RegexpModule.createRegexp(env, str);
View Full Code Here

    TempBuffer tempBuf = TempBuffer.allocate();
   
    try {
      ByteBuffer out = ByteBuffer.wrap(tempBuf.getBuffer());
     
      StringValue sb = env.createBinaryBuilder();

      while (in.hasRemaining()) {
        CoderResult coder = _encoder.encode(in, out, false);

        if (! fill(sb, in, out, coder))
View Full Code Here

  }
 
  @Override
  public StringValue encode(Env env, CharSequence str)
  {
    StringValue sb = env.createBinaryBuilder();
   
    int len = str.length();
    for (int i = 0; i < len; i++) {
      char ch = str.charAt(i);
     
      if (ch <= 0x7F) {
        sb.appendByte(ch);
        continue;
      }
     
      int code = ch;
     
     
      if (0xD800 <= ch && ch <= 0xDBFF) {
        char ch2;
       
        if (i + 1 < len
            && 0xDC00 <= (ch2 = str.charAt(i + 1)) && ch2 <= 0xDFFF) {
          i++;
         
          code = 0x10000 + ((ch - 0xD800) << 10) + (ch2 - 0xDC00);
        }
        else {
          if (_isIgnore) {
          }
          else if (_replacement != null)
            sb.append(_replacement);
          else
            return sb;
         
          continue;
        }
      }
           
      if (0x80 <= code && code <= 0x7FF) {
        sb.appendByte(0xC0 | (code >> 6));
        sb.appendByte(0x80 | (code & 0x3F));
      }
      else if (0x800 <= code && code <= 0xFFFF) {
        sb.appendByte(0xE0 | (code >> 12));
        sb.appendByte(0x80 | ((code >> 6) & 0x3F));
        sb.appendByte(0x80 | (code & 0x3F));
      }
      else {
        sb.appendByte(0xF0 | (code >> 18));
        sb.appendByte(0x80 | ((code >> 12) & 0x3F));
        sb.appendByte(0x80 | ((code >> 6) & 0x3F));
        sb.appendByte(0x80 | (code & 0x3F));
      }
    }
   
    return sb;
  }
View Full Code Here

   * @param str a string
   * @return the string escaped for SQL statements
   */
  protected StringValue realEscapeString(StringValue str)
  {
    StringValue buf = _env.createUnicodeBuilder();

    final int strLength = str.length();

    for (int i = 0; i < strLength; i++) {
      char c = str.charAt(i);

      switch (c) {
      case '\u0000':
        buf.append('\\');
        buf.append(0);
        break;
      case '\n':
        buf.append('\\');
        buf.append('n');
        break;
      case '\r':
        buf.append('\\');
        buf.append('r');
        break;
      case '\\':
        buf.append('\\');
        buf.append('\\');
        break;
      case '\'':
        buf.append('\\');
        buf.append('\'');
        break;
      case '"':
        buf.append('\\');
        buf.append('\"');
        break;
      case '\032':
        buf.append('\\');
        buf.append('Z');
        break;
      default:
        buf.append(c);
        break;
      }
    }

    return buf;
View Full Code Here

   * Reads a Binary string.
   */
  public StringValue read(int length)
    throws IOException
  {
    StringValue bb = _env.createBinaryBuilder();
    TempBuffer temp = TempBuffer.allocate();
   
    try {
      byte []buffer = temp.getBuffer();

      while (length > 0) {
        int sublen = buffer.length;

        if (length < sublen)
          sublen = length;

        sublen = read(buffer, 0, sublen);

        if (sublen > 0) {
          bb.append(buffer, 0, sublen);
          length -= sublen;
        }
        else
          break;
      }
View Full Code Here

      boolean []firstSet = _regexp._firstSet;

      if (_subject == null)
        return false;

      StringValue subject = _subject;
      int length = _subjectLength;

      /* php/4e85 XXX: optim doesn't work for greedy loops
      if (_regexp._isAnchorBegin) {
        if (_first + minLength <= length)
          length = _first + minLength;
      }
      */

      for (; _first + minLength <= length; _first++) {
        if (firstSet != null && _first < length) {
          char firstChar = subject.charAt(_first);

          if (firstChar < 256 && ! firstSet[firstChar])
            continue;
        }

View Full Code Here

  public StringValue group(Env env, int i)
  {
    int begin = getBegin(i);
    int end = getEnd(i);

    StringValue s = _subject.substring(begin, end);

    return _regexp.convertResult(env, s);
  }
View Full Code Here

      return groupNames[i];
  }

  public StringValue substring(Env env, int start)
  {
    StringValue result = _subject.substring(start);

    return _regexp.convertResult(env, result);
  }
View Full Code Here

    return _regexp.convertResult(env, result);
  }

  public StringValue substring(Env env, int start, int end)
  {
    StringValue result = _subject.substring(start, end);

    return _regexp.convertResult(env, result);
  }
View Full Code Here

TOP

Related Classes of com.caucho.quercus.env.StringValue

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.