/** @see it.matrix.aod.postel.at.ATParserImpl#buildDetailsDataMap(java.util.TreeMap) */
  @Override
  public SortedMap<Integer, String> buildDetailsDataMap(TreeMap<Integer, String> rawMap) {

    SortedMap<Integer, String> _sm = new TreeMap<Integer, String>();
    SortedMap<Integer, String> _smtmp = new TreeMap<Integer, String>();

    Iterator<Entry<Integer, String>> mit = rawMap.entrySet().iterator();

    Integer[] fromKey = new Integer[15]; // max 15 pagine, è sufficiente Nicò? :-))	
    Integer[] toKey = new Integer[15];
    int i = 0;
    //		Integer fromKey = 0;
    //		Integer toKey = 0;
    while (mit.hasNext()) {
      Entry<Integer, String> entry = (Entry<Integer, String>) mit.next();
      if (entry.getValue().startsWith("!SPA -100")) {
        fromKey[i] = entry.getKey();
        i++;
      }

      if (entry.getValue().contains("!SPA 2;INL 0")) {
        toKey[i] = entry.getKey();
      }
    }

    for (int j = 0; j < i; j++) {
      // mit = rawMap.entrySet().iterator();
      _smtmp = rawMap.subMap(fromKey[j] + 1, fromKey[j] + ParserConstants.DAHLIA_DETAILS_PAG_SIZE);
      _sm.putAll(_smtmp);
    }

    return _sm;
  }
Beispiel #2
0
  /**
   * Tie a range of rows together so that they can be collapsed or expanded
   *
   * <p>Please note the rows being grouped <em>must</em> be in the current window, if the rows are
   * already flushed then groupRow has no effect.
   *
   * <p>Correct code:
   *
   * <pre><code>
   *       Workbook wb = new SXSSFWorkbook(100);  // keep 100 rows in memory
   *       Sheet sh = wb.createSheet();
   *       for (int rownum = 0; rownum &lt; 1000; rownum++) {
   *           Row row = sh.createRow(rownum);
   *           if(rownum == 200)  {
   *               sh.groupRow(100, 200);
   *           }
   *       }
   *
   *      </code></pre>
   *
   * <p>Incorrect code:
   *
   * <pre><code>
   *       Workbook wb = new SXSSFWorkbook(100);  // keep 100 rows in memory
   *       Sheet sh = wb.createSheet();
   *       for (int rownum = 0; rownum &lt; 1000; rownum++) {
   *           Row row = sh.createRow(rownum);
   *       }
   *       sh.groupRow(100, 200); // the rows in the range [100, 200] are already flushed and groupRows has no effect
   *
   *      </code></pre>
   *
   * @param fromRow start row (0-based)
   * @param toRow end row (0-based)
   */
  public void groupRow(int fromRow, int toRow) {
    for (SXSSFRow row : _rows.subMap(fromRow, toRow + 1).values()) {
      int level = row.getOutlineLevel() + 1;
      row.setOutlineLevel(level);

      if (level > outlineLevelRow) outlineLevelRow = level;
    }

    setWorksheetOutlineLevelRow();
  }
  /**
   * @author ddefrancesco
   * @param rawMap
   * @return TreeMap<Integer, String> _tm
   * @category Utility method.
   *     <p>This method builds the generic part of footer that embeds IVA descriptions, totals both
   *     net and gross. The resulting map will be used by buildIvaDataMap(TreeMap<Integer, String>
   *     rawMap) and buildTotaliDataMap(TreeMap<Integer, String> rawMap).
   */
  private SortedMap<Integer, String> buildImponibiliIvaDataMap(TreeMap<Integer, String> rawMap) {
    Iterator<Entry<Integer, String>> mit = rawMap.entrySet().iterator();
    Integer spa1Key = 0;
    Integer spa2Key = 0;

    while (mit.hasNext()) {
      Entry<Integer, String> entry = (Entry<Integer, String>) mit.next();
      if (entry.getValue().startsWith("!SPA 2")
          && !entry.getValue().contains(";INL 0")
          && entry.getKey() > 12) spa2Key = entry.getKey();
      if (entry.getValue().startsWith("!SPA 1") && entry.getKey() > 12) spa1Key = entry.getKey();
    }
    SortedMap<Integer, String> _tm = rehashedMap(rawMap.subMap(spa2Key + 1, spa1Key - 2));

    return _tm;
  }
