Classwo***ng工具箱: 分析泛型数据结构 - 编程入门网
作者 佚名技术
来源 NET编程
浏览
发布时间 2012-06-14
TypeDescription[] types) {
// first check for direct match on substituted signature
TypeDescription desc = (TypeDescription)m_typeMap.get(sig);
if (desc == null) {
// no direct match, first handle array
if (sig.charAt(0) == ''['') {
desc = new ArrayClassDescriptor(sig,
getSignatureInstance(sig.substring(1), types));
} else {
...
}
}
return desc;
}
/**
* Get description for signature with type mapping.
*
* @param sig field signature for type variables
* @param tmap type mapping for variables
* @return type description
*/
public TypeDescription getMappedSignatureInstance(String sig,
HashMap<String,TypeDescription> tmap) {
...
}
...
/**
* Descriptor for primitive "class." There''s really nothing to record for a
* primitive type except the name, so that''s all this does. Because instances
* only need to be created and added to the directory at initialization, this
* is an inner class.
*/
private static class PrimitiveTypeDescription extends TypeDescription
{
private final String m_externalName;
private PrimitiveTypeDescription(String iname, String xname) {
super(iname);
m_externalName = xname;
}
public boolean isPrimitive() {
return true;
}
public String toString() {
return m_externalName;
}
}
/**
* Descriptor for array class. This is just a wrapper around the descriptor
* for the item type, with the same field list used for all arrays.
*/
private class ArrayClassDescriptor extends TypeDescription
{
private final TypeDescription m_itemType;
protected ArrayClassDescriptor(String name, TypeDescription item) {
super(name);
m_itemType = item;
}
public boolean isArray() {
return true;
}
public TypeDescription getArrayItemType() {
return m_itemType;
}
public FieldDescription[] getFields() {
return m_arrayFields;
}
public String toString() {
return m_itemType + "[]";
}
}
}
Classworking工具箱: 分析泛型数据结构(3)时间:2011-10-16 IBM Dennis Sosnoski清单 2 的代码使用内部的 PrimitiveTypeDescription 和 ArrayTypeDescription 类直接处理原生类 型和数组类型。原生类型在创建的时候就被添加到实际的目录(m_typeMap 哈希映射把类型名称或字段签 名与对应的类型描述关联起来),而数组类型则在被看到的时候添加到目录中。getTypeIns |
凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢! |
你可能对下面的文章感兴趣
关于Classworking工具箱: 分析泛型数据结构 - 编程入门网的所有评论