java.util.ArrayList#iterator ( )源码实例Demo

下面列出了java.util.ArrayList#iterator ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: birt   文件: JdbcSQLContentAssistProcessor.java
/**
 * @param columns
 * @return
 */
private ICompletionProposal[] convertColumnsToCompletionProposals(
		ArrayList columns, int offset )
{
	if ( columns.size( ) > 0 )
	{
		ICompletionProposal[] proposals = new ICompletionProposal[columns.size( )];
		Iterator iter = columns.iterator( );
		int n = 0;
		while ( iter.hasNext( ) )
		{
			Column column = (Column) iter.next( );
			proposals[n++] = new CompletionProposal( addQuotes( column.getName( ) ),
					offset,
					0,
					column.getName( ).length( ) );
		}
		return proposals;
	}
	return null;
}
 
源代码2 项目: sakai   文件: ItemBean.java
public boolean isCorrectChoice(String label) {
   boolean returnVal = false;
   ArrayList corranswersList = ContextUtil.paramArrayValueLike(
         "mccheckboxes");
     Iterator iter = corranswersList.iterator();
     while (iter.hasNext()) {

       String currentcorrect = (String) iter.next();
       if (currentcorrect.trim().equals(label)) {
         returnVal = true;
         break;
       }
       else {
         returnVal = false;
       }
     }
     return returnVal;
}
 
源代码3 项目: jts   文件: TestFileGeometryExtractor.java
public static void main(String[] args) throws Exception {
  TestReader testReader = new TestReader();
  TestRun testRun = testReader.createTestRun(new File("c:\\blah\\isvalid.xml"), 0);
  ArrayList geometries = new ArrayList();
  for (Iterator i = testRun.getTestCases().iterator(); i.hasNext(); ) {
    TestCase testCase = (TestCase) i.next();
    add(testCase.getGeometryA(), geometries);
    add(testCase.getGeometryB(), geometries);
  }
  String run = "";
  int j = 0;
  for (Iterator i = geometries.iterator(); i.hasNext(); ) {
    Geometry geometry = (Geometry) i.next();
    j++;
    run += "<case>" + StringUtil.newLine;
    run += "  <desc>Test " + j + "</desc>" + StringUtil.newLine;
    run += "  <a>" + StringUtil.newLine;
    run += "    " + geometry + StringUtil.newLine;
    run += "  </a>" + StringUtil.newLine;
    run += "  <test> <op name=\"isValid\" arg1=\"A\"> true </op> </test>" + StringUtil.newLine;
    run += "</case>" + StringUtil.newLine;
  }
  FileUtil.setContents("c:\\blah\\isvalid2.xml", run);
}
 
源代码4 项目: MiBandDecompiled   文件: WebServiceClient.java
private String a(String s, ArrayList arraylist)
{
    Iterator iterator = arraylist.iterator();
    int i = 0;
    while (iterator.hasNext()) 
    {
        NameValuePair namevaluepair = (NameValuePair)iterator.next();
        StringBuilder stringbuilder = (new StringBuilder()).append(s);
        String s1;
        if (i == 0)
        {
            s1 = "?";
        } else
        {
            s1 = "&";
        }
        s = stringbuilder.append(s1).append(namevaluepair.getName()).append("=").append(namevaluepair.getValue()).toString();
        i++;
    }
    return s;
}
 
源代码5 项目: XPagesExtensionLibrary   文件: JavaDumpFactory.java
@Override
public Iterator<Object> getPropertyKeys(String category) {
    ArrayList<Object> list = new ArrayList<Object>();
    getAllPropertyKeys(category,list);
    (new QuickSort.JavaList(list)).sort();
    return list.iterator();
}
 
源代码6 项目: edslite   文件: ExFatDirectory.java
@Override
public Contents list() throws IOException
{
    ArrayList<String> names = new ArrayList<>();
    synchronized (_exFat._sync)
    {
        int res = _exFat.readDir(_path.getPathString(), names);
        if (res != 0)
            throw new IOException("readDir failed. Error code = " + res);
    }
    final ArrayList<Path> paths = new ArrayList<>();
    StringPathUtil curPath = _path.getPathUtil();
    for(String name: names)
        paths.add(new ExFatPath(_exFat, curPath.combine(name).toString()));
    return new Contents()
    {
        @Override
        public void close() throws IOException
        {

        }

        @Override
        public Iterator<Path> iterator()
        {
            return paths.iterator();
        }
    };
}
 
