/** * Returns a list of objects sorted based on their media type where the first in the list * is the best match * * @param accept mime to match * @return list of objects */ public List<T> getPossible(MediaType accept) { accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { ArrayList<T> copy = new ArrayList<T>(); copy.addAll(everything); return copy; } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches); return convert(matches); }
Collections.sort(newall); all = newall; everything = convert(newall);
public List<T> getPossible(MediaType accept, Class<?> type) { List<T> cached = null; CachedMediaTypeAndClass cacheEntry = null; if (useCache) { cacheEntry = new CachedMediaTypeAndClass(type, accept); cached = classCache.get(cacheEntry); if (cached != null) return cached; } accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { matches.addAll(all); } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches, new TypedEntryComparator(type)); cached = convert(matches); if (useCache) classCache.put(cacheEntry, cached); return cached; }
/** * Returns a list of objects sorted based on their media type where the first in the list * is the best match * * @param accept mime to match * @return */ public List<T> getPossible(MediaType accept) { accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { ArrayList<T> copy = new ArrayList<T>(); copy.addAll(everything); return copy; } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches); return convert(matches); }
/** * Returns a list of objects sorted based on their media type where the first in the list * is the best match * * @param accept mime to match * @return list of objects */ public List<T> getPossible(MediaType accept) { accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { ArrayList<T> copy = new ArrayList<T>(); copy.addAll(everything); return copy; } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches); return convert(matches); }
Collections.sort(newall); all = newall; everything = convert(newall);
Collections.sort(newall); all = newall; everything = convert(newall);
public List<T> getPossible(MediaType accept, Class<?> type) { List<T> cached = null; CachedMediaTypeAndClass cacheEntry = null; if (useCache) { cacheEntry = new CachedMediaTypeAndClass(type, accept); cached = classCache.get(cacheEntry); if (cached != null) return cached; } accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { matches.addAll(all); } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches, new TypedEntryComparator(type)); cached = convert(matches); if (useCache) classCache.put(cacheEntry, cached); return cached; }
public List<T> getPossible(MediaType accept, Class<?> type) { List<T> cached = null; CachedMediaTypeAndClass cacheEntry = null; if (useCache) { cacheEntry = new CachedMediaTypeAndClass(type, accept); cached = classCache.get(cacheEntry); if (cached != null) return cached; } accept = new MediaType(accept.getType().toLowerCase(), accept.getSubtype().toLowerCase(), accept.getParameters()); List<Entry<T>> matches = new ArrayList<Entry<T>>(); if (accept.isWildcardType()) { matches.addAll(all); } else { matches.addAll(wildcards); SubtypeMap<T> indexed = index.get(accept.getType()); if (indexed != null) { matches.addAll(indexed.getPossible(accept)); } } Collections.sort(matches, new TypedEntryComparator(type)); cached = convert(matches); if (useCache) classCache.put(cacheEntry, cached); return cached; }