Java Code Examples for java.util.ListIterator.next()

The following are Jave code examples for showing how to use next() of the java.util.ListIterator class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: elasticsearch_my   File: MultiPhrasePrefixQuery.java   View Source Code Vote up 6 votes
private boolean termArraysEquals(List<Term[]> termArrays1, List<Term[]> termArrays2) {
    if (termArrays1.size() != termArrays2.size()) {
        return false;
    }
    ListIterator<Term[]> iterator1 = termArrays1.listIterator();
    ListIterator<Term[]> iterator2 = termArrays2.listIterator();
    while (iterator1.hasNext()) {
        Term[] termArray1 = iterator1.next();
        Term[] termArray2 = iterator2.next();
        if (!(termArray1 == null ? termArray2 == null : Arrays.equals(termArray1,
                termArray2))) {
            return false;
        }
    }
    return true;
}
 
Example 2
Project: jmt   File: NetSystem.java   View Source Code Vote up 6 votes
/** Starts the NetSystem Engine and executes the simulation.
 * This method should be called when <b>all</b> NetNode of <b>all</b>
 * QueueNetworks are ready to start.
 * @throws Exception
 */
public static void start() throws Exception {
	NetNode Node;
	ListIterator<QueueNetwork> nets = networkList.listIterator();
	ListIterator<NetNode> nodes;
	QueueNetwork Network;
	startTime = System.currentTimeMillis();

	while (nets.hasNext()) {
		Network = nets.next();
		if (Network.getState() == QueueNetwork.STATE_READY) {
			nodes = Network.getNodes().listIterator();
			while (nodes.hasNext()) {
				Node = nodes.next();
				Node.send(NetEvent.EVENT_START, null, 0.0, NodeSection.NO_ADDRESS, NodeSection.INPUT, Node);
				Node.send(NetEvent.EVENT_START, null, 0.0, NodeSection.NO_ADDRESS, NodeSection.SERVICE, Node);
				Node.send(NetEvent.EVENT_START, null, 0.0, NodeSection.NO_ADDRESS, NodeSection.OUTPUT, Node);
			}
			Network.setState(QueueNetwork.STATE_RUNNING);
		}
	}

	netController.start();
	netController.run();
}
 
Example 3
Project: athena   File: RangeRestrictionListenerTest.java   View Source Code Vote up 6 votes
/**
 * Checks valid range statement as sub-statement of leaf statement.
 */
@Test
public void processValidRangeStatement() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/ValidRangeStatement.yang");

    assertThat((node instanceof YangModule), is(true));
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getDataType().getDataTypeName(), is("int32"));
    assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.INT32));
    YangRangeRestriction rangeRestriction = (YangRangeRestriction) leafInfo
            .getDataType().getDataTypeExtendedInfo();

    ListIterator<YangRangeInterval> rangeListIterator = rangeRestriction.getAscendingRangeIntervals()
            .listIterator();
    YangRangeInterval rangeInterval = rangeListIterator.next();
    assertThat(((YangInt32) rangeInterval.getStartValue()).getValue(), is(1));
    assertThat(((YangInt32) rangeInterval.getEndValue()).getValue(), is(4));
}
 
Example 4
Project: athena   File: TypeListenerTest.java   View Source Code Vote up 6 votes
/**
 * Checks type for leaf-list.
 */
@Test
public void processLeafListSubStatementType() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/LeafListSubStatementType.yang");

    // Check whether the data model tree returned is of type module.
    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeafList> leafListIterator = yangNode.getListOfLeafList().listIterator();
    YangLeafList leafListInfo = leafListIterator.next();

    assertThat(leafListInfo.getName(), is("invalid-interval"));
    assertThat(leafListInfo.getDataType().getDataTypeName(), is("uint16"));
    assertThat(leafListInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
}
 
Example 5
Project: athena   File: UnitsListenerTest.java   View Source Code Vote up 6 votes
/**
 * Checks the default value of unit statement.
 */
@Test
public void processUnitsDefaultValue() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/UnitsDefaultValue.yang");

    // Check whether the data model tree returned is of type module.
    assertThat(node instanceof YangModule, is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getUnits(), is(nullValue()));
}
 