源代码7 项目: olat   文件: ContactList.java
/**
 * A comma separated list of e-mail addresses. The ContactList name is ommitted, if the form
 * ContactList.Name:[email protected],[email protected],...,[email protected]; is needed, please use the appropriate getRFC2822xxx getter method.
 * 
 */
@Override
public String toString() {
    String retVal = "";
    String sep = "";
    ArrayList emails = getEmailsAsStrings();
    Iterator iter = emails.iterator();
    while (iter.hasNext()) {
        retVal += sep + (String) iter.next();
        sep = ", ";
    }
    return retVal;
}
 
源代码8 项目: MiBandDecompiled   文件: DaoConfig.java
private static Property[] reflectProperties(Class class1)
{
    Field afield[] = Class.forName((new StringBuilder()).append(class1.getName()).append("$Properties").toString()).getDeclaredFields();
    ArrayList arraylist = new ArrayList();
    int i = afield.length;
    for (int j = 0; j < i; j++)
    {
        Field field = afield[j];
        if ((9 & field.getModifiers()) != 9)
        {
            continue;
        }
        Object obj = field.get(null);
        if (obj instanceof Property)
        {
            arraylist.add((Property)obj);
        }
    }

    Property aproperty[] = new Property[arraylist.size()];
    for (Iterator iterator = arraylist.iterator(); iterator.hasNext();)
    {
        Property property = (Property)iterator.next();
        if (aproperty[property.ordinal] != null)
        {
            throw new DaoException("Duplicate property ordinals");
        }
        aproperty[property.ordinal] = property;
    }

    return aproperty;
}
 
源代码9 项目: knopflerfish.org   文件: BundleGeneration.java
/**
 * Check bundle certificates
 */
private void checkCertificates() {
  ArrayList<List<X509Certificate>> cs = archive.getCertificateChains(false);
  if (cs != null) {
    if (bundle.fwCtx.validator != null) {
      if (bundle.fwCtx.debug.certificates) {
        bundle.fwCtx.debug.println("Validate certs for bundle #" + archive.getBundleId());
      }
      cs = new ArrayList<List<X509Certificate>>(cs);
      for (final Iterator<Validator> vi = bundle.fwCtx.validator.iterator(); !cs.isEmpty() && vi.hasNext();) {
        final Validator v = vi.next();
        for (final Iterator<List<X509Certificate>> ci = cs.iterator(); ci.hasNext();) {
          final List<X509Certificate> c = ci.next();
          if (v.validateCertificateChain(c)) {
            archive.trustCertificateChain(c);
            ci.remove();
            if (bundle.fwCtx.debug.certificates) {
              bundle.fwCtx.debug.println("Validated cert: " + c.get(0));
            }
          } else {
            if (bundle.fwCtx.debug.certificates) {
              bundle.fwCtx.debug.println("Failed to validate cert: " + c.get(0));
            }
          }
        }
      }
      if (cs.isEmpty()) {
        // Ok, bundle is signed and validated!
        return;
      }
    }
  }
  if (bundle.fwCtx.props.getBooleanProperty(FWProps.ALL_SIGNED_PROP)) {
    throw new IllegalArgumentException("All installed bundles must be signed!");
  }
}
 
