Esempio n. 1
0
  private static Set<Link> getLinks(ArrayList<String> linkList, Entry entry) {
    Set<Link> existingLinks = entry.getLinks();
    Set<Link> links = new HashSet<>();

    if (existingLinks == null) existingLinks = new HashSet<>();

    if (linkList == null) return existingLinks;

    for (int i = 0; i < linkList.size(); i++) {
      String currentItem = linkList.get(i);
      Link link;

      if (existingLinks.size() > i) {
        link = (Link) existingLinks.toArray()[i];
      } else {
        link = new Link();
        existingLinks.add(link);
      }
      link.setLink(currentItem);
      link.setEntry(entry);
      links.add(link);
    }

    return links;
  }
Esempio n. 2
0
  private static Set<SelectionMarker> getSelectionMarkers(
      ArrayList<String> markerStr, Entry entry) {
    Set<SelectionMarker> existingMarkers = entry.getSelectionMarkers();
    Set<SelectionMarker> markers = new HashSet<>();

    if (existingMarkers == null) existingMarkers = new HashSet<>();

    if (markerStr != null) {
      int itemLength = markerStr.size();

      for (int i = 0; i < itemLength; i++) {
        String currentItem = markerStr.get(i);
        SelectionMarker marker;

        if (existingMarkers.size() > i) {
          marker = (SelectionMarker) existingMarkers.toArray()[i];
        } else {
          marker = new SelectionMarker();
          existingMarkers.add(marker);
        }

        marker.setName(currentItem);
        marker.setEntry(entry);
        markers.add(marker);
      }
    } else return null;

    return markers;
  }