You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by le...@apache.org on 2004/09/11 21:07:42 UTC

cvs commit: jakarta-commons/attributes/api/src/java/org/apache/commons/attributes Util.java

leosutic    2004/09/11 12:07:42

  Modified:    attributes/api/src/java/org/apache/commons/attributes
                        Util.java
  Log:
  Fixed bug that would make Target checking get bypassed.
  
  Revision  Changes    Path
  1.2       +11 -10    jakarta-commons/attributes/api/src/java/org/apache/commons/attributes/Util.java
  
  Index: Util.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/attributes/api/src/java/org/apache/commons/attributes/Util.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- Util.java	6 Jul 2004 20:41:56 -0000	1.1
  +++ Util.java	11 Sep 2004 19:07:42 -0000	1.2
  @@ -74,18 +74,18 @@
           return sb.toString ();
       }
       
  -    public static void checkTarget (int target, Object attribute, String element) {
  +    private static void checkTarget (int target, Object attribute, String element) {
           Target targetAttr = (Target) Attributes.getAttribute (attribute.getClass (), Target.class);
           if (targetAttr == null) {
               return;
  -        }
  +        }        
           
           if ((targetAttr.getFlags () & target) == 0) {
               throw new InvalidAttributeTargetError (attribute.getClass ().getName (), element, targetAttr.getFlags ());
           }
       }
       
  -    public static void checkTarget (int target, Set attributes, String element) {
  +    private static void checkTargets (int target, Collection attributes, String element) {
           Iterator iter = attributes.iterator ();
           while (iter.hasNext ()) {
               checkTarget (target, iter.next (), element);
  @@ -93,12 +93,13 @@
       }
       
       public static void validateRepository (Class owningClass, AttributeRepositoryClass repo) {
  -        checkTarget (Target.CLASS, repo.getClassAttributes (), owningClass.getName ());
  +        checkTargets (Target.CLASS, repo.getClassAttributes (), owningClass.getName ());
           
           Map fieldAttrs = repo.getFieldAttributes ();
           for (Iterator iter = fieldAttrs.keySet ().iterator(); iter.hasNext ();) {
               String fieldName = (String) iter.next ();
  -            checkTarget (Target.FIELD, (Collection) fieldAttrs.get (fieldName), owningClass.getName () + "." + fieldName);
  +            
  +            checkTargets (Target.FIELD, (Collection) fieldAttrs.get (fieldName), owningClass.getName () + "." + fieldName);
           }
           
           Map ctorAttrs = repo.getConstructorAttributes ();
  @@ -109,11 +110,11 @@
               for (int i = 0; i < bundle.size (); i++) {
                   switch (i) {
                   case 0: 
  -                    checkTarget (Target.CONSTRUCTOR, (Collection) bundle.get (0), owningClass.getName () + "." + ctorName);
  +                    checkTargets (Target.CONSTRUCTOR, (Collection) bundle.get (0), owningClass.getName () + "." + ctorName);
                       break;
                       
                   default:
  -                    checkTarget (Target.CONSTRUCTOR_PARAMETER, (Collection) bundle.get (i), "parameter " + (i) + " of " + owningClass.getName () + ctorName);
  +                    checkTargets (Target.CONSTRUCTOR_PARAMETER, (Collection) bundle.get (i), "parameter " + (i) + " of " + owningClass.getName () + ctorName);
                   }
               }
           }
  @@ -126,15 +127,15 @@
               for (int i = 0; i < bundle.size (); i++) {
                   switch (i) {
                   case 0: 
  -                    checkTarget (Target.METHOD, (Collection) bundle.get (0), owningClass.getName () + "." + methodName);
  +                    checkTargets (Target.METHOD, (Collection) bundle.get (0), owningClass.getName () + "." + methodName);
                       break;
                       
                   case 1:
  -                    checkTarget (Target.RETURN, (Collection) bundle.get (1), "return value of " + owningClass.getName () + "." + methodName);
  +                    checkTargets (Target.RETURN, (Collection) bundle.get (1), "return value of " + owningClass.getName () + "." + methodName);
                       break;
                       
                   default:
  -                    checkTarget (Target.METHOD_PARAMETER, (Collection) bundle.get (i), "parameter " + (i - 1) + " of " + owningClass.getName () + "." + methodName);
  +                    checkTargets (Target.METHOD_PARAMETER, (Collection) bundle.get (i), "parameter " + (i - 1) + " of " + owningClass.getName () + "." + methodName);
                   }
               }
           }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org