private static ArrayList<Entry<String, Pattern>> createTitleRegexps(JobOutput jobOutput) throws Exception {
	ArrayList<Entry<String, Pattern>> titleRegexps = new ArrayList<Entry<String, Pattern>>();
	jobOutput.println(LEGACY_TITLE_REGEXP.size() + " legacy system message code patterns");
	titleRegexps.addAll(LEGACY_TITLE_REGEXP);
	LinkedHashMap<Locale, Locales> locales = new LinkedHashMap<Locale, Locales>();
	locales.put(L10nUtil.getLocale(Locales.JOURNAL), Locales.JOURNAL);
	locales.put(L10nUtil.getLocale(Locales.EN), Locales.EN);
	locales.put(L10nUtil.getLocale(Locales.DE), Locales.DE);
	Iterator<Locales> localesIt = locales.values().iterator();
	while (localesIt.hasNext()) {
		Locales locale = localesIt.next();
		LinkedHashMap<String, String> titleFormatMap = new LinkedHashMap<String, String>(CoreUtil.SYSTEM_MESSAGE_CODES.size());
		Iterator<String> codesIt = CoreUtil.SYSTEM_MESSAGE_CODES.iterator();
		while (codesIt.hasNext()) {
			String code = codesIt.next();
			String titleFormat = L10nUtil.getSystemMessageTitleFormat(locale, code);
			if (!CommonUtil.isEmptyString(titleFormat)) {
				if (!titleFormatMap.containsKey(code)) {
					titleFormatMap.put(code, titleFormat);
				} else {
					throw new Exception("duplicate " + locale.name() + " system message title format " + titleFormat);
				}
			} else {
				throw new Exception("empty " + locale.name() + " system message title format for " + code);
			}
		}
		ArrayList<Entry<String, String>> titleFormatList = new ArrayList<Entry<String, String>>(titleFormatMap.entrySet());
		titleFormatMap.clear();
		Collections.sort(titleFormatList, TITLE_FORMAT_COMPARATOR);
		Iterator<Entry<String, String>> titleFormatIt = titleFormatList.iterator();
		while (titleFormatIt.hasNext()) {
			Entry<String, String> codeTitleFormat = titleFormatIt.next();
			titleRegexps.add(new AbstractMap.SimpleEntry<String, Pattern>(codeTitleFormat.getKey(), CommonUtil.createMessageFormatRegexp(codeTitleFormat.getValue(), false)));
		}
		jobOutput.println(locale.name() + ": " + titleFormatList.size() + " system message code patterns");
	}
	jobOutput.println(titleRegexps.size() + " system message code patterns overall");
	return titleRegexps;
}
 
源代码11 项目: newsApp   文件: FeedsActivity.java
private void removeAlreadyExistingItemsInData(ArrayList<News> list) {
    ArrayList<News> storeListInPreference = com.ghn.android.BoilerplateApplication.preference.getCartItems();
    if (list.size() != 0)
        for (News newsNew : list) {
            for (Iterator<News> it = storeListInPreference.iterator(); it.hasNext(); ) {
                News s = it.next();
                if (s.getId().equals(newsNew.getId())) {
                    it.remove();
                }
            }
        }
    com.ghn.android.BoilerplateApplication.preference.setCartItems(storeListInPreference);
}
 
源代码12 项目: TencentKona-8   文件: ProgressMonitor.java
/**
 * Register progress source when progress is began.
 */
public void registerSource(ProgressSource pi) {

    synchronized(progressSourceList)    {
        if (progressSourceList.contains(pi))
            return;

        progressSourceList.add(pi);
    }

    // Notify only if there is at least one listener
    if (progressListenerList.size() > 0)
    {
        // Notify progress listener if there is progress change
        ArrayList<ProgressListener> listeners = new ArrayList<ProgressListener>();

        // Copy progress listeners to another list to avoid holding locks
        synchronized(progressListenerList) {
            for (Iterator<ProgressListener> iter = progressListenerList.iterator(); iter.hasNext();) {
                listeners.add(iter.next());
            }
        }

        // Fire event on each progress listener
        for (Iterator<ProgressListener> iter = listeners.iterator(); iter.hasNext();) {
            ProgressListener pl = iter.next();
            ProgressEvent pe = new ProgressEvent(pi, pi.getURL(), pi.getMethod(), pi.getContentType(), pi.getState(), pi.getProgress(), pi.getExpected());
            pl.progressStart(pe);
        }
    }
}
 
源代码13 项目: consulo   文件: FragmentListImpl.java
public static ArrayList<Fragment> shift(ArrayList<Fragment> fragments, TextRange rangeShift1, TextRange rangeShift2,
                                   int startLine1, int startLine2) {
  ArrayList<Fragment> newFragments = new ArrayList<Fragment>(fragments.size());
  for (Iterator<Fragment> iterator = fragments.iterator(); iterator.hasNext();) {
    Fragment fragment = iterator.next();
    newFragments.add(fragment.shift(rangeShift1, rangeShift2, startLine1, startLine2));
  }
  return newFragments;
}
 
