Java Collections.unmodifiableSortedMap Examples

Java Collections.unmodifiableSortedMap - 20 examples found. These are the top rated real world Java examples of java.util.Collections.unmodifiableSortedMap extracted from open source projects. You can rate examples to help us improve the quality of examples.
  /**
   * Sets the "frozen" state of this job.
   *
   * <p>This is an internal operation to be used only by the <code>{@link CmsScheduleManager}</code>
   * .
   *
   * <p>
   *
   * @param frozen the "frozen" state to set
   */
  protected synchronized void setFrozen(boolean frozen) {

    if (frozen && !m_frozen) {
      // "freeze" the job configuration
      m_parameters = Collections.unmodifiableSortedMap(m_parameters);
      m_context.freeze();
      m_frozen = true;
    } else if (!frozen && m_frozen) {
      // "unfreeze" the job configuration
      m_parameters = new TreeMap<String, String>(m_parameters);
      m_frozen = false;
    }
  }
 public MethodSignature(Configuration configuration, Method method) throws BindingException {
   this.returnType = method.getReturnType();
   this.returnsVoid = void.class.equals(this.returnType);
   this.returnsMany =
       (configuration.getObjectFactory().isCollection(this.returnType)
           || this.returnType.isArray());
   this.mapKey = getMapKey(method);
   this.returnsMap = (this.mapKey != null);
   this.hasNamedParameters = hasNamedParams(method);
   this.rowBoundsIndex = getUniqueParamIndex(method, RowBounds.class);
   this.resultHandlerIndex = getUniqueParamIndex(method, ResultHandler.class);
   this.params = Collections.unmodifiableSortedMap(getParams(method, this.hasNamedParameters));
 }
Example #3
0
 public SortedMap<Instant, Double> getAbscisse(StringBounder stringBounder) {
   final SortedMap<Instant, Double> pos = new TreeMap<Instant, Double>();
   final double caseWidth = getCaseWidth(stringBounder);
   final Instant end = project.getEnd();
   double x = 0;
   for (Instant cur = project.getStart();
       cur.compareTo(end) <= 0;
       cur = cur.next(project.getDayClose())) {
     pos.put(cur, x);
     x += caseWidth;
   }
   return Collections.unmodifiableSortedMap(pos);
 }
  /**
   * @param fromKey Biggest build number to be in the returned set.
   * @param toKey Smallest build number-1 to be in the returned set (-1 because this is exclusive)
   */
  public SortedMap<Integer, R> subMap(Integer fromKey, Integer toKey) {
    // TODO: if this method can produce a lazy map, that'd be wonderful
    // because due to the lack of floor/ceil/higher/lower kind of methods
    // to look up keys in SortedMap, various places of Jenkins rely on
    // subMap+firstKey/lastKey combo.

    R start = search(fromKey, DESC);
    if (start == null) return EMPTY_SORTED_MAP;

    R end = search(toKey, ASC);
    if (end == null) return EMPTY_SORTED_MAP;

    for (R i = start; i != end; ) {
      i = search(getNumberOf(i) - 1, DESC);
      assert i != null;
    }

    return Collections.unmodifiableSortedMap(
        new BuildReferenceMapAdapter<R>(this, index.byNumber.subMap(fromKey, toKey)));
  }
Example #5
0
 /**
  * Caches. Fails silently.
  *
  * @param event matching this event only, case sensitive
  * @param since since this time, 0 for all
  * @return non-null, Map of times to (possibly empty) info strings, sorted, earliest first,
  *     unmodifiable
  */
 public synchronized SortedMap<Long, String> getEvents(String event, long since) {
   SortedMap<Long, String> rv = _cache.get(event);
   if (rv != null) {
     Long cacheTime = _cacheTime.get(event);
     if (cacheTime != null) {
       if (since >= cacheTime.longValue()) return rv.tailMap(Long.valueOf(since));
     }
   }
   rv = new TreeMap<Long, String>();
   BufferedReader br = null;
   try {
     br = new BufferedReader(new InputStreamReader(new FileInputStream(_file), "UTF-8"));
     String line = null;
     while ((line = br.readLine()) != null) {
       try {
         String[] s = line.split(" ", 3);
         if (!s[1].equals(event)) continue;
         long time = Long.parseLong(s[0]);
         if (time <= since) continue;
         Long ltime = Long.valueOf(time);
         String info = s.length > 2 ? s[2] : "";
         rv.put(ltime, info);
       } catch (IndexOutOfBoundsException ioobe) {
       } catch (NumberFormatException nfe) {
       }
     }
     rv = Collections.unmodifiableSortedMap(rv);
     _cache.put(event, rv);
     _cacheTime.put(event, Long.valueOf(since));
   } catch (IOException ioe) {
   } finally {
     if (br != null)
       try {
         br.close();
       } catch (IOException ioe) {
       }
   }
   return rv;
 }
 /**
  * Returns a grouped and sorted map of all registered metrics which match then given {@link
  * MetricPredicate}.
  *
  * @param predicate a predicate which metrics have to match to be in the results
  * @return all registered metrics which match {@code predicate}, sorted by name
  */
 public SortedMap<String, SortedMap<MetricName, Metric>> getGroupedMetrics(
     MetricPredicate predicate) {
   final SortedMap<String, SortedMap<MetricName, Metric>> groups =
       new TreeMap<String, SortedMap<MetricName, Metric>>();
   for (Map.Entry<MetricName, Metric> entry : metrics.entrySet()) {
     final String qualifiedTypeName = entry.getKey().getGroup() + "." + entry.getKey().getType();
     if (predicate.matches(entry.getKey(), entry.getValue())) {
       final String scopedName;
       if (entry.getKey().hasScope()) {
         scopedName = qualifiedTypeName + "." + entry.getKey().getScope();
       } else {
         scopedName = qualifiedTypeName;
       }
       SortedMap<MetricName, Metric> group = groups.get(scopedName);
       if (group == null) {
         group = new TreeMap<MetricName, Metric>();
         groups.put(scopedName, group);
       }
       group.put(entry.getKey(), entry.getValue());
     }
   }
   return Collections.unmodifiableSortedMap(groups);
 }