示例#1
0
 protected JavaField getReferencedField(final JavaTag tag, String ref)
     throws SCRDescriptorException {
   int classSep = ref.lastIndexOf('.');
   JavaField field = null;
   if (classSep == -1) {
     // local variable
     field = tag.getJavaClassDescription().getFieldByName(ref);
   }
   if (field == null) {
     field = tag.getJavaClassDescription().getExternalFieldByName(ref);
   }
   if (field == null) {
     throw new SCRDescriptorException(
         "Property references unknown field "
             + ref
             + " in class "
             + tag.getJavaClassDescription().getName(),
         tag);
   }
   return field;
 }
示例#2
0
  /**
   * Test if there is already a property with the same name.
   *
   * @param property The tag.
   * @param field
   * @param isInspectedClass
   * @throws SCRDescriptorException
   */
  public void testProperty(JavaTag property, JavaField field, boolean isInspectedClass)
      throws SCRDescriptorException {
    final String propName = this.getPropertyName(property, field);

    if (propName != null) {
      if (properties.containsKey(propName)) {
        // if the current class is the class we are currently inspecting, we
        // have found a duplicate definition
        if (isInspectedClass) {
          throw new SCRDescriptorException(
              "Duplicate definition for property "
                  + propName
                  + " in class "
                  + property.getJavaClassDescription().getName(),
              property);
        }
      } else {
        properties.put(propName, new PropertyDescription(property, field));
      }
    } else {
      throw new SCRDescriptorException("Property has no name", property);
    }
  }