源代码14 项目: Repeat   文件: DataCutReverseTrimmer.java
/**
 * Remove points from the end of the list.
 */
@Override
public ArrayList<Point> internalTrim(ArrayList<Point> input) {
	ArrayList<Point> output = new ArrayList<>(DataNormalizer.POINT_COUNT);

	Iterator<Point> it = input.iterator();
	for (int i = 0; i < DataNormalizer.POINT_COUNT; i++) {
		output.add(it.next());
	}

	return output;
}
 
源代码15 项目: coming   文件: Lang_23_ExtendedMessageFormat_s.java
/**
 * Apply the specified pattern.
 * 
 * @param pattern String
 */
@Override
public final void applyPattern(String pattern) {
    if (registry == null) {
        super.applyPattern(pattern);
        toPattern = super.toPattern();
        return;
    }
    ArrayList<Format> foundFormats = new ArrayList<Format>();
    ArrayList<String> foundDescriptions = new ArrayList<String>();
    StringBuilder stripCustom = new StringBuilder(pattern.length());

    ParsePosition pos = new ParsePosition(0);
    char[] c = pattern.toCharArray();
    int fmtCount = 0;
    while (pos.getIndex() < pattern.length()) {
        switch (c[pos.getIndex()]) {
        case QUOTE:
            appendQuotedString(pattern, pos, stripCustom, true);
            break;
        case START_FE:
            fmtCount++;
            seekNonWs(pattern, pos);
            int start = pos.getIndex();
            int index = readArgumentIndex(pattern, next(pos));
            stripCustom.append(START_FE).append(index);
            seekNonWs(pattern, pos);
            Format format = null;
            String formatDescription = null;
            if (c[pos.getIndex()] == START_FMT) {
                formatDescription = parseFormatDescription(pattern,
                        next(pos));
                format = getFormat(formatDescription);
                if (format == null) {
                    stripCustom.append(START_FMT).append(formatDescription);
                }
            }
            foundFormats.add(format);
            foundDescriptions.add(format == null ? null : formatDescription);
            Validate.isTrue(foundFormats.size() == fmtCount);
            Validate.isTrue(foundDescriptions.size() == fmtCount);
            if (c[pos.getIndex()] != END_FE) {
                throw new IllegalArgumentException(
                        "Unreadable format element at position " + start);
            }
            //$FALL-THROUGH$
        default:
            stripCustom.append(c[pos.getIndex()]);
            next(pos);
        }
    }
    super.applyPattern(stripCustom.toString());
    toPattern = insertFormats(super.toPattern(), foundDescriptions);
    if (containsElements(foundFormats)) {
        Format[] origFormats = getFormats();
        // only loop over what we know we have, as MessageFormat on Java 1.3 
        // seems to provide an extra format element:
        int i = 0;
        for (Iterator<Format> it = foundFormats.iterator(); it.hasNext(); i++) {
            Format f = it.next();
            if (f != null) {
                origFormats[i] = f;
            }
        }
        super.setFormats(origFormats);
    }
}
 
public static FlowNetwork<VertexStructure[]> generateList (int numVertices, int minFanOut, int maxFanOut, int minCapacity, int maxCapacity) {
	ArrayList<EdgeInfo> edges = generateEdges (numVertices, minFanOut, maxFanOut, minCapacity, maxCapacity);
	
	return new FlowNetworkAdjacencyList (numVertices, 0, numVertices-1, edges.iterator());
}
 
