Ejemplo n.º 1
0
 private boolean acceptableType(String rtype) {
   TypeRef ref = analyzer.getTypeRefFromFQN(rtype);
   try {
     Clazz returnType = analyzer.findClass(ref);
     if (returnType.isEnum()) {
       return true;
     }
     // TODO check this is true for interfaces and annotations
     if (!returnType.isAbstract()
         || (returnType.isInterface() && options.contains(Options.nested))) {
       return true;
     }
     if (!returnType.isInterface()) {
       analyzer.error("Abstract classes not allowed as interface method return values: %s", rtype);
     } else {
       analyzer.error("Nested metatype only allowed with option: nested type %s", rtype);
     }
     return false;
   } catch (Exception e) {
     analyzer.error(
         "could not examine class for return type %s, exception message: %s",
         rtype, e.getMessage());
     return false;
   }
 }
Ejemplo n.º 2
0
 private void doOCD(ObjectClassDefinition o, Annotation annotation) {
   if (topLevel) {
     if (clazz.isInterface()) {
       if (ocd == null) ocd = new OCDDef(finder);
       ocd.id = o.id() == null ? name.getFQN() : o.id();
       ocd.name = o.name() == null ? space(ocd.id) : o.name();
       ocd.description = o.description() == null ? "" : o.description();
       ocd.localization =
           o.localization() == null ? "OSGI-INF/l10n/" + name.getFQN() : o.localization();
       if (annotation.get("pid") != null) {
         String[] pids = o.pid();
         designates(pids, false);
       }
       if (annotation.get("factoryPid") != null) {
         String[] pids = o.factoryPid();
         designates(pids, true);
       }
       if (annotation.get("icon") != null) {
         Icon[] icons = o.icon();
         for (Icon icon : icons) {
           ocd.icons.add(new IconDef(icon.resource(), icon.size()));
         }
       }
     } else {
       analyzer.error(
           "ObjectClassDefinition applied to non-interface, non-annotation class %s", clazz);
     }
   }
 }
Ejemplo n.º 3
0
 private void doXmlAttribute(Annotation annotation, XMLAttribute xmlAttr) {
   if (current == null) {
     if (clazz.isInterface()) {
       if (ocd == null) ocd = new OCDDef(finder);
       ocd.addExtensionAttribute(xmlAttr, annotation);
     }
   } else {
     current.addExtensionAttribute(xmlAttr, annotation);
   }
 }
Ejemplo n.º 4
0
 private boolean identifiableCollection(String type, boolean intface, boolean topLevel) {
   try {
     Clazz clazz = analyzer.findClass(analyzer.getTypeRefFromFQN(type));
     if (clazz != null
         && (!topLevel || !clazz.isAbstract())
         && ((intface && clazz.isInterface()) ^ clazz.hasPublicNoArgsConstructor())) {
       TypeRef[] intfs = clazz.getInterfaces();
       if (intfs != null) {
         for (TypeRef intf : intfs) {
           if (COLLECTION.matcher(intf.getFQN()).matches()
               || identifiableCollection(intf.getFQN(), true, false)) {
             return true;
           }
         }
       }
       TypeRef ext = clazz.getSuper();
       return ext != null && identifiableCollection(ext.getFQN(), false, false);
     }
   } catch (Exception e) {
     return false;
   }
   return false;
 }