#48453: Avoid constructing string representations of MOFID. release41_beta-BLD200502172122
authormmatula@netbeans.org
Mon, 14 Feb 2005 16:38:46 +0000
changeset 16619614ee73981a
parent 1660 3bc3eced6649
child 1662 d5e21f0ce6f2
#48453: Avoid constructing string representations of MOFID.
mdr/src/org/netbeans/mdr/handlers/gen/TagSupport.java
     1.1 --- a/mdr/src/org/netbeans/mdr/handlers/gen/TagSupport.java	Mon Jan 31 11:50:52 2005 +0000
     1.2 +++ b/mdr/src/org/netbeans/mdr/handlers/gen/TagSupport.java	Mon Feb 14 16:38:46 2005 +0000
     1.3 @@ -13,6 +13,7 @@
     1.4  package org.netbeans.mdr.handlers.gen;
     1.5  
     1.6  import java.util.Locale;
     1.7 +import org.netbeans.mdr.persistence.MOFID;
     1.8  import org.netbeans.mdr.storagemodel.StorableObject;
     1.9  import org.netbeans.mdr.util.DebugException;
    1.10  import org.netbeans.mdr.util.Logger;
    1.11 @@ -116,7 +117,7 @@
    1.12      public static String getTagValue(StorableObject storable, String tagID) {
    1.13          if (storable == null)
    1.14              return null;
    1.15 -        String tagKey = storable.getMofId() + ":" + tagID; //NOI18N
    1.16 +        Object tagKey = new CacheKey(storable.getMofId(), tagID);
    1.17          String value = (String) valueCache.get(tagKey);
    1.18          
    1.19          if (value == null) {
    1.20 @@ -329,4 +330,23 @@
    1.21              throw (DebugException) Logger.getDefault().annotate(new DebugException(), e);
    1.22          }
    1.23      }
    1.24 +    
    1.25 +    private static class CacheKey {
    1.26 +        private final MOFID mofId;
    1.27 +        private final String tagId;
    1.28 +        
    1.29 +        public CacheKey(MOFID mofId, String tagId) {
    1.30 +            if (mofId == null) throw new IllegalArgumentException();
    1.31 +            this.mofId = mofId;
    1.32 +            this.tagId = tagId == null ? "null" : tagId;
    1.33 +        }
    1.34 +
    1.35 +        public boolean equals(Object o) {
    1.36 +            return (o instanceof CacheKey) && ((CacheKey) o).mofId.equals(mofId) && ((CacheKey) o).tagId.equals(tagId);
    1.37 +        }
    1.38 +        
    1.39 +        public int hashCode() {
    1.40 +            return mofId.hashCode() * 31 + tagId.hashCode();
    1.41 +        }
    1.42 +    }
    1.43  }