源代码17 项目: BotLibre   文件: Checkers.java
public static CheckersGame.Player learnGame(Strategy redStrategy, Strategy blackStrategy, Analytic trainer,
			CheckersGame.Board board) throws Exception {
		ArrayList<CheckersGame.Board> redBoards = new ArrayList<>();
		ArrayList<CheckersGame.Move> redMoves = new ArrayList<>();
		ArrayList<CheckersGame.Board> blackBoards = new ArrayList<>();
		ArrayList<CheckersGame.Move> blackMoves = new ArrayList<>();
		int movesSinceLastInterestingMove = 0;
		while (!board.gameOver) {
			CheckersGame.Move move = null;
			if (board.playerThisTurn == CheckersGame.Player.RED) {
				move = redStrategy.getMove(board);
				redBoards.add(board);
				redMoves.add(move);
			} else if (board.playerThisTurn == CheckersGame.Player.BLACK) {
				move = blackStrategy.getMove(board);
				blackBoards.add(board);
				blackMoves.add(move);
			}
			board = board.applyMove(move);
			if (!move.jump && !move.queen) {
				movesSinceLastInterestingMove += 1;
				if (movesSinceLastInterestingMove >= 40) {
					// no captures or queens in last 40 moves means game is drawn
					break;
				}
			} else {
				movesSinceLastInterestingMove = 0;
			}
		}
		Iterator<CheckersGame.Board> boardIterator = null;
		Iterator<CheckersGame.Move> moveIterator = null;
		if (board.winner == CheckersGame.Player.RED) {
			boardIterator = redBoards.iterator();
			moveIterator = redMoves.iterator();
		} else if (board.winner == CheckersGame.Player.BLACK) {
			boardIterator = blackBoards.iterator();
			moveIterator = blackMoves.iterator();
		} else {
//			boardIterator = blackBoards.iterator();
//			moveIterator = blackMoves.iterator();
//			boardIterator = redBoards.iterator();
//			moveIterator = redMoves.iterator();
		}
		if (boardIterator != null && moveIterator != null) {
			while (boardIterator.hasNext() && moveIterator.hasNext()) {
//				trainer.train(boardIterator.next(), moveIterator.next());
				CheckersGame.Board nextBoard = boardIterator.next();
				CheckersGame.Move nextMove = moveIterator.next();
//				nextBoard.printBoard();
//				System.out.println(Integer.toString(nextMove.move[0]) + " " + Integer.toString(nextMove.move[1]));
				trainer.train(nextBoard, nextMove);
			}
		}
		return board.winner;
	}
 
源代码18 项目: JavaMainRepo   文件: BigFactory.java
public static void printArrayListEmployeeDetails(ArrayList<Employee> el) {
	Iterator<Employee> itr = el.iterator();
	while (itr.hasNext()) {
		printDetails(itr.next());
	}
}
 
源代码19 项目: astor   文件: ExtendedMessageFormat.java
/**
 * Apply the specified pattern.
 * 
 * @param pattern String
 */
@Override
public final void applyPattern(String pattern) {
    if (registry == null) {
        super.applyPattern(pattern);
        toPattern = super.toPattern();
        return;
    }
    ArrayList<Format> foundFormats = new ArrayList<Format>();
    ArrayList<String> foundDescriptions = new ArrayList<String>();
    StringBuilder stripCustom = new StringBuilder(pattern.length());

    ParsePosition pos = new ParsePosition(0);
    char[] c = pattern.toCharArray();
    int fmtCount = 0;
    while (pos.getIndex() < pattern.length()) {
        switch (c[pos.getIndex()]) {
        case QUOTE:
            appendQuotedString(pattern, pos, stripCustom, true);
            break;
        case START_FE:
            fmtCount++;
            seekNonWs(pattern, pos);
            int start = pos.getIndex();
            int index = readArgumentIndex(pattern, next(pos));
            stripCustom.append(START_FE).append(index);
            seekNonWs(pattern, pos);
            Format format = null;
            String formatDescription = null;
            if (c[pos.getIndex()] == START_FMT) {
                formatDescription = parseFormatDescription(pattern,
                        next(pos));
                format = getFormat(formatDescription);
                if (format == null) {
                    stripCustom.append(START_FMT).append(formatDescription);
                }
            }
            foundFormats.add(format);
            foundDescriptions.add(format == null ? null : formatDescription);
            Validate.isTrue(foundFormats.size() == fmtCount);
            Validate.isTrue(foundDescriptions.size() == fmtCount);
            if (c[pos.getIndex()] != END_FE) {
                throw new IllegalArgumentException(
                        "Unreadable format element at position " + start);
            }
            //$FALL-THROUGH$
        default:
            stripCustom.append(c[pos.getIndex()]);
            next(pos);
        }
    }
    super.applyPattern(stripCustom.toString());
    toPattern = insertFormats(super.toPattern(), foundDescriptions);
    if (containsElements(foundFormats)) {
        Format[] origFormats = getFormats();
        // only loop over what we know we have, as MessageFormat on Java 1.3 
        // seems to provide an extra format element:
        int i = 0;
        for (Iterator<Format> it = foundFormats.iterator(); it.hasNext(); i++) {
            Format f = it.next();
            if (f != null) {
                origFormats[i] = f;
            }
        }
        super.setFormats(origFormats);
    }
}
 
