Java Code Examples for java.util.ArrayList.iterator()

The following are Jave code examples for showing how to use iterator() of the java.util.ArrayList 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: unitimes   File: PdfInstructionalOfferingTableBuilder.java   View Source Code Vote up 6 votes
private void pdfBuildSchedulingSubpartRows(Vector subpartIds, ClassAssignmentProxy classAssignment, ExamAssignmentProxy examAssignment, CourseOffering co, SchedulingSubpart ss, String indentSpaces, SessionContext context){
  	if (subpartIds!=null) subpartIds.add(ss.getUniqueId());
      pdfBuildSchedulingSubpartRow(classAssignment, examAssignment, co, ss, indentSpaces, context);
      Set childSubparts = ss.getChildSubparts();
      
if (childSubparts != null && !childSubparts.isEmpty()){
    
    ArrayList childSubpartList = new ArrayList(childSubparts);
    Collections.sort(childSubpartList, new SchedulingSubpartComparator());
          Iterator it = childSubpartList.iterator();
          SchedulingSubpart child = null;
          
          while (it.hasNext()){              
              child = (SchedulingSubpart) it.next();
              pdfBuildSchedulingSubpartRows(subpartIds, classAssignment, examAssignment, co, child, indentSpaces + indent, context);
          }
      }
  }
 
Example 2
Project: ctsms   File: QueryUtil.java   View Source Code Vote up 6 votes
private static void appendJoins(StringBuilder statement, HashMap<String, AssociationPath> explicitJoinsMap) {
	ArrayList<AssociationPath> joins = new ArrayList<AssociationPath>(explicitJoinsMap.values());
	Collections.sort(joins, new JoinComparator());
	Iterator<AssociationPath> it = joins.iterator();
	while (it.hasNext()) {
		AssociationPath join = it.next();
		StringBuilder joinSb = new StringBuilder(" left join ");
		joinSb.append(join.getAliasedPathString());
		joinSb.append(" as ");
		joinSb.append(join.getJoinAlias());
		statement.append(joinSb);
	}
}
 
Example 3
Project: ralasafe   File: AbstractPolicyDesignHandler.java   View Source Code Vote up 6 votes
public boolean isTestUserNeeded() {
	DefineVariable[] variables=getVariables();
	
	for( int i=0; i<variables.length; i++ ) {
		DefineVariable var=variables[i];
		
		if( var.getUserValue()!=null ) {
			return true;
		} else if( var.getQueryRef()!=null ) {
			int refId=var.getQueryRef().getId();
			
			Query query=queryManager.getQuery( refId );
			ArrayList values=query.getSqlQuery().getValues();
			
			for( Iterator iter=values.iterator(); iter.hasNext(); ) {
				Value v=(Value) iter.next();
				
				if( v instanceof org.ralasafe.db.sql.UserValue ) {
					return true;				
				}
			}
		}
	}
	
	return false;
}
 
Example 4
Project: ctsms   File: MoveAdapter.java   View Source Code Vote up 6 votes
protected ArrayList<LISTITEMVO> normalizePositions(LISTITEM groupItem, ROOT root) throws Exception {
	checkRoot(root);
	Timestamp now = new Timestamp(System.currentTimeMillis());
	User user = CoreUtil.getUser();
	long position = CommonUtil.LIST_INITIAL_POSITION;
	ArrayList<LISTITEM> items = getItemsSorted(getRootId(root), groupItem);
	ArrayList<LISTITEMVO> updated = new ArrayList<LISTITEMVO>(items.size());
	Iterator<LISTITEM> it = items.iterator();
	while (it.hasNext()) {
		LISTITEM item = it.next();
		if (getPosition(item) != position) {
			checkItem(item);
			LISTITEMVO original = toVO(item);
			setPosition(item, position);
			CoreUtil.modifyVersion(item, item, now, user);
			daoUpdate(item);
			updated.add(logSystemMessage(item, original, now, user, PositionMovement.NORMALIZE));
		}
		position += 1L;
	}
	if (updated.size() > 0) {
		logUpdatedPositionsSystemMessage(root, PositionMovement.NORMALIZE, updated, now, user);
	}
	return updated;
}
 
