Пример #1
0
 public URI getFullURI(ITypeBinding typeBinding) {
   // The URIs for primitive types are cached and indexed by their one character key
   // representation.
   //
   if (typeBinding.isPrimitive()) {
     return PRIMITIVE_URIS[typeBinding.getKey().charAt(0) - 'B'];
   }
   if (typeBinding.isClass()
       || typeBinding.isInterface()
       || typeBinding.isAnnotation()
       || typeBinding.isEnum()) {
     ITypeBinding declaringClass = typeBinding.getDeclaringClass();
     if (declaringClass == null) {
       // This special case handling for common case of top level types that avoids creating a
       // builder.
       //
       String qualifiedName = typeBinding.getErasure().getQualifiedName();
       URI uri = COMMON_URIS.get(qualifiedName);
       if (uri != null) {
         return uri;
       }
       uri = OBJECTS_URI.appendSegment(qualifiedName);
       return uri.appendFragment(uri.lastSegment());
     }
     SegmentSequence.Builder builder = SegmentSequence.newBuilder("");
     URI uri = getFullURI(declaringClass, builder);
     builder.append("$");
     builder.append(typeBinding.getName());
     return uri.appendFragment(builder.toString());
   }
   SegmentSequence.Builder builder = SegmentSequence.newBuilder("");
   URI uri = getFullURI(typeBinding, builder);
   return uri.appendFragment(builder.toString());
 }
Пример #2
0
 /** @since 2.4 */
 protected URI getFullURI(ITypeBinding typeBinding, SegmentSequence.Builder builder) {
   if (typeBinding.isPrimitive()) {
     builder.append(PRIMITIVE_URIS[typeBinding.getKey().charAt(0) - 'B'].fragment());
     return PRIMITIVES_URI;
   }
   if (typeBinding.isClass()
       || typeBinding.isInterface()
       || typeBinding.isAnnotation()
       || typeBinding.isEnum()) {
     ITypeBinding declaringClass = typeBinding.getDeclaringClass();
     if (declaringClass != null) {
       URI uri = getFullURI(declaringClass, builder);
       builder.append("$");
       builder.append(typeBinding.getName());
       return uri;
     }
     String qualifiedName = typeBinding.getErasure().getQualifiedName();
     URI uri = COMMON_URIS.get(qualifiedName);
     if (uri == null) {
       uri = OBJECTS_URI.appendSegment(qualifiedName);
     }
     builder.append(uri.lastSegment());
     return uri;
   }
   if (typeBinding.isArray()) {
     URI uri = getFullURI(typeBinding.getComponentType(), builder);
     builder.append("[]");
     return uri;
   }
   if (typeBinding.isTypeVariable()) {
     ITypeBinding declaringClass = typeBinding.getDeclaringClass();
     if (declaringClass != null) {
       URI uri = getFullURI(declaringClass, builder);
       builder.append("/");
       builder.append(typeBinding.getName());
       return uri;
     }
     IMethodBinding declaringMethod = typeBinding.getDeclaringMethod();
     URI uri = getFullURI(declaringMethod.getDeclaringClass(), builder);
     builder.append(".");
     builder.append(declaringMethod.getName());
     builder.append("(");
     ITypeBinding[] parameterTypes = declaringMethod.getParameterTypes();
     for (int i = 0; i < parameterTypes.length; i++) {
       if (i != 0) {
         builder.append(",");
       }
       getQualifiedName(parameterTypes[i], builder);
     }
     builder.append(")");
     builder.append("/");
     builder.append(typeBinding.getName());
     return uri;
   }
   throw new IllegalStateException("Unexpected type: " + typeBinding);
 }
Пример #3
0
 public URI createResourceURIForFQN(String fqn) {
   return OBJECTS_URI.appendSegment(fqn);
 }