源代码20 项目: letv   文件: PayCenterApi.java
public String pay(int updataId, String deptno, String username, String commodity, String price, String merOrder, String payType, String service, String pid, String productId, String svip, String activityId) {
    Bundle params = new Bundle();
    params.putString("mod", "passport");
    params.putString("ctl", "index");
    params.putString(SocialConstants.PARAM_ACT, "offline");
    params.putString("deptno", deptno);
    params.putString("username", username);
    params.putString("commodity", commodity);
    params.putString("price", price);
    params.putString("merOrder", merOrder);
    params.putString("payType", payType);
    params.putString(NotificationCompat.CATEGORY_SERVICE, service);
    params.putString("pid", pid);
    params.putString("productid", productId);
    params.putString("svip", svip);
    params.putString("activityId", activityId);
    params.putString("pcode", LetvConfig.getPcode());
    params.putString("version", LetvUtils.getClientVersionName());
    params.putString("deviceid", Global.DEVICEID);
    ArrayList<String> list = new ArrayList();
    list.add("mod");
    list.add("ctl");
    list.add(SocialConstants.PARAM_ACT);
    list.add("deptno");
    list.add("username");
    list.add("commodity");
    list.add("price");
    list.add("merOrder");
    list.add("payType");
    list.add(NotificationCompat.CATEGORY_SERVICE);
    list.add("pid");
    list.add("productid");
    list.add("svip");
    list.add("activityId");
    list.add("pcode");
    list.add("version");
    list.add("deviceid");
    Collections.sort(list);
    StringBuilder sb = new StringBuilder();
    sb.append("letv&");
    Iterator it = list.iterator();
    while (it.hasNext()) {
        String s = (String) it.next();
        sb.append(s);
        sb.append(SearchCriteria.EQ);
        sb.append(params.get(s));
        sb.append("&");
    }
    sb.append(MainActivity.THIRD_PARTY_LETV);
    String baseUrl = null;
    try {
        baseUrl = getDynamicUrl() + "?" + "mod" + SearchCriteria.EQ + "passport" + "&" + "ctl" + SearchCriteria.EQ + "index" + "&" + SocialConstants.PARAM_ACT + SearchCriteria.EQ + "offline" + "&" + "deptno" + SearchCriteria.EQ + deptno + "&" + "username" + SearchCriteria.EQ + username + "&" + "commodity" + SearchCriteria.EQ + URLEncoder.encode(commodity, "UTF-8") + "&" + "price" + SearchCriteria.EQ + price + "&" + "merOrder" + SearchCriteria.EQ + merOrder + "&" + "payType" + SearchCriteria.EQ + payType + "&" + NotificationCompat.CATEGORY_SERVICE + SearchCriteria.EQ + service + "&" + "pid" + SearchCriteria.EQ + pid + "&" + "productid" + SearchCriteria.EQ + productId + "&" + "svip" + SearchCriteria.EQ + svip + "&" + "activityId" + SearchCriteria.EQ + activityId + "&" + "pcode" + SearchCriteria.EQ + LetvConfig.getPcode() + "&" + "version" + SearchCriteria.EQ + LetvUtils.getClientVersionName() + "&" + "deviceid" + SearchCriteria.EQ + Global.DEVICEID + "&" + GameAppOperation.GAME_SIGNATURE + SearchCriteria.EQ + MD5.toMd5(sb.toString());
    } catch (UnsupportedEncodingException e) {
        e.printStackTrace();
    }
    return baseUrl;
}