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

The following examples show how to use java.util.ArrayList#iterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JdbcSQLContentAssistProcessor.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
/**
 * @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;
}
 
Example 2
Source File: ItemBean.java    From sakai with Educational Community License v2.0 6 votes vote down vote up
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;
}
 
Example 3
Source File: TestFileGeometryExtractor.java    From jts with GNU Lesser General Public License v2.1 6 votes vote down vote up
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);
}
 
Example 4
Source File: WebServiceClient.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
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;
}
 
Example 5
Source File: DataCutReverseTrimmer.java    From Repeat with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 6
Source File: JavaDumpFactory.java    From XPagesExtensionLibrary with Apache License 2.0 5 votes vote down vote up
@Override
public Iterator<Object> getPropertyKeys(String category) {
    ArrayList<Object> list = new ArrayList<Object>();
    getAllPropertyKeys(category,list);
    (new QuickSort.JavaList(list)).sort();
    return list.iterator();
}
 
Example 7
Source File: FragmentListImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 8
Source File: ProgressMonitor.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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);
        }
    }
}
 
Example 9
Source File: FeedsActivity.java    From newsApp with Apache License 2.0 5 votes vote down vote up
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);
}
 
Example 10
Source File: JournalSystemMessageCodeInitializer.java    From ctsms with GNU Lesser General Public License v2.1 5 votes vote down vote up
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;
}
 
Example 11
Source File: BundleGeneration.java    From knopflerfish.org with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * 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!");
  }
}
 
Example 12
Source File: DaoConfig.java    From MiBandDecompiled with Apache License 2.0 5 votes vote down vote up
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;
}
 
Example 13
Source File: ContactList.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * 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;
}
 
Example 14
Source File: ExFatDirectory.java    From edslite with GNU General Public License v2.0 5 votes vote down vote up
@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();
        }
    };
}
 
Example 15
Source File: Checkers.java    From BotLibre with Eclipse Public License 1.0 4 votes vote down vote up
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;
	}
 
Example 16
Source File: BigFactory.java    From JavaMainRepo with Apache License 2.0 4 votes vote down vote up
public static void printArrayListEmployeeDetails(ArrayList<Employee> el) {
	Iterator<Employee> itr = el.iterator();
	while (itr.hasNext()) {
		printDetails(itr.next());
	}
}
 
Example 17
Source File: ExtendedMessageFormat.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * 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);
    }
}
 
Example 18
Source File: PayCenterApi.java    From letv with Apache License 2.0 4 votes vote down vote up
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;
}
 
Example 19
Source File: FlowNetworkGenerator.java    From algorithms-nutshell-2ed with MIT License 4 votes vote down vote up
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());
}
 
Example 20
Source File: Lang_23_ExtendedMessageFormat_s.java    From coming with MIT License 4 votes vote down vote up
/**
 * 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);
    }
}