Exemple #1
0
 /**
  * Return a resource type relative to a supplied type id.
  *
  * @param id the type name to retrieve
  * @return the type instance
  * @exception IllegalArgumentException if the id value does not match a type produced by the
  *     resource.
  */
 public Type getType(final String id) throws IllegalArgumentException {
   boolean flag = id.indexOf('#') > -1;
   if (flag) {
     for (int i = 0; i < m_types.length; i++) {
       Type type = m_types[i];
       if (type.getCompoundName().equals(id)) {
         return type;
       }
     }
   } else {
     for (int i = 0; i < m_types.length; i++) {
       Type type = m_types[i];
       if (type.getID().equals(id)) {
         return type;
       }
     }
   }
   final String error =
       "Type name ["
           + id
           + "] not recognized with the scope of resource ["
           + getResourcePath()
           + "].";
   throw new IllegalArgumentException(error);
 }
Exemple #2
0
  private void createIncludeDirectives(
      final DefaultModule module, final List<IncludeDirective> list, final Category category) {
    DefaultResource[] providers = getDefaultProviders(Scope.RUNTIME, true, category);
    for (int i = 0; i < providers.length; i++) {
      DefaultResource provider = providers[i];
      if (provider.isaDescendant(module)) {
        // create a ref
        String path = provider.getResourcePath();
        IncludeDirective include = new IncludeDirective(IncludeDirective.REF, category, path, null);
        if (!list.contains(include)) {
          list.add(include);
        }
      } else {
        // create a urn

        Type[] types = provider.getTypes();
        for (int j = 0; j < types.length; j++) {
          Type type = types[j];
          String label = type.getID();
          Artifact artifact = type.getArtifact();
          String urn = artifact.toString();
          IncludeDirective include =
              new IncludeDirective(IncludeDirective.URI, category, urn, null);
          if (!list.contains(include)) {
            list.add(include);
          }
        }
      }
    }
  }
Exemple #3
0
 /**
  * Test if this resource is associated with a type of the supplied name.
  *
  * @param type the type id
  * @return TRUE if this resource produces an artifact of the supplied type
  */
 public boolean isa(final String type) {
   for (int i = 0; i < m_types.length; i++) {
     Type someType = m_types[i];
     String name = someType.getID();
     if (name.equals(type)) {
       return true;
     }
   }
   return false;
 }