Beispiel #4
0
 public static void main(String[] args) {
   TreeMap tm = new TreeMap();
   tm.put(new R(3), "轻量级Java EE企业应用实战");
   tm.put(new R(-5), "疯狂Java讲义");
   tm.put(new R(9), "疯狂Android讲义");
   System.out.println(tm);
   // 返回该TreeMap的第一个Entry对象
   System.out.println(tm.firstEntry());
   // 返回该TreeMap的最后一个key值
   System.out.println(tm.lastKey());
   // 返回该TreeMap的比new R(2)大的最小key值。
   System.out.println(tm.higherKey(new R(2)));
   // 返回该TreeMap的比new R(2)小的最大的key-value对。
   System.out.println(tm.lowerEntry(new R(2)));
   // 返回该TreeMap的子TreeMap
   System.out.println(tm.subMap(new R(-1), new R(4)));
 }
  @Override
  public Result<K, T> execute(Query<K, T> query) {
    K startKey = query.getStartKey();
    K endKey = query.getEndKey();
    if (startKey == null) {
      startKey = map.firstKey();
    }
    if (endKey == null) {
      endKey = map.lastKey();
    }

    // check if query.fields is null
    query.setFields(getFieldsToQuery(query.getFields()));

    NavigableMap<K, T> submap = map.subMap(startKey, true, endKey, true);

    return new MemResult<K, T>(this, query, submap);
  }
Beispiel #6
0
 public static void main(String[] args) {
   TreeMap<Integer, String> sortedMap = new TreeMap<Integer, String>(new CountingMapData(10));
   print(sortedMap);
   Integer low = sortedMap.firstKey();
   Integer high = sortedMap.lastKey();
   print(low);
   print(high);
   Iterator<Integer> it = sortedMap.keySet().iterator();
   for (int i = 0; i <= 6; i++) {
     if (i == 3) low = it.next();
     if (i == 6) high = it.next();
     else it.next();
   }
   print(low);
   print(high);
   print(sortedMap.subMap(low, high));
   print(sortedMap.headMap(high));
   print(sortedMap.tailMap(low));
 }
Beispiel #7
0
 /**
  * Method to retrieve the subset of the map between the specified keys.
  *
  * @param fromKey The start key
  * @param toKey The end key
  * @return The map meeting the input
  */
 public java.util.SortedMap subMap(Object fromKey, Object toKey) {
   return delegate.subMap(fromKey, toKey);
 }
 public Iterator<Entry<Long, Double>> getIteratorForSubMap(long from, long to) {
   return prices.subMap(from, false, to, false).entrySet().iterator();
 }
  @Override
  public List<UniqueId> replaceVersions(
      ObjectIdentifiable objectIdentifiable,
      List<YieldCurveDefinitionDocument> replacementDocuments) {
    ArgumentChecker.notNull(replacementDocuments, "replacementDocuments");
    ArgumentChecker.notNull(objectIdentifiable, "objectIdentifiable");

    final Instant now = Instant.now();

    for (YieldCurveDefinitionDocument replacementDocument : replacementDocuments) {
      ArgumentChecker.notNull(replacementDocument, "document");
      ArgumentChecker.notNull(
          replacementDocument.getYieldCurveDefinition(), "document.yieldCurveDefinition");
      final Currency currency = replacementDocument.getYieldCurveDefinition().getCurrency();
      final String name = replacementDocument.getYieldCurveDefinition().getName();
      final UniqueId id = UniqueId.of(getUniqueIdScheme(), name + "_" + currency.getCode());
      ArgumentChecker.isTrue(id.equals(objectIdentifiable), "Invalid object identifier");
    }

    YieldCurveDefinitionDocument storedDocument = get(objectIdentifiable, null);
    if (storedDocument == null) {
      throw new DataNotFoundException("Document not found: " + objectIdentifiable);
    }
    final Currency currency = storedDocument.getYieldCurveDefinition().getCurrency();
    final String name = storedDocument.getYieldCurveDefinition().getName();
    Pair<Currency, String> key = Pair.of(currency, name);

    final TreeMap<Instant, YieldCurveDefinition> value = _definitions.get(key);
    if (value == null) {
      throw new DataNotFoundException("OID '" + objectIdentifiable + "' not found");
    }
    if (_sourceVersionCorrection.getVersionAsOf() != null) {
      // Don't need to keep the old values before the one needed by "versionAsOfInstant"
      final Instant oldestNeeded = value.floorKey(_sourceVersionCorrection.getVersionAsOf());
      value.headMap(oldestNeeded).clear();
    } else {
      // Don't need any old values
      value.clear();
    }

    Instant lowestCurrentVersionFrom = value.firstKey();

    List<YieldCurveDefinitionDocument> orderedReplacementDocuments =
        MasterUtils.adjustVersionInstants(
            now, lowestCurrentVersionFrom, null, replacementDocuments);

    final Instant lowestVersionFrom = orderedReplacementDocuments.get(0).getVersionFromInstant();
    final Instant highestVersionTo =
        orderedReplacementDocuments
            .get(orderedReplacementDocuments.size() - 1)
            .getVersionToInstant();

    if (orderedReplacementDocuments.size() > 0) {
      value.subMap(lowestVersionFrom, true, highestVersionTo, false).clear();
    }

    for (YieldCurveDefinitionDocument replacementDocument : orderedReplacementDocuments) {
      value.put(
          replacementDocument.getVersionFromInstant(),
          replacementDocument.getYieldCurveDefinition());
      changeManager()
          .entityChanged(ChangeType.CHANGED, replacementDocument.getObjectId(), null, null, now);
    }
    return MasterUtils.mapToUniqueIDs(orderedReplacementDocuments);
  }