Exemplo n.º 1
0
 /** @see de.interactive_instruments.ShapeChange.Model.ClassInfo#property(java.lang.String) */
 public PropertyInfo property(String name) {
   // Search in own properties
   validatePropertiesCache();
   for (PropertyInfo pi : propertiesCache.values()) {
     if (pi.name().equals(name)) return pi;
   }
   // Go and search in base classes
   TreeSet<ClassInfoEA> bcis = new TreeSet<ClassInfoEA>();
   if (baseclassInfo != null) bcis.add(baseclassInfo);
   else if (baseclassInfoSet != null) bcis = baseclassInfoSet;
   for (ClassInfoEA bci : bcis) {
     PropertyInfo pi = bci.property(name);
     if (pi != null) return pi;
   }
   return null;
 } // property()
Exemplo n.º 2
0
  // Validate properties cache. This makes sure the property cache contains
  // all properties ordered by their appearance in the class.
  private void validatePropertiesCache() {

    if (propertiesCache == null) {

      // Allocate the cache
      propertiesCache = new TreeMap<StructuredNumber, PropertyInfo>();

      // Load attributes ...
      Collection<Attribute> attrs = eaClassElement.GetAttributes();

      // Ensure that there are attributes before continuing
      if (attrs != null) {
        for (Attribute attr : attrs) {
          // Pick public attributes if this has been requested
          if (document.options.parameter("publicOnly").equals("true")) {
            String vis = attr.GetVisibility();
            if (!vis.equalsIgnoreCase("Public")) {
              continue;
            }
          }
          // Create the property object.
          PropertyInfoEA pi = new PropertyInfoEA(document, this, attr);
          // Check sequence number on duplicates
          PropertyInfo piTemp = propertiesCache.get(pi.sequenceNumber());
          if (piTemp != null) {
            int cat = category();
            if (cat != Options.ENUMERATION
                && cat != Options.CODELIST
                && !pi.sequenceNumber.equals(new StructuredNumber(Integer.MIN_VALUE))) {
              MessageContext mc =
                  document.result.addError(null, 107, pi.name(), name(), piTemp.name());
              if (mc != null) mc.addDetail(null, 400, "Package", pkg().fullName());
            }
          }
          // Add to properties cache
          propertiesCache.put(pi.sequenceNumber(), pi);
        }
      }

      // Load roles ...
      for (PropertyInfoEA pi : registeredRoles) {
        // Check sequence number on duplicates
        PropertyInfo piTemp = propertiesCache.get(pi.sequenceNumber());
        if (piTemp != null) {
          MessageContext mc = document.result.addError(null, 107, pi.name(), name(), piTemp.name());
          if (mc != null) mc.addDetail(null, 400, "Package", pkg().fullName());
        }
        // Add to properties cache
        propertiesCache.put(pi.sequenceNumber(), pi);
      }

      // Are there any nilReason implementation uses in the class ?
      // This is called at the end of loading all properties,
      // as there could be cases in which the order of the property
      // loading
      // matters, for example the detection of the union direct case
      // in the implementedByNilReason() method.
      for (PropertyInfo pi : propertiesCache.values()) {
        if (pi.implementedByNilReason()) hasNilReason = true;
      }
    }
  } // validatePropertiesCache()