0

The queryMe method returns an ArrayIterator<Me>. The queryYou method returns an ArrayIterator<You>.

public ArrayIterator<Object> query(String table, String field, String criterion)
{
    ArrayIterator<Object> result = null;

    if (table.equals("MyTable")
    {
        result = MyTable.queryMe(field, criterion);
    }
    else if (table.equals("YourTable")
    {
        result = YourTable.queryYou(field, criterion);
    }

    return result;
}

I'm getting an error that says

ArrayIterator<Me> and ArrayIterator<Java.lang.object> are incompatible types.

Any suggestions?


Entire Piped Email not coming through

I'm having trouble with piping emails to a PHP script. It seems as if the entire email isn't coming through. This is the sort of response I get:

From brian@myemailaddress.com Sun Apr 14 13:12:53 2013
Received: from mailserver.google.com ([GOOGLE.IP.ADDRESS]:41509)
        by myhost.server.com with esmtps (TLSv1:RC4-SHA:128)
        (Exim 4.80)
        (envelope-from <brian@myemailaddress.com>)
        id THE-EMAIL-ID
        for brian@mysub.domain.com; Sun, 14 Apr 2013 13:12:53 -0400
Received: by mailserver.google.com with SMTP id somesmtp.id
        for <brian@mysub.domain.com>; Sun, 14 Apr 2013 10:12:51 -0700 (PDT)
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=google.com; s=20120113;
        h=x-received:mime-version:x-originating-ip:from:date:message-id
         :subject:to:content-type:x-gm-message-state;
        bh=rPONCz8eaLlxJpumTQNPIEKBlWcbg53KdugbKjulvj4=;
        b=Kr7ZpXKTpXDCoQHmI93Ep+CSv8BY4xT2Pgh3eJeRsz5Y0iAjomGdBQDwKMQ/myk4hz
         dkReoFPGAqE3KsRo601JXzgDrvmu9oRDC3UpbwHvMUvbI+U1qjC2rUsp1fmaeohpc99T
         tPVMhO9WBBqthUP4TCv/T50/popu771Mydj0YXWbEuRtViyllzTa1M1kO3DhqLC+/bA2
         ED2J3wBXp47xRVjkoUNUOzyi5pUIsryDRUh9gxdSQtAGjqAdTpTwQXSX0MAdSK+PYc8Y
         oB/5Sm09um8/id4d4YHUBZMbIZv0+L0GR0ZbIfa42l7+WzvKMjijNw7QsA/KDXMaYL5W
         CwBQ==
X-Received: by IP.ADDR.ESS with SMTP id some.long.id; Sun,
 14 Apr 2013 10:12:51 -0700 (PDT)
MIME-Version: 1.0
Received: by IP.ADDR.ESS with HTTP; Sun, 14 Apr 2013 10:12:31 -0700 (PDT)
X-Originating-IP: [MY.IP.ADDRESS]
From: Brian D. <brian@myemailaddress.com>
Date: Sun, 14 Apr 2013 12:12:31 -0500
Message-ID: <CAOb+JoxnfiaHFSG6RyQPtnmeS526JPMO4krsS96wc3FGMKWOiA@mail.gmail.com>
Subject: New Task.
To: brian@wmysub.domain.com
Content-Type: multipart/alternative; boundary=001a11c30f960b290d04ea583f19
X-Gm-Message-State: AKoCoQnquQFvVi0CYGF4sdhK0Cn2swVezCK1Yg5uXKhxBmnppYCfVX/2+EK37dX1iyV4pxBOM1cJ

The way this is being piped is using cPanel's Default Address feature to work as a catch-all for a specific domain. This is the command:

|/usr/local/bin/php /home/account/path/to/my/script.php

I actually had to manually modify this script in the /etc/valiases file for the domain because it required I use hashbang/shebang at the top of my script and that was causing errors, but this (for the most part) works, but the entire message isn't showing up. Here is the code I'm using to read the message:

$email = '';
$stream = fopen('php://stdin', 'r');
$i = 0;
while($line = stream_get_line($stream, 65535, PHP_EOL)) {
$email .= $line;
    $i++;
}
fclose($stream);

Any ideas why I'm not getting the body of the email?

4

3 に答える 3

2

ArrayIterator<Me>実際にはのサブタイプではないため、キャストできませんArrayIterator<Java.lang.object>。これらの 2 つのタイプは関連していません。

詳細については、こちらをご覧ください

于 2013-04-14T17:33:00.887 に答える
0

これがあなたが求めているハックです。最初に生の ArrayIterator にキャストし、次に ArrayIterator<Me> にキャストします。

ArrayIterator<Me> meIter = (ArrayIterator) 結果。

より良い方法は、ArrayIterator<Me> を返すようにメソッドを変更し、結果を同じに変更することです。

***あなたの更新を見ました。メソッドがさまざまな型の ArrayIterators を返そうとしているように見えるため、 <Object> の戻り値の型です。

// Would be nice if the 2 types shared a common super type.   
public ArrayIterator<Object> query(String table, String field, String criterion)
{
    // WARNING, this is a raw generic type, and provides no type safety
    ArrayIterator result = null;

    if (table.equals("MyTable")
    {
        result = MyTable.queryMe(field, criterion);
    }
    else if (table.equals("YourTable")
    {
        result = YourTable.queryYou(field, criterion);
    }
    return (ArrayIterator<Object>) result.
}
于 2013-04-14T17:41:32.070 に答える
0

ArrayIterator<Me>に変換することはできません。関数ArrayIterator<Object>の戻り値の型を変更する必要がありqueryMeますが、イテレータが常に型を持っている場合は、プログラム全体でMe使用することをお勧めしますArrayIterator<Me>

于 2013-04-14T17:35:06.067 に答える