Example #1
0
 /**
  * Return a directive suitable for publication as an external description.
  *
  * @param module the enclosing module
  * @return the resource directive
  */
 ResourceDirective exportResource(final DefaultModule module) {
   if (null == m_directive) {
     final String error = "Cannot export from the root module.";
     throw new UnsupportedOperationException(error);
   }
   String name = getName();
   String version = getVersion();
   String basedir = null;
   InfoDirective info = m_directive.getInfoDirective();
   TypeDirective[] types = m_directive.getTypeDirectives();
   TypeDirective[] exportedTypes = createExportedTypes(types);
   DependencyDirective[] dependencies = createDeps(module);
   Properties properties = getExportProperties();
   return ResourceDirective.createResourceDirective(
       name,
       version,
       Classifier.EXTERNAL,
       basedir,
       info,
       exportedTypes,
       dependencies,
       properties,
       null,
       true);
 }
Example #2
0
 /**
  * Return the resource classifier.
  *
  * @return the classifier (LOCAL, EXTERNAL or ANONYMOUS)
  */
 public Classifier getClassifier() {
   if (null != m_directive) {
     return m_directive.getClassifier();
   } else {
     return ResourceDirective.ANONYMOUS;
   }
 }
Example #3
0
 /**
  * Return the name of the resource.
  *
  * @return the resource name
  */
 public String getName() {
   if (null != m_directive) {
     return m_directive.getName();
   } else {
     return null;
   }
 }
Example #4
0
 /**
  * Return the export policy.
  *
  * @return the export policy value
  */
 public boolean getExportPolicy() {
   if (null != m_directive) {
     return m_directive.getExportPolicy();
   } else {
     return true;
   }
 }
Example #5
0
 /**
  * Return a string representation of the resource in the form 'resource:[path]'.
  *
  * @return the string value
  */
 public String toString() {
   if (null != m_directive) {
     if (m_directive.isLocal()) {
       return toString("project");
     }
   }
   return toString("resource");
 }
Example #6
0
 private IncludeDirective[] getLocalIncludes(final Scope scope, final Category category) {
   DependencyDirective dependency = m_directive.getDependencyDirective(scope);
   if (null == category) {
     return dependency.getIncludeDirectives();
   } else {
     return dependency.getIncludeDirectives(category);
   }
 }
Example #7
0
 /**
  * Return the declard resource version.
  *
  * @return the statutory version
  */
 public String getStatutoryVersion() {
   if (null == m_directive) {
     return null;
   } else {
     String version = m_directive.getVersion();
     if ((null != version) || m_directive.isAnonymous()) {
       return version;
     } else {
       if (null != m_parent) {
         return m_parent.getStatutoryVersion();
       } else if (!m_directive.getClassifier().equals(Classifier.LOCAL)) {
         return ANONYMOUS;
       } else {
         return null;
       }
     }
   }
 }
Example #8
0
 /**
  * Return the resource version.
  *
  * @return the version
  */
 public String getVersion() {
   String version = getStatutoryVersion();
   if (null != version) {
     return version;
   } else if (m_directive.isAnonymous()) {
     return version;
   } else {
     return getStandardVersion();
   }
 }
Example #9
0
 boolean isLocal() {
   if (null != m_directive) {
     return m_directive.isLocal();
   }
   return false;
 }
Example #10
0
 boolean isAnonymous() {
   if (null != m_directive) {
     return m_directive.isAnonymous();
   }
   return false;
 }
Example #11
0
 /**
  * Return the info block.
  *
  * @return the info block
  */
 public Info getInfo() {
   return m_directive.getInfoDirective();
 }
Example #12
0
 String getScheme() {
   return m_directive.getScheme();
 }
Example #13
0
  /**
   * Creation of a new default resource.
   *
   * @param library the reference library
   * @param module the parent module
   * @param directive the resource directive
   */
  DefaultResource(
      final DefaultLibrary library, final DefaultModule module, final ResourceDirective directive) {
    super(module, directive);
    if (null == directive) {
      throw new NullPointerException("directive");
    }

    m_library = library;
    m_directive = directive;
    m_parent = module;

    if (module.isRoot()) {
      m_path = directive.getName();
    } else {
      m_path = module.getResourcePath() + "/" + directive.getName();
    }

    // setup produced types

    TypeDirective[] types = directive.getTypeDirectives();
    m_types = new Type[types.length];
    m_typeNames = new String[types.length];
    for (int i = 0; i < types.length; i++) {
      TypeDirective type = types[i];
      m_types[i] = new DefaultType(this, type);
      m_typeNames[i] = type.getID();
    }

    // setup the resource basedir

    File anchor = getAnchor();
    String filename = m_directive.getBasedir();
    if (null != filename) {
      String spec = resolve(filename);
      File file = new File(spec);
      if (file.isAbsolute()) {
        m_basedir = getCanonicalFile(file);
      } else {
        File basedir = new File(anchor, spec);
        m_basedir = getCanonicalFile(basedir);
        setProperty("basedir", m_basedir.toString());
      }
    } else {
      if (!m_directive.getClassifier().equals(Classifier.LOCAL)) {
        m_basedir = null;
      } else {
        final String error = "Missing base directory declaration in resource [" + m_path + "].";
        throw new ValidationException(error);
      }
    }

    // setup the default properties

    setProperty("project.name", getName());
    if (null != m_parent) {
      setProperty("project.group", m_parent.getResourcePath());
    } else {
      setProperty("project.group", "");
    }
    String version = getVersion();
    if (null != version) {
      setProperty("project.version", version);
    }

    // setup filters

    FilterDirective[] filters = directive.getFilterDirectives();
    for (int i = 0; i < filters.length; i++) {
      FilterDirective filter = filters[i];
      String token = filter.getToken();
      m_filters.put(token, filter);
    }
  }