Example 5
Project: boohee_v5.6   File: ImageGridAdapter.java   View Source Code Vote up 5 votes
public void setDefaultSelected(ArrayList<String> resultList) {
    if (resultList != null) {
        this.mResultList = resultList;
        this.mSelectedImages.clear();
        Iterator i$ = resultList.iterator();
        while (i$.hasNext()) {
            Image image = getImageByPath((String) i$.next());
            if (image != null) {
                this.mSelectedImages.add(image);
            }
        }
    }
}
 
Example 6
Project: n4js   File: N4JSClassifierWizardModelValidator.java   View Source Code Vote up 5 votes
@Override
protected void prepare() {
	// ---------------------------------------
	// Automatic regulative constraints
	// ---------------------------------------

	// Auto disable the N4JS annotation field when definition file (external) is unselected.
	if (!getModel().isDefinitionFile() && getModel().isN4jsAnnotated()) {
		getModel().setN4jsAnnotated(false);
	}
	// Auto disable the Internal annotation for the private and project access modifier
	if ((getModel().getAccessModifier() == AccessModifier.PRIVATE
			|| getModel().getAccessModifier() == AccessModifier.PROJECT) && getModel().isInternal()) {
		getModel().setInternal(false);
	}
	// Auto disable the N4JS annotation for the private access modifier
	if (getModel().getAccessModifier() == AccessModifier.PRIVATE) {
		getModel().setN4jsAnnotated(false);
	}

	// Remove interfaces duplicate entries
	ArrayList<ClassifierReference> interfaces = new ArrayList<>(getModel().getInterfaces());

	Set<String> duplicateFullSpecifiers = Sets.newHashSet();

	for (Iterator<ClassifierReference> itr = interfaces.iterator(); itr.hasNext();/**/) {
		ClassifierReference next = itr.next();
		if (!duplicateFullSpecifiers.add(next.getFullSpecifier())) {
			itr.remove();
		}
		// Also remove empty entries
		if (next.classifierName.isEmpty()) {
			itr.remove();
		}
	}

	getModel().setInterfaces(interfaces);
}
 
Example 7
Project: tap17-muggl-javaee   File: ArrayModificationHandler.java   View Source Code Vote up 5 votes
/**
 * Initialize the ArrayModificationHandler.
 * @param array The array this handler will work on. Can be null to indicate a new array is being worked on.
 * @param typeString A String characterizing the type stored.
 * @param isPrimitive Indicates whether the array is a wrapper type for a primitive array.
 * @throws GUIException If a type is encountered that no array can be created for as it will not be supported by the GUI anyway.
 */
public ArrayModificationHandler(Object[] array, String typeString, boolean isPrimitive) throws GUIException {
	this.array = array;
	this.typeString = typeString;
	this.isPrimitive = isPrimitive;

	// Initialize the array if needed.
	if (this.array == null) {
		this.array = getNewArray();
	} else {
		// Build up the dimensions length.
		ArrayList<Integer> dimensionsArrayList = new ArrayList<Integer>();
		Object currentDimension = this.array;
		while (currentDimension.getClass().isArray()) {
			int length = ((Object[]) currentDimension).length;
			dimensionsArrayList.add(Integer.valueOf(length));
			if (length == 0) break;
			currentDimension = ((Object[]) currentDimension)[0];
		}
		this.dimensionsLength = new int[dimensionsArrayList.size()];
		Iterator<Integer> iterator = dimensionsArrayList.iterator();
		int a = 0;
		while (iterator.hasNext()) {
			this.dimensionsLength[a] = iterator.next();
			a++;
		}
	}

	// At the beginning, we assume that there is a return value.
	this.hasAReturnValue = true;
}
 
Example 8
Project: ALTTPMenuPractice   File: ControllerHandler.java   View Source Code Vote up 5 votes
public synchronized void fireEvents(SNESInputEvent e) {
	if (brat != null) {
		brat.fireSNESInputEvent(e);
		return;
	}

	ArrayList<SNESControllable> firing = new ArrayList<SNESControllable>();
	firing.addAll(children);

	Iterator<SNESControllable> i = firing.iterator();
	while (i.hasNext()) {
		(i.next()).fireSNESInputEvent(e);
	}
}
 