Example 6
Project: RNLearn_Project1   File: NativeAnimatedNodesManager.java   View Source Code Vote up 6 votes
public void removeAnimatedEventFromView(int viewTag, String eventName, int animatedValueTag) {
  String key = viewTag + eventName;
  if (mEventDrivers.containsKey(key)) {
    List<EventAnimationDriver> driversForKey = mEventDrivers.get(key);
    if (driversForKey.size() == 1) {
      mEventDrivers.remove(viewTag + eventName);
    } else {
      ListIterator<EventAnimationDriver> it = driversForKey.listIterator();
      while (it.hasNext()) {
        if (it.next().mValueNode.mTag == animatedValueTag) {
          it.remove();
          break;
        }
      }
    }
  }
}
 
Example 7
Project: athena   File: TypeListenerTest.java   View Source Code Vote up 6 votes
/**
 * Checks derived statement without contraints.
 */
@Test
public void processDerivedTypeStatement() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/DerivedTypeStatement.yang");

    // Check whether the data model tree returned is of type module.
    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getDataType().getDataTypeName(), is("hello"));
    assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.DERIVED));
}
 
Example 8
Project: jdk8u-jdk   File: PolicyTool.java   View Source Code Vote up 6 votes
/**
 * convert the Principals portion of this policy entry into a string
 */
String principalsToString() {
    String result = "";
    if ((grantEntry.principals != null) &&
        (!grantEntry.principals.isEmpty())) {
        StringBuffer buffer = new StringBuffer(200);
        ListIterator<PolicyParser.PrincipalEntry> list =
                            grantEntry.principals.listIterator();
        while (list.hasNext()) {
            PolicyParser.PrincipalEntry pppe = list.next();
            buffer.append(" Principal " + pppe.getDisplayClass() + " " +
                pppe.getDisplayName(true));
            if (list.hasNext()) buffer.append(", ");
        }
        result = buffer.toString();
    }
    return result;
}
 
Example 9
Project: athena   File: MandatoryListenerTest.java   View Source Code Vote up 6 votes
/**
 * Checks valid mandatory with value false statement.
 */
@Test
public void processMandatoryFalse() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/MandatoryFalse.yang");

    // Check whether the data model tree returned is of type module.
    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    ListIterator<YangLeaf> leafIterator = yangNode.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    // Check whether the mandatory value is set correctly.
    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.isMandatory(), is(false));
}
 
Example 10
Project: athena   File: ListListenerTest.java   View Source Code Vote up 5 votes
/**
 * Checks list with all its sub-statements.
 */
@Test
public void processListSubStatements() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/ListSubStatements.yang");

    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    // Check whether the list is child of module
    YangList yangList = (YangList) yangNode.getChild();

    // Check whether list properties as set correctly.
    assertThat(yangList.getName(), is("ospf"));
    assertThat(yangList.getKeyList().contains("invalid-interval"), is(true));

    assertThat(yangList.isConfig(), is(true));
    assertThat(yangList.getMaxElements(), is(10));
    assertThat(yangList.getMinElements(), is(3));
    assertThat(yangList.getDescription(), is("\"list description\""));
    assertThat(yangList.getStatus(), is(YangStatusType.CURRENT));
    assertThat(yangList.getReference(), is("\"list reference\""));

    // Check whether leaf properties as set correctly.
    ListIterator<YangLeaf> leafIterator = yangList.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
    assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
    assertThat(leafInfo.getUnits(), is("\"seconds\""));
    assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
    assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
}
 
Example 11
Project: myfaces-trinidad   File: ShowOneListRendererBase.java   View Source Code Vote up 5 votes
/**
 *  Returns first disclosed child's Id.
 *
 * @param context the facesContext object
 * @param component
 * @return String id of the first showDetailItem child that can be rendered
 *                and is disclosed
 * @throws IOException
 */
@SuppressWarnings("unchecked")
private static String _getDisclosedItemId(FacesContext context,
                                          UIComponent component)
  throws IOException
{
  String returnId = null;
  ListIterator<UIComponent> iter = component.getChildren().listIterator();

  if (iter == null)
  {
    return null;
  }

  // This will only render UIXShowDetail children.
  // other children are ignored.
  while ( iter.hasNext())
  {
    UIComponent child = iter.next();
    if (! child.isRendered() )
    {
      continue;
    }

    // only CoreShowDetailItem children are rendered. Rest are ignored.
    if ( (child instanceof UIXShowDetail))
    {
      UIXShowDetail detailChild = (UIXShowDetail) child;
      if (detailChild.isDisclosed())
      {
        returnId = detailChild.getClientId(context);
        break;
      }
    }
  }
  return returnId;
}
 
