Package com.caucho.quercus.env

Examples of com.caucho.quercus.env.StringValue


  public static Value str_rot13(StringValue string)
  {
    if (string == null)
      return NullValue.NULL;

    StringValue sb = string.createStringBuilder(string.length());

    int len = string.length();
    for (int i = 0; i < len; i++) {
      char ch = string.charAt(i);

      if ('a' <= ch && ch <= 'z') {
        int off = ch - 'a';

        sb.append((char) ('a' + (off + 13) % 26));
      }
      else if ('A' <= ch && ch <= 'Z') {
        int off = ch - 'A';

        sb.append((char) ('A' + (off + 13) % 26));
      }
      else {
        sb.append(ch);
      }
    }

    return sb;
  }
View Full Code Here


        if (!isBetweenWords) {
          // finished a word
          isBetweenWords = true;

          if (format > 0) {
            StringValue word = string.substring(lastWordStart, i);

            if (format == 1)
              resultArray.append(word);
            else if (format == 2)
              resultArray.put(LongValue.create(lastWordStart), word);
View Full Code Here

   * @param allowTags the allowable tags
   */
  public static StringValue strip_tags(StringValue string,
                                       @Optional Value allowTags)
  {
    StringValue result = string.createStringBuilder(string.length());

    HashSet<StringValue> allowedTagMap = null;

    if (! allowTags.isDefault())
      allowedTagMap = getAllowedTags(allowTags.toStringValue());

    int len = string.length();

    for (int i = 0; i < len; i++) {
      char ch = string.charAt(i);

      if (i + 1 >= len || ch != '<') {
        result.append(ch);
        continue;
      }

      ch = string.charAt(i + 1);

      if (Character.isWhitespace(ch)) {
        i++;

        result.append('<');
        result.append(ch);
        continue;
      }

      int tagNameStart = i + 1;

      if (ch == '/')
        tagNameStart++;

      int j = tagNameStart;

      while (j < len
             && (ch = string.charAt(j)) != '>'
             // && ch != '/'
             && ! Character.isWhitespace(ch)) {
        j++;
      }

      StringValue tagName = string.substring(tagNameStart, j);
      int tagEnd = 0;

      if (allowedTagMap != null && allowedTagMap.contains(tagName)) {
        result.append(string, i, Math.min(j + 1, len));
      }
View Full Code Here

   */
  public static Value stripos(Env env, StringValue haystack,
                              Value needleV,
                              @Optional int offset)
  {
    StringValue needle;
    int len = haystack.length();

    if (len < offset) {
      env.warning(L.l("offset cannot exceed string length"));
      return BooleanValue.FALSE;
    }

    if (needleV instanceof StringValue)
      needle = (StringValue) needleV;
    else
      needle = StringValue.create((char) needleV.toInt());

    haystack = haystack.toLowerCase();
    needle = needle.toLowerCase();

    int pos = haystack.indexOf(needle, offset);

    if (pos < 0)
      return BooleanValue.FALSE;
View Full Code Here

   *
   * @param string the string to clean
   */
  public static StringValue stripslashes(StringValue string)
  {
    StringValue sb = string.createStringBuilder();
    int len = string.length();

    for (int i = 0; i < len; i++) {
      char ch = string.charAt(i);

      if (ch == '\\') {
        if (i + 1 < len) {
          char ch2 = string.charAt(i + 1);
          if (ch2 == '0') {
            ch2 = 0x0;
          }
          sb.append(ch2);
          i++;
        }
      }
      else
        sb.append(ch);
    }

    return sb;
  }
View Full Code Here

      char lower = Character.toLowerCase((char) needleV.toLong());

      needleLower = String.valueOf(lower);
    }

    StringValue haystackLower = haystack.toLowerCase();

    int i = haystackLower.indexOf(needleLower);

    if (i >= 0)
      return haystack.substring(i);
    else
      return BooleanValue.FALSE;
View Full Code Here

  public static Value strpos(Env env,
                             StringValue haystack,
                             Value needleV,
                             @Optional int offset)
  {
    StringValue needle;
   
    if (offset > haystack.length()) {
      env.warning(L.l("offset cannot exceed string length"));
     
      return BooleanValue.FALSE;
View Full Code Here

   * Reverses a string.
   *
   */
  public static Value strrev(StringValue string)
  {
    StringValue sb = string.createStringBuilder(string.length());

    for (int i = string.length() - 1; i >= 0; i--) {
      sb.append(string.charAt(i));
    }

    return sb;
  }
View Full Code Here

  public static Value strrpos(Env env,
                              StringValue haystack,
                              Value needleV,
                              @Optional Value offsetV)
  {
    StringValue needle;

    if (needleV instanceof StringValue)
      needle = needleV.toStringValue();
    else
      needle = StringValue.create((char) needleV.toInt());
View Full Code Here

   */
  public static Value strtok(Env env,
                             StringValue string1,
                             @Optional Value string2)
  {
    StringValue string;
    StringValue characters;
    int offset;
    //StringValue savedToken = null;

    if (string2.isNull()) {
      StringValue savedString = (StringValue) env
          .getSpecialValue("caucho.strtok_string");
      Integer savedOffset = (Integer) env
          .getSpecialValue("caucho.strtok_offset");
      //savedToken = (StringValue) env.getSpecialValue("caucho.strtok_token");

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.