Example 9
Project: lams   File: PersistentBag.java   View Source Code Vote up 5 votes
@Override
@SuppressWarnings("unchecked")
public Iterator getDeletes(CollectionPersister persister, boolean indexIsFormula) throws HibernateException {
	final Type elementType = persister.getElementType();
	final ArrayList deletes = new ArrayList();
	final List sn = (List) getSnapshot();
	final Iterator olditer = sn.iterator();
	int i=0;
	while ( olditer.hasNext() ) {
		final Object old = olditer.next();
		final Iterator newiter = bag.iterator();
		boolean found = false;
		if ( bag.size()>i && elementType.isSame( old, bag.get( i++ ) ) ) {
		//a shortcut if its location didn't change!
			found = true;
		}
		else {
			//search for it
			//note that this code is incorrect for other than one-to-many
			while ( newiter.hasNext() ) {
				if ( elementType.isSame( old, newiter.next() ) ) {
					found = true;
					break;
				}
			}
		}
		if ( !found ) {
			deletes.add( old );
		}
	}
	return deletes.iterator();
}
 
Example 10
Project: MCPEWorldConverter   File: ListTag.java   View Source Code Vote up 5 votes
public void remove(String name){
    ArrayList<Tag> list = getValue();
    if(list == null) return;
    Iterator it = list.iterator();
    while(it.hasNext()){
        Tag tag = (Tag) it.next();
        if(tag.getName().equals(name)) {
            it.remove();
            setValue(list);
            break;
        }
    }
}
 
Example 11
Project: incubator-netbeans   File: SaasCatalog.java   View Source Code Vote up 5 votes
/**
 * Get String iterator representing all public IDs registered in catalog.
 * @return null if cannot proceed, try later.
 */
public java.util.Iterator getPublicIDs() {
    ArrayList<String> ids = new ArrayList<String>();
    ids.add(SAAS_SERVICES_1_0_ID);
    
    return ids.iterator();
}
 
Example 12
Project: TechnicalAnalysisTool   File: TatMain.java   View Source Code Vote up 5 votes
/**
 * Method to close OBV setting Pane for a OHLC
 * @param category - OHLC category name
 * @param market - OHLC market name
 * @param code - OHLC code name
 */
public void closeIndicatorOBVSettingPane(String category, String market, String code){
    String strTitle = "Indicator Setting";
    if (leftBottomTabPane.hasTab(strTitle)){
        //Remove it from the indicatorSettingMap;
        String strKey = category + "-" + market + "-" + code;
        Iterator<TitledPane> it = indicatorSettingPaneMap.get(strKey).iterator();
        while(it.hasNext()){
            TitledPane pane = it.next();
            if (pane instanceof IndicatorOBVSettingPane){
                    indicatorSettingPaneMap.get(strKey).remove(pane);
                    //Removed it from the mainchart or volume chart
                    if (chartTabPane.getTab(strKey) != null){
                        Node node = chartTabPane.getTab(strKey);
                        if (node instanceof ChartCanvasPane){
                            ChartCanvasPane canvasPane = (ChartCanvasPane)node;
                            canvasPane.closeIndicatorChart(IndicatorType.OBV);
                        }
                    }
                    break;
            }
        }
        //Removed it from the accordions
        TatAccordion indicatorAccordion = new TatAccordion();
        leftBottomTabPane.removeTab(strTitle);
        if (indicatorSettingPaneMap.get(strKey).size() > 0){
            leftBottomTabPane.addTab(strTitle, indicatorAccordion);
            ArrayList<TitledPane> settings = indicatorSettingPaneMap.get(strKey);
            Iterator<TitledPane> itAdd = settings.iterator();
            while(itAdd.hasNext()){
                indicatorAccordion.getPanes().addAll(itAdd.next());
            }
            indicatorAccordion.setExpandedPane(indicatorSettingPaneMap.get(strKey).get(indicatorSettingPaneMap.get(strKey).size() - 1));
        }
    }      
}
 