Example 12
Project: scorekeeperfrontend   File: BarcodeScannerWatcher.java   View Source Code Vote up 5 votes
/**
 * Run through the queue to see if we got a possible match of:
 * [0] stx, [1 - (n-1)] Integers within time frame, [n]
 * @return the count of key events we can dump out to the user
 */
private int _scanQueue()
{
    StringBuilder barcode = new StringBuilder();
    ListIterator<KeyEvent> iter = queue.listIterator();

    KeyEvent first = iter.next();
    if ((first.getID() != KeyEvent.KEY_TYPED) || (first.getKeyChar() != config.stx))
        return 1;
    
    while (iter.hasNext())
    {
        KeyEvent ke = iter.next();            
        if (ke.getID() != KeyEvent.KEY_TYPED)  // only look at TYPED events
            continue;

        Character c = ke.getKeyChar();
        if (c == config.stx) // a second stx char, clear buffer before this 
            return iter.nextIndex()-1;
        
        if (c == config.etx) {
            queue.clear();
            log.log(Level.FINE, "Scanned barcode {0}", barcode);
            Messenger.sendEvent(MT.BARCODE_SCANNED, barcode.toString());
            return iter.nextIndex();  // time to dump
        }

        barcode.append(c);            
        if (barcode.length() > 20) {
            log.log(Level.FINE, "Barcode too long, ignoring");
            return iter.nextIndex(); // time to dump
        }
    }

    return 0;
}
 
Example 13
Project: openjdk-jdk10   File: SubList.java   View Source Code Vote up 5 votes
@Test(dataProvider = "modifiable",
      expectedExceptions = ConcurrentModificationException.class)
public void testModListIteratorNext(List<Integer> list, int from, int to) {
    List<Integer> subList = list.subList(from, to);
    ListIterator<Integer> it = subList.listIterator();
    list.add(42);
    it.next();
}
 
Example 14
Project: athena   File: ContainerListenerTest.java   View Source Code Vote up 5 votes
/**
 * Checks container with all its sub-statements.
 */
@Test
public void processContainerSubStatements() throws IOException, ParserException {

    YangNode node = manager.getDataModel("src/test/resources/ContainerSubStatements.yang");

    assertThat((node instanceof YangModule), is(true));

    // Check whether the node type is set properly to module.
    assertThat(node.getNodeType(), is(YangNodeType.MODULE_NODE));

    // Check whether the module name is set correctly.
    YangModule yangNode = (YangModule) node;
    assertThat(yangNode.getName(), is("Test"));

    // Check whether the container is child of module
    YangContainer yangContainer = (YangContainer) yangNode.getChild();

    // Check whether container properties as set correctly.
    assertThat(yangContainer.getName(), is("ospf"));

    assertThat(yangContainer.isConfig(), is(true));
    assertThat(yangContainer.getPresence(), is("\"ospf logs\""));
    assertThat(yangContainer.getDescription(), is("\"container description\""));
    assertThat(yangContainer.getStatus(), is(YangStatusType.CURRENT));
    assertThat(yangContainer.getReference(), is("\"container reference\""));

    // Check whether leaf properties as set correctly.
    ListIterator<YangLeaf> leafIterator = yangContainer.getListOfLeaf().listIterator();
    YangLeaf leafInfo = leafIterator.next();

    assertThat(leafInfo.getName(), is("invalid-interval"));
    assertThat(leafInfo.getDataType().getDataTypeName(), is("uint16"));
    assertThat(leafInfo.getDataType().getDataType(), is(YangDataTypes.UINT16));
    assertThat(leafInfo.getUnits(), is("\"seconds\""));
    assertThat(leafInfo.getStatus(), is(YangStatusType.CURRENT));
    assertThat(leafInfo.getReference(), is("\"RFC 6020\""));
}
 
Example 15
Project: Spark   File: SparksList.java   View Source Code Vote up 5 votes
public final void drawSparks()
{
	final ListIterator<Sparks> iterator = SparkList.listIterator();

	while (iterator.hasNext())
	{
		final Sparks spark = iterator.next();

		if (spark.Active == true)
		{
			spark.Render();
		}
	}
}
 
Example 16
Project: QN-ACTR-Release   File: NetworkList.java   View Source Code Vote up 5 votes
/** Gets the network in the list, if it exists, which has the specified Name.
 * @return The network called "Name". Returns Null if it doesn't exist.
 */
public QueueNetwork get(String name) {
	ListIterator<QueueNetwork> iterator = networks.listIterator();
	QueueNetwork jc;
	while (iterator.hasNext()) {
		jc = iterator.next();
		if (jc.getName().compareTo(name) == 0) {
			return jc;
		}
	}
	return null;
}
 
