interfaceport.java
来自「plugin for eclipse」· Java 代码 · 共 111 行
JAVA
111 行
/*
* Created on Jun 9, 2005
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package isis.anp.nesc.ot;
import isis.anp.common.ObjectTreeBuilderContext;
import java.util.Iterator;
import java.util.LinkedHashMap;
/**
* @author sallai
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class InterfacePort extends Port {
LinkedHashMap functionPorts = new LinkedHashMap();
Interface nesCInterface;
ObjectTreeBuilderContext ctx;
public InterfacePort(ObjectTreeBuilderContext ctx) {
this.ctx = ctx;
}
public void outline(Outline o) {
o.addTabs();
if (direction == Port.Direction.USES) {
o.append("uses interface ");
} else {
o.append("provides interface ");
}
o.append(getName());
o.append(";");
// interface contents
//o.incTabs();
// nesCInterface.outline(o);
//o.decTabs();
}
/* (non-Javadoc)
* @see parser.nesc.ot.Port#getPortName()
*/
public String getPortName() {
// TODO Auto-generated method stub
return getName();
}
/**
* @return Returns the nesCInterface.
*/
public Interface getInterface() {
return nesCInterface;
}
/**
* @param nesCInterface The nesCInterface to set.
*/
public void setInterface(Interface nesCInterface) {
this.nesCInterface = nesCInterface;
if(nesCInterface==null) {
System.out.println("InterfacePort.setInterface: Interface is null");
return;
}
if(nesCInterface.getFunctionDeclarations()!=null) {
// populate function port list
Iterator i = nesCInterface.getFunctionDeclarations().iterator();
while (i.hasNext()) {
FunctionDeclaration d = (FunctionDeclaration) i.next();
FunctionPort p = new FunctionPort(ctx);
p.setDeclaration(d);
// inherit the interface port's properties
p.setDirection(this.direction);
p.setComponent(this.getComponent());
p.setParameterTypeList(this.getParameterTypeList());
functionPorts.put(p.getName(), p);
}
}
}
public String getTypeString() {
return this.getInterface()==null ? null : this.getInterface().getName();
}
public void addConnection(Connection c) {
super.addConnection(c);
Iterator i = functionPorts.values().iterator();
while (i.hasNext()) {
FunctionPort p = (FunctionPort) i.next();
p.addConnection(c);
}
}
/**
* @param string
* @return
*/
public FunctionPort getFunctionPortByName(String pn) {
return (FunctionPort)functionPorts.get(pn);
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?