Example 13
Project: ctsms   File: ClamlClassProcessor.java   View Source Code Vote up 5 votes
private static HashMap<String, ArrayList<Element>> applyModifiers(Element classElement, ArrayList<String> modifiedBy, Map<String, Map<String, Element>> modifierClasses) {
	HashMap<String, ArrayList<Element>> result = new HashMap<String, ArrayList<Element>>();
	result.put(getCode(classElement), null);
	Iterator<String> it = modifiedBy.iterator();
	while (it.hasNext()) {
		String modifier = it.next();
		if (modifierClasses.containsKey(modifier)) {
			result = modifierCartesianProduct(result, modifierClasses.get(modifier));
		} else {
			throw new IllegalArgumentException(ClamlConstants.MODIFIER_ATTR + " '" + modifier + "' unknown");
		}
	}
	return result;
}
 
Example 14
Project: incubator-netbeans   File: MenuChecker.java   View Source Code Vote up 5 votes
/** check shortcuts in menu structure
 * @param a
 * @return  
 */
private static StringBuffer checkShortCutCollision(ArrayList a) {
    StringBuffer collisions = new StringBuffer("");
    Iterator it = a.iterator();
    HashMap check = new HashMap();

    while (it.hasNext()) {
        Object o = it.next();

        if (o instanceof NbMenuItem) {
            NbMenuItem item = (NbMenuItem) o;

            if (item.getAccelerator() != null) {
                //stream.println("checking : " + item.name + " - " + item.accelerator);
                if (check.containsKey(item.getAccelerator())) {
                    collisions.append("\n !!!!!! Collision! accelerator ='" + item.getAccelerator() + "' : " + item.getName() + " is in collision with " + check.get(item.getAccelerator()));
                } else {
                    check.put(item.getAccelerator(), item.getName());
                }

            }
        }

        if (o instanceof ArrayList) {
            collisions.append(checkShortCutCollision((ArrayList) o));
        }

    }

    return collisions;
}
 
Example 15
Project: ctsms   File: Settings.java   View Source Code Vote up 5 votes
public static List<Color> getColorList(String key, Bundle bundle, ArrayList<String> defaultValue) {
	ArrayList<String> colors = CommonUtil.getValueStringList(key, getBundle(bundle), defaultValue);
	ArrayList<Color> result = new ArrayList<Color>(colors.size());
	Iterator<String> it = colors.iterator();
	while (it.hasNext()) {
		result.add(Color.fromString(it.next()));
	}
	return result;
}
 
Example 16
Project: openjdk-jdk10   File: MemberName.java   View Source Code Vote up 4 votes
List<MemberName> getMembers(Class<?> defc,
        String matchName, Object matchType,
        int matchFlags, Class<?> lookupClass) {
    matchFlags &= ALLOWED_FLAGS;
    String matchSig = null;
    if (matchType != null) {
        matchSig = BytecodeDescriptor.unparse(matchType);
        if (matchSig.startsWith("("))
            matchFlags &= ~(ALL_KINDS & ~IS_INVOCABLE);
        else
            matchFlags &= ~(ALL_KINDS & ~IS_FIELD);
    }
    final int BUF_MAX = 0x2000;
    int len1 = matchName == null ? 10 : matchType == null ? 4 : 1;
    MemberName[] buf = newMemberBuffer(len1);
    int totalCount = 0;
    ArrayList<MemberName[]> bufs = null;
    int bufCount = 0;
    for (;;) {
        bufCount = MethodHandleNatives.getMembers(defc,
                matchName, matchSig, matchFlags,
                lookupClass,
                totalCount, buf);
        if (bufCount <= buf.length) {
            if (bufCount < 0)  bufCount = 0;
            totalCount += bufCount;
            break;
        }
        // JVM returned to us with an intentional overflow!
        totalCount += buf.length;
        int excess = bufCount - buf.length;
        if (bufs == null)  bufs = new ArrayList<>(1);
        bufs.add(buf);
        int len2 = buf.length;
        len2 = Math.max(len2, excess);
        len2 = Math.max(len2, totalCount / 4);
        buf = newMemberBuffer(Math.min(BUF_MAX, len2));
    }
    ArrayList<MemberName> result = new ArrayList<>(totalCount);
    if (bufs != null) {
        for (MemberName[] buf0 : bufs) {
            Collections.addAll(result, buf0);
        }
    }
    for (int i = 0; i < bufCount; i++) {
        result.add(buf[i]);
    }
    // Signature matching is not the same as type matching, since
    // one signature might correspond to several types.
    // So if matchType is a Class or MethodType, refilter the results.
    if (matchType != null && matchType != matchSig) {
        for (Iterator<MemberName> it = result.iterator(); it.hasNext();) {
            MemberName m = it.next();
            if (!matchType.equals(m.getType()))
                it.remove();
        }
    }
    return result;
}
 