Example 17
Project: LightSIP   File: SDPFieldList.java   View Source Code Vote up 5 votes
/**
* Encode into a canonical string.
*/
public String encode() {
    StringBuilder retval = new StringBuilder();
    ListIterator li = sdpFields.listIterator();
    while (li.hasNext()) {
        SDPField sdphdr = (SDPField) li.next();
        retval.append(sdphdr.encode());
    }
    return retval.toString();
}
 
Example 18
Project: incubator-netbeans   File: ActiveRegion.java   View Source Code Vote up 5 votes
private ActiveRegion next_sibling_of(ActiveRegion child) {
    ListIterator<ActiveRegion> iter = children.listIterator();
    while (iter.hasNext()) {
        ActiveRegion candidate = iter.next();
        if (candidate == child) {
            return iter.hasNext() ? iter.next() : null;
        }
    }
    return null;
}
 
Example 19
Project: athena   File: BgpSelectionAlgo.java   View Source Code Vote up 4 votes
/**
 * Stores BGP basic attributes of two objects.
 *
 * @param listIteratorObj1 list iterator of object1
 * @param listIteratorObj2 list iterator of object2
 */
void storeAttr(ListIterator<BgpValueType> listIteratorObj1, ListIterator<BgpValueType> listIteratorObj2) {
     while (listIteratorObj1.hasNext()) {
         BgpValueType pathAttributeObj1 = listIteratorObj1.next();
         switch (pathAttributeObj1.getType()) {
         case LocalPref.LOCAL_PREF_TYPE:
             obj1LocPref = (LocalPref) pathAttributeObj1;
             break;
         case AsPath.ASPATH_TYPE:
             obj1Aspath = (AsPath) pathAttributeObj1;
             break;
         case Origin.ORIGIN_TYPE:
             obj1Origin = (Origin) pathAttributeObj1;
             break;
         case Med.MED_TYPE:
             obj1Med = (Med) pathAttributeObj1;
             break;
         default:
             log.debug("Got other type, Not required: " + pathAttributeObj1.getType());
         }
     }
     while (listIteratorObj2.hasNext()) {
         BgpValueType pathAttributeObj2 = listIteratorObj2.next();
         switch (pathAttributeObj2.getType()) {
         case LocalPref.LOCAL_PREF_TYPE:
             obj2LocPref = (LocalPref) pathAttributeObj2;
             break;
         case AsPath.ASPATH_TYPE:
             obj2Aspath = (AsPath) pathAttributeObj2;
             break;
         case Origin.ORIGIN_TYPE:
             obj2Origin = (Origin) pathAttributeObj2;
             break;
         case Med.MED_TYPE:
             obj2Med = (Med) pathAttributeObj2;
             break;
         default:
             log.debug("Got other type, Not required: " + pathAttributeObj2.getType());
         }
    }
}
 
Example 20
Project: ChronoBike   File: CMapSetElement.java   View Source Code Vote up 4 votes
public CBaseResourceEntity DoSemanticAnalysis(CDataEntity parent, CBaseEntityFactory factory)
	{
		CEntityResourceFormContainer eFC = factory.NewEntityFormContainer(getLine(), getName(), false) ;
		ListIterator i = m_children.listIterator() ;
		try
		{
			CBMSElement le = (CBMSElement)i.next() ;
			while (le != null)
			{
				if (le.GetType()==EBMSElementType.MAP)
				{
					if (m_resStrings != null)
					{
						le.SetResourceStrings(m_resStrings) ;
					}
					CEntityResourceForm form = (CEntityResourceForm)le.DoSemanticAnalysis(eFC, factory) ;
					if (m_resStrings == null)
					{
						m_resStrings = le.GetResourceStrings(); 
					}
					if (form != null)
					{
						form.m_Of = eFC ;
						eFC.AddForm(form) ;
						form.setResourceName(getName()) ;
						if (form.GetName().endsWith("F"))
						{
//							m_arrAccessors.addElement(le.GetName()) ;
							form.SetReferences(m_arrAccessors) ;
						}
					}
					else if (form == null)
					{
						m_arrAccessors.addElement(le.getName());
					}
				}
				le = (CBMSElement)i.next() ;
			}
		}
		catch (NoSuchElementException e)
		{
			//System.out.println(e.toString());
		}
		eFC.m_resStrings = m_resStrings ;
		return eFC ;
	}