Java tutorial
/* * Created 2008/08/23 * Copyright (C) 2003-2009 Naoki Iwami (naoki@limy.org) * * This file is part of Limy Eclipse Plugin. * * Limy Eclipse Plugin is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Limy Eclipse Plugin is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with Limy Eclipse Plugin. If not, see <http://www.gnu.org/licenses/>. */ package org.limy.eclipse.qalab.outline.sequence; import java.util.ArrayList; import java.util.Collection; import org.eclipse.jdt.core.IJavaElement; import org.eclipse.jdt.core.IMember; /** * V?[PX?}\?B * @author Naoki Iwami */ public class SequenceBean { // ------------------------ Fields /** Rei */ private String containerName; /** ?o */ private String callName; /** CX^X */ private String instanceName; /** Javavf */ private IJavaElement javaElement; /** qvf */ private Collection<SequenceBean> children = new ArrayList<SequenceBean>(); // ------------------------ Constructors /** * SequenceBean CX^X?\z?B * @param instanceName CX^X * @param javaElement Javavf */ public SequenceBean(String instanceName, IJavaElement javaElement) { super(); this.javaElement = javaElement; this.callName = javaElement.getElementName(); this.instanceName = instanceName; if (javaElement instanceof IMember) { IMember member = (IMember) javaElement; this.containerName = member.getDeclaringType().getElementName(); } } /** * SequenceBean CX^X?\z?B * @param instanceName CX^X * @param javaElement Javavf * @param containerName Rei */ public SequenceBean(String instanceName, IJavaElement javaElement, String containerName) { super(); this.javaElement = javaElement; this.callName = javaElement.getElementName(); this.instanceName = instanceName; this.containerName = containerName; } /** * SequenceBean CX^X?\z?B * @param containerName Rei * @param callName ?o */ public SequenceBean(String containerName, String callName) { super(); this.callName = callName; this.containerName = containerName; } // ------------------------ Public Methods public void addChild(SequenceBean bean) { children.add(bean); } public String getResultValue() { if (callName.startsWith("get")) { return callName.substring(3, 4).toLowerCase() + callName.substring(4); } return null; } /** * wOJavavf?B * @param lastBean ??Bean * @param name ? * @return Javavf */ public IJavaElement searchElement(SequenceBean lastBean, String name) { for (SequenceBean child : getChildren()) { IJavaElement result = child.searchElement(lastBean, name); if (result != null) { return result; } } if (getCallName().equals(name)) { return javaElement; } return null; } // ------------------------ Getter/Setter Methods /** * Rei?B * @return Rei */ public String getContainerName() { return containerName; } /** * Rei??B * @param containerName Rei */ public void setContainerName(String containerName) { this.containerName = containerName; } /** * ?o?B * @return ?o */ public String getCallName() { return callName; } /** * ?o??B * @param callName ?o */ public void setCallName(String callName) { this.callName = callName; } /** * CX^X?B * @return CX^X */ public String getInstanceName() { return instanceName; } /** * Javavf?B * @return Javavf */ public IJavaElement getJavaElement() { return javaElement; } /** * qvf?B * @return qvf */ public Collection<SequenceBean> getChildren() { return children; } /** * qvf??B * @param children qvf */ public void setChildren(Collection<SequenceBean> children) { this.children = children; } }