Example 17
Project: loom   File: FakeRegionsUpdater.java   View Source Code Vote up 4 votes
@Override
protected Iterator<FakeRegion> getResources(final int prjIdx, final int regIdx) {
    ArrayList<FakeRegion> regs = new ArrayList<>();
    regs.add(new FakeRegion(regions[regIdx], regions[regIdx]));
    return regs.iterator();
}
 
Example 18
Project: monarch   File: PRClientServerRegionFunctionExecutionSelectorNoSingleHopDUnitTest.java   View Source Code Vote up 4 votes
public static void serverAllKeyExecution(Boolean isByName) {
  Region region = cache.getRegion(PartitionedRegionName);
  assertNotNull(region);
  final HashSet testKeysSet = new HashSet();
  for (int i = (totalNumBuckets.intValue() / 2); i > 0; i--) {
    testKeysSet.add("execKey-" + i);
  }
  DistributedSystem.setThreadsSocketPolicy(false);
  Function function = new TestFunction(true, TEST_FUNCTION2);
  FunctionService.registerFunction(function);
  Execution dataSet = FunctionService.onRegion(region);
  try {
    int j = 0;
    HashSet origVals = new HashSet();
    for (Iterator i = testKeysSet.iterator(); i.hasNext();) {
      Integer val = new Integer(j++);
      origVals.add(val);
      region.put(i.next(), val);
    }
    ResultCollector rc1 = executeOnAll(dataSet, Boolean.TRUE, function, isByName);
    List resultList = (List) ((List) rc1.getResult());
    LogWriterUtils.getLogWriter().info("Result size : " + resultList.size());
    LogWriterUtils.getLogWriter().info("Result are SSSS : " + resultList);
    assertEquals(3, resultList.size());

    Iterator resultIterator = resultList.iterator();
    Map.Entry entry = null;
    DistributedMember key = null;
    List resultListForMember = new ArrayList();

    // while (resultIterator.hasNext()) {
    // resultListForMember.add(resultIterator.next());
    //
    // for (Object result : resultListForMember) {
    // assertIndexDetailsEquals(Boolean.TRUE, result);
    // }
    // }
    for (Object result : resultList) {
      assertEquals(Boolean.TRUE, result);
    }
    List l2 = null;
    ResultCollector rc2 = executeOnAll(dataSet, testKeysSet, function, isByName);
    l2 = ((List) rc2.getResult());
    assertEquals(3, l2.size());
    HashSet foundVals = new HashSet();
    for (Iterator i = l2.iterator(); i.hasNext();) {
      ArrayList subL = (ArrayList) (i.next());
      assertTrue(subL.size() > 0);
      for (Iterator subI = subL.iterator(); subI.hasNext();) {
        assertTrue(foundVals.add(subI.next()));
      }
    }
    assertEquals(origVals, foundVals);

  } catch (Exception e) {
    Assert.fail("Test failed after the put operation", e);

  }
}
 
