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


        = (Enumeration<Header>)new InternetHeaders(encodedHeaders.toInputStream()).getAllHeaders();

      while (enumeration.hasMoreElements()) {
        Header header = enumeration.nextElement();

        StringValue name
        = QuercusMimeUtility.decodeMime(env, header.getName(), charset);
        StringValue val
        = QuercusMimeUtility.decodeMime(env, header.getValue(), charset);

        Value headerName;
        if ((headerName = headers.containsKey(name)) == null) {
          headers.put(name, val);
View Full Code Here

                              String charset)
    throws UnsupportedEncodingException
  {
    String decodedStr = MimeUtility.decodeText(word.toString());
   
    StringValue str
      = env.createStringOld(MimeUtility.unfold(decodedStr));

    return str.toBinaryValue(charset);
  }
View Full Code Here

    CharSequence nameUnicode = decoder.decode(env, name);

    decoder.reset();
    String valueUnicode = decoder.decode(env, value).toString();

    StringValue sb = env.createUnicodeBuilder();
    sb.append(UnicodeUtility.encode(env, nameUnicode, outCharset));
    sb.append(':');
    sb.append(' ');

    String word = encodeMimeWord(valueUnicode.toString(),
                                 outCharset,
                                 scheme,
                                 lineBreakChars,
                                 lineLength);

    sb.append(MimeUtility.fold(sb.length(), word));

    return sb;
  }
View Full Code Here

      if (to == null || to.equals(""))
        to = headers.get("to");
     
      Properties props = new Properties();
     
      StringValue host = env.getIni("SMTP");
      if (host != null && ! host.toString().equals(""))
        props.put("mail.smtp.host", host.toString());
      else if (System.getProperty("mail.smtp.host") != null)
        props.put("mail.smtp.host", System.getProperty("mail.smtp.host"));
     
      StringValue port = env.getIni("smtp_port");
      if (port != null && ! port.toString().equals(""))
        props.put("mail.smtp.port", port.toString());
      else if (System.getProperty("mail.smtp.port") != null)
        props.put("mail.smtp.port", System.getProperty("mail.smtp.port"));

      if (System.getProperty("mail.smtp.class") != null)
        props.put("mail.smtp.class", System.getProperty("mail.smtp.class"));

      StringValue user = null;

      if (headers.get("from") != null)
        user = env.createStringOld(headers.get("from"));

      if (user == null)
        user = env.getIni("sendmail_from");
     
      if (user != null && ! user.toString().equals("")) {
        String userString = user.toString();

        /*
        int p = userString.indexOf('<');
        int q = userString.indexOf('>');
       
View Full Code Here

    return true;
  }

  static public StringValue pgRealEscapeString(StringValue str)
  {
    StringValue buf = str.createStringBuilder(str.length());

    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('\u0000');
          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 '"':
          // pg_escape_string does nothing about it.
          // 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 line from the BinaryInput, returning null on EOF.
   */
  public StringValue readLine(Env env, BinaryInput input, long length)
    throws IOException
  {
    StringValue sb = env.createBinaryBuilder();

    int ch;

    for (; length > 0 && (ch = input.read()) >= 0; length--) {
      // php/161[pq] newlines
      if (ch == '\n') {
        sb.appendByte((byte) ch);

        if (_isMacLineEnding == null)
          _isMacLineEnding = false;

        if (!_isMacLineEnding)
          break;
      }
      else if (ch == '\r') {
        sb.appendByte((byte) '\r');

        int ch2 = input.read();

        if (ch2 == '\n') {
          if (_isMacLineEnding == null)
            _isMacLineEnding = false;

          if (_isMacLineEnding) {
            input.unread();
            break;
          }
          else {
            sb.appendByte((byte) '\n');
            break;
          }
        }
        else {
          input.unread();

          if (_isMacLineEnding == null)
            _isMacLineEnding = true;

          if (_isMacLineEnding)
            return sb;
        }

      }
      else
        sb.appendByte((byte) ch);
    }

    if (sb.length() == 0)
      return null;
    else
      return sb;
   
  }
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

   */
  @Override
  public StringValue readLine(Env env)
    throws IOException
  {
    StringValue sb = env.createStringBuilder();

    int ch;

    while ((ch = read()) >= 0) {
      sb.append((char) ch);

      if (ch == '\n')
        return sb;
      // XXX: issues with mac
    }

    if (sb.length() > 0)
      return sb;
    else
      return null;
  }
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

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.