📄 idlinterface.java
字号:
package com.corba.mnq.tool.idl;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Vector;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.corba.mnq.tool.BNFTool;
import com.corba.mnq.tool.LoggerTool;
import com.corba.mnq.tool.Warehouse;
import com.corba.mnq.tool.idl.type.CTInterface;
import com.corba.mnq.tool.idl.type.TypeBase;
public class IdlInterface extends IdlBase {
public IdlInterface() {
super();
// TODO Auto-generated constructor stub
}
/** used for java.util.logging */
private static final Logger LOG = Logger.getLogger(IdlInterface.class
.getName());
// This interface is extended from:
private List parent = new Vector();
// inheritent content of this interface
public String inherit = "";
// associated IOR String
private String ior;
// created servants
public Map servants = new Hashtable();
private boolean getParents = false;
public List getParent() {
parseInherit();
return parent;
}
public String createTag() {
if(servants.size() == 0) {
return cName.replaceAll("::", "_");
}
return cName.replaceAll("::", "_") + "_" + System.currentTimeMillis();
}
private void parseInherit() {
if (getParents)
return;
if (inherit.equalsIgnoreCase("")) {
getParents = true;
return;
}
String scoped_name = BNFTool.scoped_name;
Pattern pType = Pattern.compile(scoped_name, Pattern.DOTALL
+ Pattern.MULTILINE);
Matcher mType = pType.matcher(inherit);
while (mType.find()) {
String t = mType.group(0).replaceAll("\\s+", "").replaceAll("::_",
"::");
String tmp;
Object node = null;
if (t.indexOf("::") < 0) {
String val;
val = cName;
do {
val = val.substring(0, val.lastIndexOf("::"));
tmp = val + "::" + t;
node = Warehouse.cname2node
.get(tmp.replaceAll("::_", "::"));
if (node != null)
break;
if (val.equalsIgnoreCase(""))
break;
} while (true);
} else {
if (t.startsWith("::")) {
tmp = t;
} else {
tmp = "::" + t;
}
node = Warehouse.cname2node.get(tmp.replaceAll("::_", "::"));
}
if (node == null) {
System.out.println(this.content + "\t" + t);
continue;
}
parent.add(((IdlBase) node).cName);
}
getParents = true;
}
// ior getter
public String getior() {
return ior;
}
// ior setter
public void setior(String iorstr) {
ior = iorstr;
// if (!parent.equalsIgnoreCase("")) {
// Object o = Warehouse.cname2node.get(parent.replaceAll("::_", "::"));
// if (o != null) {
// ((IdlInterface) o).setior(iorstr);
// }
// }
}
public void recurContent() {
String res = BNFTool.findInterface(val, sibling, cName, (IdlFile) fn);
res = BNFTool.findAttrs(res, sibling, cName, (IdlFile) fn);
res = BNFTool.findTypes(res, sibling, cName, (IdlFile) fn);
res = BNFTool.findExceptions(res, sibling, cName, (IdlFile) fn);
res = BNFTool.findOperations(res, sibling, cName, (IdlFile) fn);
res = BNFTool.findConst(res, sibling, cName, (IdlFile) fn);
// System.out.println(cName + res);
LoggerTool.checkRemainedContent(LOG, res, this);
for (int i = 0; i < sibling.size(); i++) {
IdlBase sib = (IdlBase) sibling.get(i);
sib.recurContent();
}
prefix = getPrefix();
}
public String getIconName() {
return "interface.gif";
}
private List ops = new Vector();
public List getOperations() {
if (!getParentsOps) {
firstgetOperations();
getParentsOps = true;
}
return ops;
}
private boolean getParentsOps = false;
private void addParentOperations() {
parseInherit();
int len = parent.size();
if (len > 0) {
for (int j = 0; j < len; j++) {
String par = (String) parent.get(j);
Object o = Warehouse.cname2node
.get(par.replaceAll("::_", "::"));
if (o != null) {
List out = ((IdlInterface) o).getOperations();
for (int i = 0; i < out.size(); i++) {
IdlOperation on = (IdlOperation) ((IdlOperation) out
.get(i)).cloneNode();
on.in = this;
sibling.add(on);
}
}
}
}
}
/**
* @param out
* List type
*/
public void firstgetOperations() {
addParentOperations();
// add its own defined operations in the output list
for (int i = 0; i < sibling.size(); i++) {
IdlBase n = (IdlBase) sibling.get(i);
if (n instanceof IdlOperation) {
ops.add(n);
}
}
}
public TypeBase toType() {
CTInterface it = new CTInterface();
it.dn = cName;
it.rdn = sName;
it.id = id();
return it;
}
/**
* @param args
*/
public static void main_(String[] args) {
// TODO Auto-generated method stub
}
}
/* EOF */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -