Exemple #1
1
  /**
   * Given a master list and the new sub list, replace the items in the master list with the
   * matching items from the new sub list. This process works even if the length of the new sublist
   * is different.
   *
   * <p>For example, givn:
   *
   * <pre>
   * replace A by A':
   *   M=[A,B,C], S=[A'] => [A',B,C]
   *   M=[A,B,A,B,C], S=[A',A'] => [A',B,A',B,C]
   *
   * when list length is different:
   *   M=[A,A,B,C], S=[] => [B,C]
   *   M=[A,B,C], S=[A',A'] => [A',A',B,C]
   *   M=[B,C], S=[A',A'] => [B,C,A',A']
   * </pre>
   */
  private static List<Child> stitchList(
      List<Child> list, String name, List<? extends Child> newSubList) {
    List<Child> removed = new LinkedList<Child>();
    // to preserve order, try to put new itesm where old items are found.
    // if the new list is longer than the current list, we put all the extra
    // after the last item in the sequence. That is,
    // given [A,A,B,C] and [A',A',A'], we'll update the list to [A',A',A',B,C]
    // The 'last' variable remembers the insertion position.
    int last = list.size();

    ListIterator<Child> itr = list.listIterator();
    ListIterator<? extends Child> jtr = newSubList.listIterator();
    while (itr.hasNext()) {
      Child child = itr.next();
      if (child.name.equals(name)) {
        if (jtr.hasNext()) {
          itr.set(jtr.next()); // replace
          last = itr.nextIndex();
          removed.add(child);
        } else {
          itr.remove(); // remove
          removed.add(child);
        }
      }
    }

    // new list is longer than the current one
    if (jtr.hasNext()) list.addAll(last, newSubList.subList(jtr.nextIndex(), newSubList.size()));

    return removed;
  }
  /** Check the 2 lists comparing the rows in order. If they are not the same fail the test. */
  public void checkRows(List<RowMetaAndData> rows1, List<RowMetaAndData> rows2) {
    if (rows1.size() != rows2.size()) {
      fail("Number of rows is not the same: " + rows1.size() + " and " + rows2.size());
    }
    ListIterator<RowMetaAndData> it1 = rows1.listIterator();
    ListIterator<RowMetaAndData> it2 = rows2.listIterator();

    while (it1.hasNext() && it2.hasNext()) {
      RowMetaAndData rm1 = it1.next();
      RowMetaAndData rm2 = it2.next();

      Object[] r1 = rm1.getData();
      Object[] r2 = rm2.getData();

      if (rm1.size() != rm2.size()) {
        fail("row nr " + it1.nextIndex() + " is not equal");
      }
      int[] fields = new int[r1.length];
      for (int ydx = 0; ydx < r1.length; ydx++) {
        fields[ydx] = ydx;
      }
      try {
        if (rm1.getRowMeta().compare(r1, r2, fields) != 0) {
          fail("row nr " + it1.nextIndex() + " is not equal");
        }
      } catch (KettleValueException e) {
        fail("row nr " + it1.nextIndex() + " is not equal");
      }
    }
  }
  public void testListIterator() {
    ListIterator<Integer> i;

    i = this.list.listIterator();

    assertFalse(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(0, i.nextIndex());
    assertEquals(Integer.valueOf(1), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(1, i.nextIndex());
    assertEquals(Integer.valueOf(2), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(2, i.nextIndex());
    assertEquals(Integer.valueOf(3), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(3, i.nextIndex());
    assertEquals(Integer.valueOf(10), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(4, i.nextIndex());
    assertEquals(Integer.valueOf(20), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(5, i.nextIndex());
    assertEquals(Integer.valueOf(21), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(6, i.nextIndex());
    assertEquals(Integer.valueOf(22), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(7, i.nextIndex());
    assertEquals(Integer.valueOf(23), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(8, i.nextIndex());
    assertEquals(Integer.valueOf(24), i.next());

    assertTrue(i.hasPrevious());
    assertTrue(i.hasNext());
    assertEquals(9, i.nextIndex());
    assertEquals(Integer.valueOf(25), i.next());

    assertTrue(i.hasPrevious());
    assertFalse(i.hasNext());
  }
Exemple #4
0
 /**
  * {@inheritDoc}
  *
  * <p>This implementation first gets a list iterator that points to the end of the list (with
  * {@code listIterator(size())}). Then, it iterates backwards over the list until the specified
  * element is found, or the beginning of the list is reached.
  *
  * @throws ClassCastException {@inheritDoc}
  * @throws NullPointerException {@inheritDoc}
  */
 public int lastIndexOf(Object o) {
   ListIterator<E> e = listIterator(size());
   if (o == null) {
     while (e.hasPrevious()) if (e.previous() == null) return e.nextIndex();
   } else {
     while (e.hasPrevious()) if (o.equals(e.previous())) return e.nextIndex();
   }
   return -1;
 }
 public void testNextIndex() {
   int i = 0;
   ListIterator stream = this.buildListIterator();
   while (stream.hasNext()) {
     assertEquals(i, stream.nextIndex());
     stream.next();
     i++;
   }
   assertEquals(i, stream.nextIndex());
 }
Exemple #6
0
  public LinkedList<MapLocation> pathFind(MapLocation start, MapLocation target)
      throws GameActionException {
    //		for (int i = 0; i < myRobot.allies.length; i++) {
    //			RobotInfo r = rc.senseRobotInfo(myRobot.allies[i]);
    //			if (myRobot.allies[i].getID() == myRobot.ID) continue;
    //			map[r.location.x][r.location.y] = -2;
    //		}
    //		for (int i = 0; i < myRobot.enemies.length; i++) {
    //			RobotInfo r = rc.senseRobotInfo(myRobot.enemies[i]);
    //			map[r.location.x][r.location.y] = -2;
    //		}
    int x = Clock.getRoundNum();
    SearchNode bugSearch = bugSearch(start, target);
    SearchNode[] nodes = new SearchNode[bugSearch.length];
    int counter = bugSearch.length - 1;
    while (bugSearch.prevLoc != null) {
      nodes[counter] = bugSearch;
      bugSearch = bugSearch.prevLoc;
      counter--;
    }

    nodes[0] = bugSearch;
    LinkedList<MapLocation> pivots = new LinkedList<MapLocation>();
    pivots.add(nodes[0].loc);

    for (int i = 1; i < nodes.length; i++) {
      if (nodes[i].isPivot) {
        pivots.add(nodes[i].loc);
      }
    }

    counter = 0;
    ListIterator<MapLocation> li1 = pivots.listIterator(), li2;
    while (li1.hasNext()) {
      li2 = pivots.listIterator(pivots.size());
      while (li2.hasPrevious() && li2.previousIndex() > li1.nextIndex() + 1) {
        if (canTravel(li1.next(), li2.previous())) {
          pivots.subList(li1.nextIndex(), li2.previousIndex() + 1).clear();
          li1 = pivots.listIterator(++counter);
          break;
        }
        li1.previous();
      }
      li1.next();
    }

    if (false) System.out.println(Clock.getRoundNum() - x);
    return pivots;
  }
  public IUpdate getProxyCrossReferencesUpdate(
      final EObject owner, final EReference crossReference) {
    IUpdate result = IUpdate.EMPTY;
    final CDOStore[] store = {null};

    for (ListIterator<? extends EObject> xrefs = CDOUtils.iterator(owner, crossReference, false);
        xrefs.hasNext(); ) {
      final int index = xrefs.nextIndex();
      final EObject referent = xrefs.next();

      if (!referent.eIsProxy() && !inSameUnit(owner, referent) && inSameModel(owner, referent)) {
        if (store[0] == null) {
          store[0] = ((InternalCDOView) CDOUtils.getCDOObject(owner).cdoView()).getStore();
        }

        result =
            result.chain(
                new OneWayUpdate() {

                  @Override
                  public void apply() {
                    store[0].set(
                        (InternalEObject) owner,
                        crossReference,
                        index,
                        CDOIDUtil.createExternal(createPapyrusCDOURI(referent)));
                  }
                });
      }
    }

    return result;
  }
    @Override
    public ClauseInfo next() {
      // Alessandro Montanari - [email protected]
      currentIndex = it.nextIndex();

      return it.next();
    }
Exemple #9
0
  /** Sorts the static LinkedList mainlineLinks in the order they appear on the freeway */
  private LinkedList<Link> recursiveLinkSort(LinkedList<Link> links2) {

    if (links2.size() == 1) {

      return links2;

    } else {

      boolean swapMade = false;
      ListIterator<Link> itr1 = links2.listIterator();
      while (itr1.hasNext()) {
        Link temp = itr1.next();
        int tempindex = itr1.nextIndex();
        // if this loop makes any switches, set the flag to true
        if (links2.getFirst().getUpNode().getNodeID() == temp.getDownNode().getNodeID()) {
          swapMade = true;
          links2.addFirst(temp);
          links2.remove(tempindex);
          return this.recursiveLinkSort(links2);
        }
      }

      if (!swapMade) {
        // assign last n-1 links to links3
        LinkedList<Link> links3 = new LinkedList<Link>();
        Link temp = links2.getFirst();
        links2.removeFirst();
        links3 = this.recursiveLinkSort(links2);
        links3.addFirst(temp);
        return links3;
      } else {
        return links2;
      }
    }
  }
  @Override
  protected void createUpcomingSelection() {
    if (!rightSubSelectionIterator.hasNext()) {
      if (!leftSubSelectionIterator.hasNext()) {
        upcomingSelection = null;
        return;
      }
      leftSubSelection = leftSubSelectionIterator.next();

      if (!leftEqualsRight) {
        rightSubSelectionIterator = rightSubSelector.listIterator();
        if (!rightSubSelectionIterator.hasNext()) {
          upcomingSelection = null;
          return;
        }
      } else {
        // Select A-B, A-C, B-C. Do not select B-A, C-A, C-B. Do not select A-A, B-B, C-C.
        if (!leftSubSelectionIterator.hasNext()) {
          upcomingSelection = null;
          return;
        }
        rightSubSelectionIterator =
            rightSubSelector.listIterator(leftSubSelectionIterator.nextIndex());
        // rightEntityIterator's first hasNext() always returns true because of the nextIndex()
      }
    }
    SubS rightSubSelection = rightSubSelectionIterator.next();
    upcomingSelection = newSwapSelection(leftSubSelection, rightSubSelection);
  }
 private void addTypeCastToExplicitReceiver(
     XAbstractFeatureCall featureCall,
     IModificationContext context,
     JvmType declaringType,
     EReference structuralFeature)
     throws BadLocationException {
   List<INode> nodes = NodeModelUtils.findNodesForFeature(featureCall, structuralFeature);
   if (nodes.isEmpty()) return;
   INode firstNode = IterableExtensions.head(nodes);
   INode lastNode = IterableExtensions.last(nodes);
   int offset = firstNode.getOffset();
   int length = lastNode.getEndOffset() - offset;
   ReplacingAppendable appendable =
       appendableFactory.create(
           context.getXtextDocument(), (XtextResource) featureCall.eResource(), offset, length);
   appendable.append("(");
   ListIterator<INode> nodeIter = nodes.listIterator();
   while (nodeIter.hasNext()) {
     String text = nodeIter.next().getText();
     if (nodeIter.previousIndex() == 0) appendable.append(Strings.removeLeadingWhitespace(text));
     else if (nodeIter.nextIndex() == nodes.size())
       appendable.append(Strings.trimTrailingLineBreak(text));
     else appendable.append(text);
   }
   appendable.append(" as ");
   appendable.append(declaringType);
   appendable.append(")");
   appendable.commitChanges();
 }
Exemple #12
0
  /**
   * Creates a dataset with the second argument as its id (if it has no such parameter it gets a
   * generated id) This method is called if the input string starts with "data" or if the input
   * string contains a tab (then a dataset is assumed) All lines until the next empty line are part
   * of the dataset
   *
   * @param args any parameters to the data command including the command itself as first parameter
   */
  private void createDatasetObject(String[] args, ListIterator<String> inputIterator) {
    int lineNr = inputIterator.nextIndex();
    String datasetId = null;
    if (args != null) {
      if (args.length > 1) {
        datasetId = args[1];
        /* handle further parameters here */
      }
    }
    DataSet newDataset = new DataSet(datasetId, datasetNr++, lineNr);
    while (inputIterator.hasNext()) {
      String nextLine = inputIterator.next();
      if (nextLine.matches(PlotConstants.REGEX_COMMENT)) {
        continue;
      } else if (nextLine.trim().isEmpty()) {
        break;
      } else {
        newDataset.addLine(nextLine.split(PlotConstants.REGEX_DATA_SEPARATOR));
      }
    }

    if (datasetId != null) {
      for (DataSet ds : datasetList) {
        if (datasetId.equals(ds.getId())) {
          throw new ParserException(
              "The dataset name \"" + datasetId + "\" (line: " + lineNr + ") already exists");
        }
      }
    }
    datasetList.add(newDataset);
  }
 private void lookForLocalTestTemplate() {
   localTemplateAtLine = NO_TEMPLATE;
   outer:
   for (int lineIdx = lineIterator.nextIndex() - 1; lineIdx < lines.size(); ++lineIdx) {
     RobotLine line = lines.get(lineIdx);
     assert line.lineNo - 1 == lineIdx;
     int settingKeyPos = 1;
     switch (line.type) {
       case TESTCASE_TABLE_TESTCASE_BEGIN:
       case TESTCASE_TABLE_TESTCASE_LINE:
         break;
       case CONTINUATION_LINE:
         settingKeyPos = determineContinuationLineArgOff(line);
         break;
       case COMMENT_LINE:
         continue;
       default:
         // testcase ended, do not look further
         break outer;
     }
     if (line.arguments.size() > settingKeyPos
         && line.arguments.get(settingKeyPos).getValue().equals("[Template]")) {
       localTemplateAtLine = line.lineNo;
       localTemplateAtColumn = settingKeyPos;
       // continue searching; last hit remains in effect
     }
   }
 }
Exemple #14
0
 private static boolean invoke(
     PageContext pc, List list, UDF udf, ExecutorService es, List<Future<Data<Object>>> futures)
     throws CasterException, PageException {
   ListIterator it = list.listIterator();
   boolean async = es != null;
   Object res, v;
   int index;
   ArgumentIntKey k;
   while (it.hasNext()) {
     index = it.nextIndex();
     k = ArgumentIntKey.init(index);
     v = it.next();
     res =
         _inv(
             pc,
             udf,
             new Object[] {v, Caster.toDoubleValue(k.getString()), list},
             k,
             v,
             es,
             futures);
     if (!async && !Caster.toBooleanValue(res)) return false;
   }
   return true;
 }
  public List<String> getUniqueLines(List<String> lines) {

    Collections.sort(
        lines,
        new Comparator<String>() {
          @Override
          public int compare(String s1, String s2) {
            return s1.length() == s2.length() ? s1.compareTo(s2) : s1.length() - s2.length();
          }
        });

    System.out.println("===========");
    System.out.println("Sorted lines:");

    dump(lines);

    ListIterator<String> outerIterator = lines.listIterator(0);

    while (outerIterator.hasNext()) {

      String currentString = outerIterator.next();

      boolean isLastIndex = (outerIterator.nextIndex() == lines.size());

      if (!isLastIndex) {
        ListIterator<String> innerIterator = lines.listIterator(outerIterator.nextIndex());

        while (innerIterator.hasNext()) {

          String comparedString = innerIterator.next();

          if (comparedString.contains(currentString)) {

            // remove the short string

            outerIterator.remove();

            // go to next currentString

            break;
          }
        }
      }
    }

    return lines;
  }
  public void testIterator() {
    ListIterator iter = (ListIterator) makeObject();
    assertTrue("Iterator should have next item", iter.hasNext());
    assertTrue("Iterator should have no previous item", !iter.hasPrevious());
    assertEquals("Iteration next index", 0, iter.nextIndex());
    assertEquals("Iteration previous index", -1, iter.previousIndex());

    Object iterValue = iter.next();
    assertEquals("Iteration value is correct", testValue, iterValue);

    assertTrue("Iterator should have no next item", !iter.hasNext());
    assertTrue("Iterator should have previous item", iter.hasPrevious());
    assertEquals("Iteration next index", 1, iter.nextIndex());
    assertEquals("Iteration previous index", 0, iter.previousIndex());

    iterValue = iter.previous();
    assertEquals("Iteration value is correct", testValue, iterValue);

    assertTrue("Iterator should have next item", iter.hasNext());
    assertTrue("Iterator should have no previous item", !iter.hasPrevious());
    assertEquals("Iteration next index", 0, iter.nextIndex());
    assertEquals("Iteration previous index", -1, iter.previousIndex());

    iterValue = iter.next();
    assertEquals("Iteration value is correct", testValue, iterValue);

    assertTrue("Iterator should have no next item", !iter.hasNext());
    assertTrue("Iterator should have previous item", iter.hasPrevious());
    assertEquals("Iteration next index", 1, iter.nextIndex());
    assertEquals("Iteration previous index", 0, iter.previousIndex());

    try {
      iter.next();
    } catch (Exception e) {
      assertTrue(
          "NoSuchElementException must be thrown",
          e.getClass().equals((new NoSuchElementException()).getClass()));
    }
    iter.previous();
    try {
      iter.previous();
    } catch (Exception e) {
      assertTrue(
          "NoSuchElementException must be thrown",
          e.getClass().equals((new NoSuchElementException()).getClass()));
    }
  }
Exemple #17
0
 public static void iterMotion(List a) {
   ListIterator it = a.listIterator();
   b = it.hasNext();
   b = it.hasPrevious();
   o = it.next();
   i = it.nextIndex();
   o = it.previous();
   i = it.previousIndex();
 }
 /*
    data for this specific object not internal objects
 */
 public List print() {
   for (ListIterator it = datas.listIterator(); it.hasNext(); ) {
     SnapShotData shotA = (SnapShotData) it.next();
     for (ListIterator it1 = datas.listIterator(Math.max(0, it.previousIndex() - maxTimeRelation));
         it1.hasNext() && it1.nextIndex() < it.nextIndex() + maxTimeRelation; ) {
       SnapShotData shotB = (SnapShotData) it1.next();
       if (it.previousIndex() != it1.previousIndex()) {
         for (int i = 0; i < shotB.getNodeShadows().length; i++) {
           storage +=
               getSpeedRatio(shotA.getNodeShadows()[i], shotB.getNodeShadows()[i])
                   * getRelativeDir(shotA.getNodeShadows()[i], shotB.getNodeShadows()[i]);
           numOfValue++;
         }
       }
     }
   }
   return Arrays.asList(storage / numOfValue);
 }
 void insertInList(final List<MethodEntry> list, Comparator<MethodEntry> comparator) {
   boolean inserted = false;
   ListIterator li = list.listIterator();
   while (li.hasNext() && !inserted) {
     MethodEntry entry = ((MethodEntry) li.next());
     if (comparator.compare(this, entry) < 0) {
       LOG.debug(
           "insertInList dependent method: add "
               + myEnd.toString()
               + " at index "
               + (li.nextIndex() - 1));
       list.add(li.nextIndex() - 1, this);
       inserted = true;
     }
   }
   if (!inserted) {
     list.add(this);
   }
 }
Exemple #20
0
 public static void verify(List output, List expected) {
   verifyLength(output.size(), expected.size(), Test.EXACT);
   if (!expected.equals(output)) {
     // find the line of mismatch
     ListIterator it1 = expected.listIterator();
     ListIterator it2 = output.listIterator();
     while (it1.hasNext() && it2.hasNext() && it1.next().equals(it2.next())) ;
     throw new LineMismatchException(
         it1.nextIndex(), it1.previous().toString(), it2.previous().toString());
   }
 }
Exemple #21
0
 public void setFixtures(List<TestFixture> fixtures) {
   this.fixtures = fixtures;
   if (fixtures != null) {
     for (ListIterator<TestFixture> iterator = fixtures.listIterator(); iterator.hasNext(); ) {
       int index = iterator.nextIndex();
       TestFixture testFixture = iterator.next();
       testFixture.setTestStation(this);
       testFixture.setPosition(index);
     }
   }
 }
  /**
   * Creates and returns a String representation of the Score.
   *
   * @return String the Score as a String
   */
  public String toString() {
    String scoreData = "Score: " + '\n';

    scoreData += "ChordProg: " + '\n' + chordProg.toString() + '\n';

    ListIterator<MelodyPart> i = partList.listIterator();
    while (i.hasNext()) {
      scoreData += "Part " + i.nextIndex() + ":" + '\n' + i.next().toString() + '\n';
    }
    return scoreData;
  }
 public void remove() {
   delegate.previous();
   Item item = findNext();
   if (item == null) {
     throw new IllegalStateException();
   }
   int index = delegate.nextIndex();
   props.items.remove(item);
   props.itemIndex.remove(item.getKey());
   delegate = props.items.listIterator(index);
 }
Exemple #24
0
 public void setTestLimits(List<TestStationLimit> testLimits) {
   this.testLimits = testLimits;
   if (testLimits != null) {
     for (ListIterator<TestStationLimit> iterator = testLimits.listIterator();
         iterator.hasNext(); ) {
       int index = iterator.nextIndex();
       TestStationLimit testLimit = iterator.next();
       testLimit.setTestStation(this);
       testLimit.setPosition(index);
     }
   }
 }
Exemple #25
0
 public void setProperties(List<TestStationProperty> properties) {
   this.properties = properties;
   if (properties != null) {
     for (ListIterator<TestStationProperty> iterator = properties.listIterator();
         iterator.hasNext(); ) {
       int index = iterator.nextIndex();
       TestStationProperty testStationProperty = iterator.next();
       testStationProperty.setTestStation(this);
       testStationProperty.setPosition(index);
     }
   }
 }
  /**
   * Returns all packages belonging to this project.
   *
   * @return The array of this project's packages, if none exist an empty array is returned.
   * @throws ProjectNotOpenException if the project has been closed by the user.
   */
  public BPackage[] getPackages() throws ProjectNotOpenException {
    Project thisProject = projectId.getBluejProject();

    List<String> names = thisProject.getPackageNames();
    BPackage[] packages = new BPackage[names.size()];
    for (ListIterator<String> li = names.listIterator(); li.hasNext(); ) {
      int i = li.nextIndex();
      String name = li.next();
      packages[i] = getPackage(name);
    }
    return packages;
  }
  @Override
  public Object getCurrentElement() throws IteratorException {

    Object obj = null;
    if (list != null) {
      int currIndex = listIterator.nextIndex();
      obj = list.get(currIndex);
    } else {
      throw new IteratorException();
    }
    return obj;
  }
Exemple #28
0
  public ParserResult parse(String source) {

    List<String> inputList = Arrays.asList(source.split("\n", -1));
    ListIterator<String> inputIterator = inputList.listIterator();

    while (inputIterator.hasNext()) {
      String line = inputIterator.next();
      if (line.isEmpty() || line.matches(PlotConstants.REGEX_COMMENT)) {
        /* ignore empty lines and comments */
      } else if (line.matches(PlotConstants.REGEX_PLOT)) {
        parserResult.addPlotState(createPlotStateObject(line.split(" "), inputIterator));
      } else if (line.matches(PlotConstants.REGEX_PLOT_ADD)) {
        List<PlotState> plotStates = parserResult.getPlotStateList();
        if (plotStates.isEmpty()) {
          // if no plotStates, create a new one
          parserResult.addPlotState(createPlotStateObject(line.split(" "), inputIterator));
        } else {
          // if plots exist, add new plotState to last plotState
          PlotState last = plotStates.get(plotStates.size() - 1);
          last.addSubPlot(createPlotStateObject(line.split(" "), inputIterator));
        }
      } else if (line.matches(PlotConstants.REGEX_DATA)) {
        createDatasetObject(line.split(" "), inputIterator);
      } else if (line.matches(PlotConstants.REGEX_DATA_GUESS)) {
        inputIterator
            .previous(); // Must go 1 step back to avoid skipping the first line in
                         // createDatasetObject
        createDatasetObject(new String[] {PlotConstants.DATA}, inputIterator);
      } else if (line.matches(PlotConstants.REGEX_VALUE_ASSIGNMENT)) {
        createKeyValueAssignment(line, inputIterator.nextIndex());
      } else {
        throw new ParserException(
            "Invalid line: " + line + "(line: " + inputIterator.nextIndex() + ")");
      }
    }

    analyseDatasets();
    addDatasetsToPlotStates();
    return parserResult;
  }
 private static boolean startOfNewRecursiveObject(
     ListIterator<Field> fieldIterator, List<Field> fieldsList, Class<?> segmentGroupClass) {
   Field nextField = fieldsList.get(fieldIterator.nextIndex());
   if (nextField.getType().equals(segmentGroupClass)) {
     return true;
   }
   if (Collection.class.isAssignableFrom(nextField.getType())) {
     final ParameterizedType genericType = (ParameterizedType) nextField.getGenericType();
     Type collectionType = genericType.getActualTypeArguments()[0];
     return segmentGroupClass.equals(collectionType);
   }
   return false;
 }
Exemple #30
0
 /**
  * Returns the index of the Unit previous to the index indicated.
  *
  * @param slotIndex the index of the slot to start searching from
  * @return int the index of the previous Unit
  */
 public int getPrevIndex(int slotIndex) {
   if (slotIndex < 0) {
     return -1;
   }
   ListIterator<Unit> i = slots.listIterator(slotIndex);
   while (i.hasPrevious()) {
     Unit unit = i.previous();
     if (unit != null) {
       return i.nextIndex();
     }
   }
   return -1;
 }