Examples of SoftReference


Examples of java.lang.ref.SoftReference

        // *********************************************************
        // Assign SoftReference to File cached in-memory as a String

        oReplaced = new String(cBuffer);
        oFileStr = new SoftReference(oReplaced);

      } // fi (oReplaced)

    } // fi (bHasReplacements)

View Full Code Here

Examples of java.lang.ref.SoftReference

            jv = new JarVerifier(b);
        }
    } else {
        man = new Manifest(super.getInputStream(manEntry));
    }
          manRef = new SoftReference(man);
      }
  }
  return man;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

        }
        // No cached value available; request value from VM
        res = Reflection.filterFields(this, getDeclaredFields0(publicOnly));
        if (useCaches) {
            if (publicOnly) {
                declaredPublicFields = new SoftReference(res);
            } else {
                declaredFields = new SoftReference(res);
            }
        }
        return res;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

        }

        res = new Field[fields.size()];
        fields.toArray(res);
        if (useCaches) {
            publicFields = new SoftReference(res);
        }
        return res;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

        } else {
            res = getDeclaredConstructors0(publicOnly);
        }
        if (useCaches) {
            if (publicOnly) {
                publicConstructors = new SoftReference(res);
            } else {
                declaredConstructors = new SoftReference(res);
            }
        }
        return res;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

        }
        // No cached value available; request value from VM
        res = getDeclaredMethods0(publicOnly);
        if (useCaches) {
            if (publicOnly) {
                declaredPublicMethods = new SoftReference(res);
            } else {
                declaredMethods = new SoftReference(res);
            }
        }
        return res;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

        }
        methods.addAllIfNotPresent(inheritedMethods);
        methods.compactAndTrim();
        res = methods.getArray();
        if (useCaches) {
            publicMethods = new SoftReference(res);
        }
        return res;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

     * Look up resource data for the desiredLocale in the cache; update the
     * cache if necessary.
     */
    private static ResourceBundle cacheLookup(Locale desiredLocale) {
  ResourceBundle rb;
  SoftReference data
      = (SoftReference)cachedLocaleData.get(desiredLocale);
  if (data == null) {
      rb = LocaleData.getDateFormatData(desiredLocale);
      data = new SoftReference(rb);
      cachedLocaleData.put(desiredLocale, data);
  } else {
      if ((rb = (ResourceBundle)data.get()) == null) {
    rb = LocaleData.getDateFormatData(desiredLocale);
    data = new SoftReference(rb);
      }
  }
  return rb;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

      if (!Modifier.isPublic(mods)) {
     result[i] = null;
      }
        }   
  // Add it to the cache.
  declaredMethodCache.put(fclz, new SoftReference(result));
  return result;
    }
View Full Code Here

Examples of java.lang.ref.SoftReference

     */
    public synchronized List<String> getNativesForFlavor(DataFlavor flav) {
        List retval = null;

        // Check cache, even for null flav
        SoftReference ref = (SoftReference)getNativesForFlavorCache.get(flav);
        if (ref != null) {
            retval = (List)ref.get();
            if (retval != null) {
                // Create a copy, because client code can modify the returned
                // list.
                return new ArrayList(retval);
            }
        }

        if (flav == null) {
            retval = new ArrayList(getNativeToFlavor().keySet());
        } else if (disabledMappingGenerationKeys.contains(flav)) {
            // In this case we shouldn't synthesize a native for this flavor,
            // since its mappings were explicitly specified.
            retval = flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);
        } else if (DataTransferer.isFlavorCharsetTextType(flav)) {

            // For text/* flavors, flavor-to-native mappings specified in
            // flavormap.properties are stored per flavor's base type.
            if ("text".equals(flav.getPrimaryType())) {
                retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType());
                if (retval != null) {
                    // To prevent the List stored in the map from modification.
                    retval = new ArrayList(retval);
                }
            }

            // Also include text/plain natives, but don't duplicate Strings
            List textPlainList = (List)getFlavorToNative().get(TEXT_PLAIN_BASE_TYPE);

            if (textPlainList != null && !textPlainList.isEmpty()) {
                // To prevent the List stored in the map from modification.
                // This also guarantees that removeAll() is supported.
                textPlainList = new ArrayList(textPlainList);
                if (retval != null && !retval.isEmpty()) {
                    // Use HashSet to get constant-time performance for search.
                    textPlainList.removeAll(new HashSet(retval));
                    retval.addAll(textPlainList);
                } else {
                    retval = textPlainList;
                }
            }

            if (retval == null || retval.isEmpty()) {
                retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
            } else {
                // In this branch it is guaranteed that natives explicitly
                // listed for flav's MIME type were added with
                // addUnencodedNativeForFlavor(), so they have lower priority.
                List explicitList =
                    flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND)

                // flavorToNativeLookup() never returns null.
                // It can return an empty List, however.
                if (!explicitList.isEmpty()) {
                    // To prevent the List stored in the map from modification.
                    // This also guarantees that removeAll() is supported.
                    explicitList = new ArrayList(explicitList);
                    // Use HashSet to get constant-time performance for search.
                    explicitList.removeAll(new HashSet(retval));
                    retval.addAll(explicitList);
                }
            }
        } else if (DataTransferer.isFlavorNoncharsetTextType(flav)) {
            retval = (List)getFlavorToNative().get(flav.mimeType.getBaseType());

            if (retval == null || retval.isEmpty()) {
                retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
            } else {
                // In this branch it is guaranteed that natives explicitly
                // listed for flav's MIME type were added with
                // addUnencodedNativeForFlavor(), so they have lower priority.
                List explicitList =
                    flavorToNativeLookup(flav, !SYNTHESIZE_IF_NOT_FOUND);

                // flavorToNativeLookup() never returns null.
                // It can return an empty List, however.
                if (!explicitList.isEmpty()) {
                    // To prevent the List stored in the map from modification.
                    // This also guarantees that add/removeAll() are supported.
                    retval = new ArrayList(retval);
                    explicitList = new ArrayList(explicitList);
                    // Use HashSet to get constant-time performance for search.
                    explicitList.removeAll(new HashSet(retval));
                    retval.addAll(explicitList);
                }
            }
        } else {
            retval = flavorToNativeLookup(flav, SYNTHESIZE_IF_NOT_FOUND);
        }

        getNativesForFlavorCache.put(flav, new SoftReference(retval));
        // Create a copy, because client code can modify the returned list.
        return new ArrayList(retval);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.