今ひとつ解らない問題があります。Iframe のパスを維持する変数「private List pathContainer」を持つ Iframe としてクラスがあります。
与えられたコードは、
public class IFrame implements HtmlElement {
private WebElement elem;
private String xpath;
private boolean selected;
private String parentClass;
private boolean isProcessed=false;
private boolean isIframeContent=false;
private List <String> pathContainer;
public IFrame(WebElement elem) {
this.elem = elem;
pathContainer=new ArrayList<String>();
}
親 iframe のパス リストをサブ iframe に渡して、そのリストに含めます。しかし、subIframe パス リストを変更すると、親 Iframe パス リストも変更されます。与えられた関数のコードは、
public void LoadIFrameNodes(List<String> parentPath){
IFrame iframe=new IFrame(e);
List <String> tempPath=new ArrayList<String>();
iframe.setPathContainer(parentPath); //assigning parent path in subIframe list
tempPath=iframe.getPathContainer();
tempPath.add(iframe.getXpath()); // add another value to subIframe
iframe.setPathContainer(tempPath); //setting the changed list as the subIframe
}
subIframe が新しい値で設定されると、渡されたparentPath リストも新しい値で変更されます。渡されたリストは更新されません。どこが間違っていたのか教えてください。