Example 19
Project: ralasafe   File: ApplicationManagerImpl.java   View Source Code Vote up 4 votes
private void createTablesForApp(Application app) {

		// Name rule for role, privilege and roleprivilege is:
		//   <appName>_role, <appName>_privilege and <appName>_roleprivilege
		String appName = app.getName();
		String sqlRole = DBUtil.roleTableCreateSql(appName);
		String sqlPrivilege = DBUtil.privilegeTableCreateSql(appName);
		String sqlRolePrivilege = DBUtil.rolePrivilegeTableCreateSql(appName);
		
		// Each usertype has it's own userrole table. Name rule is:
		// <appName>_<userTypeName>_userrole
		ArrayList sqlUserRoles = new ArrayList();
		Iterator itr = app.getUserTypes().iterator();
		while (itr.hasNext()) {
			UserType userType = (UserType) itr.next();
			userType = Factory.getUserTypeManager().getUserType(
					userType.getName());
			TableMetadata userTable = userType.getUserMetadata()
					.getMainTableMetadata();
			String sqlUserRole = DBUtil.userRoleTableCreateSql(appName,
					userType.getName(), User.idFieldName,
					getIdColumnType(userTable));
			sqlUserRoles.add(sqlUserRole);
		}

		String tableQueryCreateSql = DBUtil.tableQueryCreateSql(appName);
		String tableUserCategoryCreateSql = DBUtil
				.tableUserCategoryCreateSql(appName);
		String tableDicisionEntitlementCreateSql = DBUtil
				.tableDecisionEntitlementCreateSql(appName);
		String tableQueryEntitlementCreateSql = DBUtil
				.tableQueryEntitlementCreateSql(appName);
		String tableBusinessDataCreateSql = DBUtil
				.tableBusinessDataCreateSql(appName);
	
		Connection conn = DBPower.getConnection(DBPower.getDefaultDsName());
		try {
			// conn.setAutoCommit(false);
			// create tables
			DBUtil.exec(conn, sqlRole);
			DBUtil.exec(conn, sqlPrivilege);
			DBUtil.exec(conn, sqlRolePrivilege);
			itr = sqlUserRoles.iterator();
			while (itr.hasNext()) {
				DBUtil.exec(conn, (String) itr.next());
			}
			DBUtil.exec(conn, tableQueryCreateSql);
			DBUtil.exec(conn, tableUserCategoryCreateSql);
			DBUtil.exec(conn, tableDicisionEntitlementCreateSql);
			DBUtil.exec(conn, tableQueryEntitlementCreateSql);
			DBUtil.exec(conn, tableBusinessDataCreateSql);
			// conn.commit();
		} catch (SQLException e) {
			// try {
			// conn.rollback();
			// } catch (SQLException e1) {
			// throw new DBLevelException(e1);
			// }
			throw new DBLevelException(e);
		} finally {
			DBUtil.close(conn);
		}
	}
 
Example 20
Project: ctsms   File: TrialServiceImpl.java   View Source Code Vote up 4 votes
@Override
protected Collection<ProbandListEntryOutVO> handleDeleteProbandListEntries(
		AuthenticationVO auth, Long trialId, Set<Long> probandIds, boolean shuffle, Long limit) throws Exception {
	TrialDao trialDao = this.getTrialDao();
	Trial trial = CheckIDUtil.checkTrialId(trialId, trialDao, LockMode.PESSIMISTIC_WRITE);
	Timestamp now = new Timestamp(System.currentTimeMillis());
	User user = CoreUtil.getUser();
	ProbandListEntryDao probandListEntryDao = this.getProbandListEntryDao();
	ArrayList<ProbandListEntryOutVO> result = new ArrayList<ProbandListEntryOutVO>();
	ShuffleInfoVO shuffleInfo = new ShuffleInfoVO();
	shuffleInfo.setLimit(limit);
	if (probandIds != null) {
		Iterator<Long> probandIt;
		ArrayList<Long> ids = new ArrayList<Long>(probandIds);
		shuffleInfo.setInputIds(ids);
		if (shuffle) {
			long seed = SecureRandom.getInstance(SHUFFLE_SEED_RANDOM_ALGORITHM).nextLong();
			Random random = new Random(seed); // reproducable
			shuffleInfo.setPrngClass(random.getClass().getCanonicalName());
			shuffleInfo.setSeed(seed);
			Collections.shuffle(ids, random);
			probandIt = ids.iterator();
		} else {
			probandIt = probandIds.iterator();
		}
		while (probandIt.hasNext() && (limit == null || result.size() < limit)) {
			Long probandId = probandIt.next();
			try {
				ProbandListEntry probandListEntry = probandListEntryDao.findByTrialProband(trialId, probandId);
				if (probandListEntry != null) {
					result.add(removeProbandListEntry(probandListEntry, now, user, true));
					shuffleInfo.getResultIds().add(probandId);
				}
			} catch (ServiceException e) {
			}
		}
	}
	logSystemMessage(trial, trialDao.toTrialOutVO(trial), now, user, shuffleInfo,
			shuffleInfo != null ? SystemMessageCodes.PROBAND_LIST_ENTRIES_SHUFFLED_AND_DELETED : SystemMessageCodes.PROBAND_LIST_ENTRIES_DELETED);
	return result;
}