⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 idlexcept.java

📁 UCS (Ultra Corba Simulator) is one more powerful corba client/servant simulator tool than other simi
💻 JAVA
字号:
package com.corba.mnq.tool.idl;

import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import com.corba.mnq.tool.BNFTool;
import com.corba.mnq.tool.Warehouse;
import com.corba.mnq.tool.idl.type.CTBasic;
import com.corba.mnq.tool.idl.type.CTExcept;
import com.corba.mnq.tool.idl.type.TypeBase;

public class IdlExcept extends IdlBase {

	public IdlExcept() {
		super();
		// TODO Auto-generated constructor stub
	}

	public void recurContent() {
		// TODO Auto-generated method stub

	}

	public String getIconName() {
		return "exception.gif";
	}

	// prefix in id()
	// TODO need to updated in the future, not hard coding.
	public String prefix = "3gppsa5.org";

	public String id() {
		if (prefix.equalsIgnoreCase("")) {
			return "IDL:" + cName.replaceAll("::", "/").substring(1) + ":1.0";
		}
		return "IDL:" + prefix + cName.replaceAll("::", "/") + ":1.0";
	}

	public TypeBase toType() {
		// Handle struct type
		CTExcept et = new CTExcept();
		et.dn = cName;
		et.rdn = sName;
		et.id = id();
		getExceptMems(et.mems, et.memType);

		return et;
	}

	private void getExceptMems(List m, List mt) {
		String param_type_spec = BNFTool.param_type_spec;
		// group 1--memType, group 2--memName
		String strmem = "(" + param_type_spec + ")" + "\\s+"
				+ BNFTool.identifier_catch;

		Pattern pType = Pattern.compile(strmem, Pattern.DOTALL
				+ Pattern.MULTILINE);
		Matcher mType = pType.matcher(val);
		while (mType.find()) {
			String name = mType.group(2);
			String type = mType.group(1).replaceAll("\\s+", "").replaceAll(
					"::_", "::");

			m.add(name);
			mt.add(getIncludedType(type));
		}

	}

	private TypeBase getIncludedType(String t) {

		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) {
			if (node instanceof IdlType) {
				return ((IdlType) node).toType();
			} else if (node instanceof IdlInterface) {
				return ((IdlInterface) node).toType();
			} else {
				System.out.println("Wrong in getIncludedType() of IdlType: "
						+ ((IdlBase) node).content);
			}
		}

		CTBasic bt = new CTBasic();
		if (t.equalsIgnoreCase("float"))
			bt.rdn = "float";
		else if (t.equalsIgnoreCase("double"))
			bt.rdn = "double";
		else if (t.equalsIgnoreCase("long double")
				|| t.equalsIgnoreCase("longdouble"))
			bt.rdn = "long double";
		else if (t.equalsIgnoreCase("short"))
			bt.rdn = "short";
		else if (t.equalsIgnoreCase("long"))
			bt.rdn = "long";
		else if (t.equalsIgnoreCase("long long")
				|| t.equalsIgnoreCase("longlong"))
			bt.rdn = "long long";
		else if (t.equalsIgnoreCase("unsigned short")
				|| t.equalsIgnoreCase("unsignedshort"))
			bt.rdn = "unsigned short";
		else if (t.equalsIgnoreCase("unsigned long")
				|| t.equalsIgnoreCase("unsignedlong"))
			bt.rdn = "unsigned long";
		else if (t.equalsIgnoreCase("unsigned long long")
				|| t.equalsIgnoreCase("unsignedlonglong"))
			bt.rdn = "unsigned long long";
		else if (t.equalsIgnoreCase("char"))
			bt.rdn = "char";
		else if (t.equalsIgnoreCase("wchar"))
			bt.rdn = "wchar";
		else if (t.equalsIgnoreCase("boolean"))
			bt.rdn = "boolean";
		else if (t.equalsIgnoreCase("octet"))
			bt.rdn = "octet";
		else if (t.equalsIgnoreCase("any"))
			bt.rdn = "any";
		else if (t.equalsIgnoreCase("string"))
			bt.rdn = "string";
		else if (t.equalsIgnoreCase("wstring"))
			bt.rdn = "wstring";
		else if (t.equalsIgnoreCase("void"))
			bt.rdn = "void";
		else {
			bt.rdn = "string";
		}

		return bt;
	}

}
/* EOF */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -