Ejemplo n.º 1
0
  /**
   * Return the documentation attached to the property object. This is fetched from tagged values
   * and - if this is absent - from the 'notes' specific to the EA objects model.
   */
  @Override
  public String documentation() {

    // Retrieve/compute the documentation only once
    // Cache the result for subsequent use
    if (!documentationAccessed) {

      documentationAccessed = true;

      // Try default first
      String s = super.documentation();

      // Try EA notes, if both tagged values fail and ea:notes is the source
      if ((s == null || s.length() == 0)
          && descriptorSource(Options.Descriptor.DOCUMENTATION.toString()).equals("ea:notes")) {
        s = eaClassElement.GetNotes();
        // Fix for EA7.5 bug
        if (s != null) {
          s = EADocument.removeSpuriousEA75EntitiesFromStrings(s);
          super.documentation = options().internalize(s);
        }
      }

      // If result is empty, check if we can get the documentation from a
      // dependency
      if (s == null || s.isEmpty()) {
        for (Iterator<String> i = this.supplierIds().iterator(); i.hasNext(); ) {
          String cid = i.next();
          ClassInfoEA cix = document.fClassById.get(cid);
          if (cix != null) {
            if (cix.name().equalsIgnoreCase(this.name()) && cix.stereotype("featureconcept")) {
              s = cix.documentation();
              break;
            }
          }
        }
      }

      // If result is empty, check if we can get the documentation from a
      // supertype with the same name (added for ELF/INSPIRE)
      if (s == null || s.isEmpty()) {
        HashSet<ClassInfoEA> sts = supertypesAsClassInfoEA();
        if (sts != null) {
          for (ClassInfoEA stci : sts) {
            if (stci.name().equals(this.name())) {
              s = stci.documentation();
              break;
            }
          }
        }
      }

      // Assign what we got or "" ...
      super.documentation = options().internalize(s != null ? s : "");
    }
    return super.documentation;
  } // documentation()