package org.apache.fop.afp;
-import java.util.Iterator;
import java.util.Map;
import org.apache.fop.afp.AFPResourceLevel.ResourceType;
* @param other the other instance to get the defaults from
*/
public void mergeFrom(AFPResourceLevelDefaults other) {
- Iterator iter = other.defaultResourceLevels.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- Byte type = (Byte)entry.getKey();
- AFPResourceLevel level = (AFPResourceLevel)entry.getValue();
+ for (Object o : other.defaultResourceLevels.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
+ Byte type = (Byte) entry.getKey();
+ AFPResourceLevel level = (AFPResourceLevel) entry.getValue();
this.defaultResourceLevels.put(type, level);
}
}
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
import java.util.Map;
import org.apache.commons.logging.Log;
* a collection of AFP font attributes
*/
public void addFontsToCurrentPage(Map pageFonts) {
- Iterator iter = pageFonts.values().iterator();
- while (iter.hasNext()) {
- AFPFontAttributes afpFontAttributes = (AFPFontAttributes) iter
- .next();
+ for (Object o : pageFonts.values()) {
+ AFPFontAttributes afpFontAttributes = (AFPFontAttributes) o;
createFont(afpFontAttributes.getFontReference(), afpFontAttributes
.getFont(), afpFontAttributes.getPointSize());
}
import java.io.IOException;
import java.io.OutputStream;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import org.apache.fop.afp.Completable;
*/
public int getDataLength() {
int dataLen = 0;
- Iterator it = objects.iterator();
- while (it.hasNext()) {
- dataLen += ((StructuredData)it.next()).getDataLength();
+ for (Object object : objects) {
+ dataLen += ((StructuredData) object).getDataLength();
}
return dataLen;
}
/** {@inheritDoc} */
public void setComplete(boolean complete) {
- Iterator it = objects.iterator();
- while (it.hasNext()) {
- Object object = it.next();
+ for (Object object : objects) {
if (object instanceof Completable) {
- ((Completable)object).setComplete(true);
+ ((Completable) object).setComplete(true);
}
}
this.complete = true;
import java.awt.Color;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.List;
import org.apache.xmlgraphics.java2d.color.ColorConverter;
import org.apache.fop.afp.AFPDataObjectInfo;
import org.apache.fop.afp.AFPObjectAreaInfo;
-import org.apache.fop.afp.Completable;
import org.apache.fop.afp.Factory;
import org.apache.fop.afp.StructuredData;
import org.apache.fop.afp.fonts.CharacterSet;
/** {@inheritDoc} */
@Override
public void setComplete(boolean complete) {
- Iterator<GraphicsData> it = objects.iterator();
- while (it.hasNext()) {
- Completable completedObject = it.next();
+ for (GraphicsData completedObject : objects) {
completedObject.setComplete(true);
}
super.setComplete(complete);
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
import java.util.List;
import org.apache.fop.afp.AFPConstants;
copySF(startData, Type.MAP, Category.CODED_FONT);
baos.write(startData);
- Iterator iter = fontList.iterator();
- while (iter.hasNext()) {
- FontDefinition fd = (FontDefinition) iter.next();
+ for (Object aFontList : fontList) {
+ FontDefinition fd = (FontDefinition) aFontList;
// Start of repeating groups (occurs 1 to 254)
baos.write(0x00);
baos.write(0x00);
baos.write(BinaryUtils.convert(fd.scale, 2)); // Height
- baos.write(new byte[] {0x00, 0x00}); // Width
+ baos.write(new byte[]{0x00, 0x00}); // Width
- baos.write(new byte[] {0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00});
+ baos.write(new byte[]{0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00});
baos.write(0x60);
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
-import java.util.Iterator;
import java.util.Set;
import org.apache.fop.afp.AFPConstants;
int pos = 13;
- Iterator iter = this.pageSegments.iterator();
- while (iter.hasNext()) {
+ for (Object pageSegment : this.pageSegments) {
pos += 4;
- String name = (String)iter.next();
+ String name = (String) pageSegment;
try {
byte[] nameBytes = name.getBytes(AFPConstants.EBCIDIC_ENCODING);
System.arraycopy(nameBytes, 0, data, pos, nameBytes.length);
} catch (UnsupportedEncodingException usee) {
LOG.error("UnsupportedEncodingException translating the name "
- + name);
+ + name);
}
pos += 8;
}
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.Set;
import org.apache.fop.afp.Streamable;
/** {@inheritDoc} */
public void writeContent(OutputStream os) throws IOException {
- Iterator it = resourceSet.iterator();
- while (it.hasNext()) {
- Object object = it.next();
+ for (Object object : resourceSet) {
if (object instanceof Streamable) {
- Streamable streamableObject = (Streamable)object;
+ Streamable streamableObject = (Streamable) object;
streamableObject.writeToStream(os);
}
}
package org.apache.fop.fo.properties;
import java.awt.Color;
-import java.util.Iterator;
import java.util.List;
import org.apache.fop.apps.FOUserAgent;
Property textDecoProp = pList.getExplicit(Constants.PR_TEXT_DECORATION);
if (textDecoProp != null) {
List list = textDecoProp.getList();
- Iterator i = list.iterator();
- while (i.hasNext()) {
- Property prop = (Property)i.next();
+ for (Object aList : list) {
+ Property prop = (Property) aList;
int propEnum = prop.getEnum();
FOUserAgent ua = pList.getFObj() == null ? null : pList.getFObj().getUserAgent();
if (propEnum == Constants.EN_NONE) {
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
import java.util.Map;
import javax.xml.parsers.DocumentBuilderFactory;
// Get kerning
- Iterator iter = pfm.getKerning().keySet().iterator();
- while (iter.hasNext()) {
- Integer kpx1 = (Integer)iter.next();
+ for (Object kpx1 : pfm.getKerning().keySet()) {
el = doc.createElement("kerning");
el.setAttribute("kpx1", kpx1.toString());
root.appendChild(el);
Element el2 = null;
Map h2 = (Map) pfm.getKerning().get(kpx1);
- Iterator enum2 = h2.entrySet().iterator();
- while (enum2.hasNext()) {
- Map.Entry entry = (Map.Entry) enum2.next();
+ for (Object o : h2.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
Integer kpx2 = (Integer) entry.getKey();
el2 = doc.createElement("pair");
el2.setAttribute("kpx2", kpx2.toString());
Integer cidKey2 = unicodeToGlyph(unicodeKey2);
Integer kern = e.getValue();
- Iterator uniMap = mtxTab[cidKey2].getUnicodeIndex().listIterator();
- while (uniMap.hasNext()) {
- Integer unicodeKey = (Integer)uniMap.next();
+ for (Object o : mtxTab[cidKey2].getUnicodeIndex()) {
+ Integer unicodeKey = (Integer) o;
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey);
for (Integer ansiKey : ansiKeys) {
akpx.put(ansiKey, kern);
}
if (akpx.size() > 0) {
- Iterator uniMap = mtxTab[cidKey1].getUnicodeIndex().listIterator();
- while (uniMap.hasNext()) {
- Integer unicodeKey = (Integer)uniMap.next();
+ for (Object o : mtxTab[cidKey1].getUnicodeIndex()) {
+ Integer unicodeKey = (Integer) o;
Integer[] ansiKeys = unicodeToWinAnsi(unicodeKey);
for (Integer ansiKey : ansiKeys) {
ansiKerningTab.put(ansiKey, akpx);
if (newLMs == null || newLMs.size() == 0) {
return;
}
- ListIterator<LayoutManager> iter = newLMs.listIterator();
- while (iter.hasNext()) {
- addChildLM(iter.next());
+ for (LayoutManager newLM : (Iterable<LayoutManager>) newLMs) {
+ addChildLM(newLM);
}
}
package org.apache.fop.layoutmgr;
-import java.util.Iterator;
import java.util.List;
/**
if (category == null) {
throw new NullPointerException("category must not be null");
}
- Iterator i = activeObservers.iterator();
- while (i.hasNext()) {
- ((Observer)i.next()).observe(elementList, category, id);
+ for (Object activeObserver : activeObservers) {
+ ((Observer) activeObserver).observe(elementList, category, id);
}
}
}
// "wrap" the Position stored in each element of returnedList
// and add elements to returnList
- ListIterator<KnuthElement> listIter = returnedList.listIterator();
- while (listIter.hasNext()) {
- returnedElement = listIter.next();
+ for (KnuthElement aReturnedList : returnedList) {
+ returnedElement = aReturnedList;
if (returnedElement.getLayoutManager() != this) {
returnedElement.setPosition(
new NonLeafPosition(this, returnedElement.getPosition()));
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import org.apache.fop.area.Block;
import org.apache.fop.area.BodyRegion;
private boolean containsFootnotes(List contentList, LayoutContext context) {
boolean containsFootnotes = false;
if (contentList != null) {
- ListIterator contentListIterator = contentList.listIterator();
- while (contentListIterator.hasNext()) {
- ListElement element = (ListElement) contentListIterator.next();
+ for (Object aContentList : contentList) {
+ ListElement element = (ListElement) aContentList;
if (element instanceof KnuthBlockBox
- && ((KnuthBlockBox) element).hasAnchors()) {
+ && ((KnuthBlockBox) element).hasAnchors()) {
// element represents a line with footnote citations
containsFootnotes = true;
KnuthBlockBox box = (KnuthBlockBox) element;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
stackSize = 0;
List contentList = getNextKnuthElements(childLC, Constants.EN_START);
- ListIterator contentIter = contentList.listIterator();
- while (contentIter.hasNext()) {
- KnuthElement element = (KnuthElement) contentIter.next();
+ for (Object aContentList : contentList) {
+ KnuthElement element = (KnuthElement) aContentList;
if (element instanceof KnuthInlineBox) {
KnuthInlineBox box = (KnuthInlineBox) element;
// TODO handle alignment here?
if (newLMs == null || newLMs.size() == 0) {
return;
}
- ListIterator iter = newLMs.listIterator();
- while (iter.hasNext()) {
- LayoutManager lm = (LayoutManager) iter.next();
+ for (Object newLM : newLMs) {
+ LayoutManager lm = (LayoutManager) newLM;
addChildLM(lm);
}
}
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
-import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
if (curLM instanceof InlineLevelLayoutManager) {
context.clearKeepWithNextPending();
// "wrap" the Position stored in each element of returnedList
- ListIterator seqIter = returnedList.listIterator();
- while (seqIter.hasNext()) {
- KnuthSequence sequence = (KnuthSequence) seqIter.next();
+ for (KnuthSequence sequence : returnedList) {
sequence.wrapPositions(this);
}
int insertionStartIndex = 0;
// this is a new list
// "wrap" the Position stored in each element of returnedList
- ListIterator listIter = returnedList.listIterator();
- while (listIter.hasNext()) {
- returnedElement = (KnuthElement) listIter.next();
+ for (Object aReturnedList : returnedList) {
+ returnedElement = (KnuthElement) aReturnedList;
returnedElement.setPosition(
- notifyPos(new NonLeafPosition(this, returnedElement.getPosition())));
+ notifyPos(new NonLeafPosition(this, returnedElement.getPosition())));
returnList.add(returnedElement);
}
}
// loop over the KnuthSequences (and single KnuthElements) in returnedList
- ListIterator iter = inlineElements.listIterator();
- while (iter.hasNext()) {
- KnuthSequence sequence = (KnuthSequence) iter.next();
+ for (Object inlineElement : inlineElements) {
+ KnuthSequence sequence = (KnuthSequence) inlineElement;
// the sequence contains inline Knuth elements
if (sequence.isInlineSequence()) {
// look at the last element
// else this is the last paragraph
if (lastPar == null) {
lastPar = new Paragraph(this,
- textAlignment, textAlignmentLast,
- textIndent.getValue(this),
- lastLineEndIndent.getValue(this));
+ textAlignment, textAlignmentLast,
+ textIndent.getValue(this),
+ lastLineEndIndent.getValue(this));
lastPar.startSequence();
if (log.isTraceEnabled()) {
trace.append(" [");
// finish last paragraph if it was closed with a linefeed
if (lastElement.isPenalty()
&& ((KnuthPenalty) lastElement).getPenalty()
- == -KnuthPenalty.INFINITE) {
+ == -KnuthPenalty.INFINITE) {
// a penalty item whose value is -inf
// represents a preserved linefeed,
// which forces a line break
if (!seq.isInlineSequence()) {
List<ListElement> targetList = new LinkedList<ListElement>();
- ListIterator listIter = seq.listIterator();
- while (listIter.hasNext()) {
+ for (Object aSeq : seq) {
ListElement tempElement;
- tempElement = (ListElement) listIter.next();
+ tempElement = (ListElement) aSeq;
LayoutManager lm = tempElement.getLayoutManager();
if (baselineOffset < 0 && lm != null && lm.hasLineAreaDescendant()) {
baselineOffset = lm.getBaselineOffset();
int oldIndex = -1;
int changeIndex;
PendingChange currChange;
- ListIterator changeListIterator = changeList.listIterator();
- while (changeListIterator.hasNext()) {
- currChange = (PendingChange) changeListIterator.next();
+ for (Object aChangeList : changeList) {
+ currChange = (PendingChange) aChangeList;
if (currChange.index == oldIndex) {
mappingsAdded++;
changeIndex = currChange.index + mappingsAdded - mappingsRemoved;
List tempList = returnedList;
KnuthElement tempElement;
returnedList = new LinkedList();
- ListIterator listIter = tempList.listIterator();
- while (listIter.hasNext()) {
- tempElement = (KnuthElement)listIter.next();
+ for (Object aTempList : tempList) {
+ tempElement = (KnuthElement) aTempList;
tempElement.setPosition(new NonLeafPosition(this, tempElement.getPosition()));
returnedList.add(tempElement);
}
import java.util.Iterator;
import java.util.List;
-import java.util.ListIterator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
List rawCols = table.getColumns();
if (rawCols != null) {
int colnum = 1;
- ListIterator iter = rawCols.listIterator();
- while (iter.hasNext()) {
- TableColumn col = (TableColumn)iter.next();
+ for (Object rawCol : rawCols) {
+ TableColumn col = (TableColumn) rawCol;
if (col == null) {
continue;
}
//Post-processing the list (looking for gaps)
//TODO The following block could possibly be removed
int pos = 1;
- ListIterator ppIter = columns.listIterator();
- while (ppIter.hasNext()) {
- TableColumn col = (TableColumn)ppIter.next();
+ for (Object column : columns) {
+ TableColumn col = (TableColumn) column;
if (col == null) {
assert false; //Gaps are filled earlier by fo.flow.table.Table.finalizeColumns()
//log.error("Found a gap in the table-columns at position " + pos);
import java.util.ArrayList;
import java.util.Arrays;
-import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
firstRowOnPageIndex = firstRowIndex;
}
}
- Iterator partIter = tcpos.cellParts.iterator();
//Iterate over all grid units in the current step
- while (partIter.hasNext()) {
- CellPart cellPart = (CellPart)partIter.next();
+ for (Object cellPart1 : tcpos.cellParts) {
+ CellPart cellPart = (CellPart) cellPart1;
if (log.isDebugEnabled()) {
log.debug(">" + cellPart);
}
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
contentKnuthElements = contentLM.getNextKnuthElements(childLC, alignment);
//Set index values on elements coming from the content LM
- Iterator iter = contentKnuthElements.iterator();
- while (iter.hasNext()) {
- ListElement el = (ListElement)iter.next();
+ for (Object contentKnuthElement : contentKnuthElements) {
+ ListElement el = (ListElement) contentKnuthElement;
notifyPos(el.getPosition());
}
log.debug(contentKnuthElements);
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
*/
protected PDFGState findGState(PDFGState wanted, PDFGState current) {
PDFGState poss;
- Iterator<PDFGState> iter = this.gstates.iterator();
- while (iter.hasNext()) {
- PDFGState avail = iter.next();
+ for (PDFGState avail : this.gstates) {
poss = new PDFGState();
poss.addValues(current);
poss.addValues(avail);
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.Map;
import java.util.SortedMap;
map.put(key, value);
}
names.clear();
- Iterator iter = map.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
+ for (Object o : map.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
names.add(entry.getKey());
names.add(entry.getValue());
}
import java.util.Arrays;
import java.util.BitSet;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.SortedSet;
if (deep) {
dests = new PDFDests();
PDFArray kids = new PDFArray(dests);
- Iterator iter = destinationList.iterator();
- while (iter.hasNext()) {
- PDFDestination dest = (PDFDestination)iter.next();
+ for (Object aDestinationList : destinationList) {
+ PDFDestination dest = (PDFDestination) aDestinationList;
PDFNameTreeNode node = new PDFNameTreeNode();
getDocument().registerObject(node);
node.setLowerLimit(dest.getIDRef());
package org.apache.fop.render;
//Java
-import java.util.Iterator;
import java.util.Map;
import org.apache.fop.apps.FOUserAgent;
/** {@inheritDoc} **/
public String toString() {
StringBuffer stringBuffer = new StringBuffer("RendererContext{\n");
- Iterator it = props.keySet().iterator();
- while (it.hasNext()) {
- String key = (String)it.next();
+ for (Object o : props.keySet()) {
+ String key = (String) o;
Object value = props.get(key);
stringBuffer.append("\t" + key + "=" + value + "\n");
}
private void addForeignAttributes(AttributesImpl atts) throws SAXException {
Map foreignAttributes = getContext().getForeignAttributes();
if (!foreignAttributes.isEmpty()) {
- Iterator iter = foreignAttributes.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- addAttribute(atts, (QName)entry.getKey(), entry.getValue().toString());
+ for (Object o : foreignAttributes.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
+ addAttribute(atts, (QName) entry.getKey(), entry.getValue().toString());
}
}
}
AttributesImpl atts = new AttributesImpl();
try {
handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK_TREE, atts);
- Iterator iter = tree.getBookmarks().iterator();
- while (iter.hasNext()) {
- Bookmark b = (Bookmark)iter.next();
+ for (Object o : tree.getBookmarks()) {
+ Bookmark b = (Bookmark) o;
if (b.getAction() != null) {
serializeBookmark(b);
}
XMLUtil.CDATA, bookmark.isShown() ? "show" : "hide");
handler.startElement(DocumentNavigationExtensionConstants.BOOKMARK, atts);
serializeXMLizable(bookmark.getAction());
- Iterator iter = bookmark.getChildBookmarks().iterator();
- while (iter.hasNext()) {
- Bookmark b = (Bookmark)iter.next();
+ for (Object o : bookmark.getChildBookmarks()) {
+ Bookmark b = (Bookmark) o;
if (b.getAction() != null) {
serializeBookmark(b);
}
package org.apache.fop.render.intermediate.extensions;
-import java.util.Iterator;
import java.util.Map;
/**
}
private AbstractAction normalize(AbstractAction action) {
- Iterator iter = this.actionRegistry.values().iterator();
- while (iter.hasNext()) {
- AbstractAction a = (AbstractAction)iter.next();
+ for (Object o : this.actionRegistry.values()) {
+ AbstractAction a = (AbstractAction) o;
if (a.isSame(action)) {
return a;
}
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;
import org.apache.fop.area.PageViewport;
import org.apache.fop.area.Trait;
import org.apache.fop.area.inline.Image;
-import org.apache.fop.area.inline.InlineArea;
import org.apache.fop.area.inline.Leader;
import org.apache.fop.area.inline.SpaceArea;
import org.apache.fop.area.inline.TextArea;
protected void restoreStateStackAfterBreakOut(List breakOutList) {
log.debug("Block.FIXED --> restoring context after break-out");
- Iterator it = breakOutList.iterator();
- while (it.hasNext()) {
- Java2DGraphicsState s = (Java2DGraphicsState)it.next();
+ for (Object aBreakOutList : breakOutList) {
+ Java2DGraphicsState s = (Java2DGraphicsState) aBreakOutList;
stateStack.push(state);
this.state = s;
}
float textCursor = 0;
- Iterator iter = text.getChildAreas().iterator();
- while (iter.hasNext()) {
- InlineArea child = (InlineArea)iter.next();
+ for (Object child : text.getChildAreas()) {
if (child instanceof WordArea) {
- WordArea word = (WordArea)child;
+ WordArea word = (WordArea) child;
String s = word.getWord();
int[] letterAdjust = word.getLetterAdjustArray();
GlyphVector gv = g2d.getFont().createGlyphVector(g2d.getFontRenderContext(), s);
g2d.drawGlyphVector(gv, textCursor, 0);
textCursor += gv.getLogicalBounds().getWidth() + additionalWidth;
} else if (child instanceof SpaceArea) {
- SpaceArea space = (SpaceArea)child;
+ SpaceArea space = (SpaceArea) child;
String s = space.getSpace();
char sp = s.charAt(0);
int tws = (space.isAdjustable()
? text.getTextWordSpaceAdjust()
- + 2 * text.getTextLetterSpaceAdjust()
+ + 2 * text.getTextLetterSpaceAdjust()
: 0);
textCursor += (font.getCharWidth(sp) + tws) / 1000f;
import java.awt.Dimension;
import java.awt.Rectangle;
-import java.util.Iterator;
import java.util.List;
import org.apache.xmlgraphics.util.UnitConv;
* @return the page definition or null if no match was found
*/
public static PCLPageDefinition getPageDefinition(long width, long height, int errorMargin) {
- Iterator iter = pageDefinitions.iterator();
- while (iter.hasNext()) {
- PCLPageDefinition def = (PCLPageDefinition)iter.next();
+ for (Object pageDefinition : pageDefinitions) {
+ PCLPageDefinition def = (PCLPageDefinition) pageDefinition;
if (def.matches(width, height, errorMargin)) {
return def;
}
* @return the page definition or null if no match was found
*/
public static PCLPageDefinition getPageDefinition(String name) {
- Iterator iter = pageDefinitions.iterator();
- while (iter.hasNext()) {
- PCLPageDefinition def = (PCLPageDefinition)iter.next();
+ for (Object pageDefinition : pageDefinitions) {
+ PCLPageDefinition def = (PCLPageDefinition) pageDefinition;
if (def.getName().equalsIgnoreCase(name)) {
return def;
}
import java.awt.Rectangle;
import java.awt.geom.Point2D;
import java.awt.geom.Rectangle2D;
-import java.util.Iterator;
import java.util.Map;
import org.apache.fop.pdf.PDFAction;
/** {@inheritDoc} */
public void renderBookmarkTree(BookmarkTree tree) throws IFException {
- Iterator iter = tree.getBookmarks().iterator();
- while (iter.hasNext()) {
- Bookmark b = (Bookmark)iter.next();
+ for (Object o : tree.getBookmarks()) {
+ Bookmark b = (Bookmark) o;
renderBookmark(b, null);
}
}
PDFReference actionRef = (action != null ? action.makeReference() : null);
PDFOutline pdfOutline = getPDFDoc().getFactory().makeOutline(parent,
bookmark.getTitle(), actionRef, bookmark.isShown());
- Iterator iter = bookmark.getChildBookmarks().iterator();
- while (iter.hasNext()) {
- Bookmark b = (Bookmark)iter.next();
+ for (Object o : bookmark.getChildBookmarks()) {
+ Bookmark b = (Bookmark) o;
renderBookmark(b, pdfOutline);
}
}
if (x || y) {
sb.append("\n[");
int idx = 0;
- Iterator<Point2D> iter = this.relativePositions.iterator();
- while (iter.hasNext()) {
- Point2D pt = iter.next();
+ for (Point2D pt : this.relativePositions) {
if (idx > 0) {
if (x) {
sb.append(format(gen, pt.getX()));
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
-import java.util.Iterator;
import java.util.Map;
import java.util.Set;
if (formResources == null) {
return;
}
- Iterator iter = formResources.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- PSResource res = (PSResource)entry.getValue();
+ for (Object o : formResources.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
+ PSResource res = (PSResource) entry.getValue();
long count = resTracker.getUsageCount(res);
if (count > 1) {
//Make global form
if (formResources == null) {
return;
}
- Iterator iter = formResources.values().iterator();
- while (iter.hasNext()) {
- PSImageFormResource form = (PSImageFormResource)iter.next();
+ for (Object o : formResources.values()) {
+ PSImageFormResource form = (PSImageFormResource) o;
resTracker.registerSuppliedResource(form);
}
}
if (formResources == null) {
return;
}
- Iterator iter = formResources.values().iterator();
- while (iter.hasNext()) {
- PSImageFormResource form = (PSImageFormResource)iter.next();
+ for (Object o : formResources.values()) {
+ PSImageFormResource form = (PSImageFormResource) o;
generateFormForImage(gen, form);
}
}
protected void addTraitAttributes(Area area) {
Map traitMap = area.getTraits();
if (traitMap != null) {
- Iterator iter = traitMap.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry traitEntry = (Map.Entry) iter.next();
+ for (Object o : traitMap.entrySet()) {
+ Map.Entry traitEntry = (Map.Entry) o;
Object key = traitEntry.getKey();
String name = Trait.getTraitName(key);
Class clazz = Trait.getTraitClass(key);
}
Object value = traitEntry.getValue();
if (((Integer) key).intValue() == Trait.FONT) {
- FontTriplet triplet = (FontTriplet)value;
+ FontTriplet triplet = (FontTriplet) value;
addAttribute("font-name", triplet.getName());
addAttribute("font-style", triplet.getStyle());
addAttribute("font-weight", triplet.getWeight());
} else if (clazz.equals(InternalLink.class)) {
- InternalLink iLink = (InternalLink)value;
+ InternalLink iLink = (InternalLink) value;
addAttribute(name, iLink.xmlAttribute());
} else if (clazz.equals(Background.class)) {
- Background bkg = (Background)value;
+ Background bkg = (Background) value;
//TODO Remove the following line (makes changes in the test checks necessary)
addAttribute(name, bkg.toString());
if (bkg.getColor() != null) {
String repString;
int repeat = bkg.getRepeat();
switch (repeat) {
- case Constants.EN_REPEAT:
- repString = "repeat";
- break;
- case Constants.EN_REPEATX:
- repString = "repeat-x";
- break;
- case Constants.EN_REPEATY:
- repString = "repeat-y";
- break;
- case Constants.EN_NOREPEAT:
- repString = "no-repeat";
- break;
- default:
- throw new IllegalStateException(
- "Illegal value for repeat encountered: " + repeat);
+ case Constants.EN_REPEAT:
+ repString = "repeat";
+ break;
+ case Constants.EN_REPEATX:
+ repString = "repeat-x";
+ break;
+ case Constants.EN_REPEATY:
+ repString = "repeat-y";
+ break;
+ case Constants.EN_NOREPEAT:
+ repString = "no-repeat";
+ break;
+ default:
+ throw new IllegalStateException(
+ "Illegal value for repeat encountered: " + repeat);
}
addAttribute("bkg-repeat", repString);
addAttribute("bkg-horz-offset", bkg.getHoriz());
addAttribute("bkg-vert-offset", bkg.getVertical());
}
} else if (clazz.equals(Color.class)) {
- Color c = (Color)value;
+ Color c = (Color) value;
addAttribute(name, ColorUtil.colorToString(c));
} else if (((Integer) key).intValue() == Trait.START_INDENT
|| ((Integer) key).intValue() == Trait.END_INDENT) {
protected void handleExtensionAttachments(List attachments) {
if (attachments != null && attachments.size() > 0) {
startElement("extension-attachments");
- Iterator i = attachments.iterator();
- while (i.hasNext()) {
- ExtensionAttachment attachment = (ExtensionAttachment)i.next();
+ for (Object attachment1 : attachments) {
+ ExtensionAttachment attachment = (ExtensionAttachment) attachment1;
if (attachment instanceof XMLizable) {
try {
- ((XMLizable)attachment).toSAX(this.handler);
+ ((XMLizable) attachment).toSAX(this.handler);
} catch (SAXException e) {
log.error("Error while serializing Extension Attachment", e);
}
package org.apache.fop.tools.fontlist;
+import java.util.ArrayList;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
SortedMap fontFamilies = new java.util.TreeMap();
//SortedMap<String/font-family, List<FontSpec>>
- Iterator iter = fontInfo.getFontTriplets().entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- FontTriplet triplet = (FontTriplet)entry.getKey();
- String key = (String)entry.getValue();
+ for (Object o : fontInfo.getFontTriplets().entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
+ FontTriplet triplet = (FontTriplet) entry.getKey();
+ String key = (String) entry.getValue();
FontSpec container;
if (keyBag.contains(key)) {
keyBag.remove(key);
- FontMetrics metrics = (FontMetrics)fonts.get(key);
+ FontMetrics metrics = (FontMetrics) fonts.get(key);
container = new FontSpec(key, metrics);
container.addFamilyNames(metrics.getFamilyNames());
keys.put(key, container);
- String firstFamilyName = (String)container.getFamilyNames().first();
- List containers = (List)fontFamilies.get(firstFamilyName);
+ String firstFamilyName = (String) container.getFamilyNames().first();
+ List containers = (List) fontFamilies.get(firstFamilyName);
if (containers == null) {
- containers = new java.util.ArrayList();
+ containers = new ArrayList();
fontFamilies.put(firstFamilyName, containers);
}
containers.add(container);
Collections.sort(containers);
} else {
- container = (FontSpec)keys.get(key);
+ container = (FontSpec) keys.get(key);
}
container.addTriplet(triplet);
}
sb.append(':');
sb.append('\n');
List list = (List)entry.getValue();
- Iterator fonts = list.iterator();
- while (fonts.hasNext()) {
- FontSpec f = (FontSpec)fonts.next();
+ for (Object aList : list) {
+ FontSpec f = (FontSpec) aList;
sb.append(" ");
sb.append(f.getKey());
sb.append(' ');
}
}
sb.append('\n');
- Iterator triplets = f.getTriplets().iterator();
- while (triplets.hasNext()) {
- FontTriplet triplet = (FontTriplet)triplets.next();
+ for (Object o : f.getTriplets()) {
+ FontTriplet triplet = (FontTriplet) o;
sb.append(" ");
sb.append(triplet.toString());
sb.append('\n');
throws TransformerConfigurationException, SAXException, IOException {
if (this.outputFile.isDirectory()) {
System.out.println("Creating one file for each family...");
- Iterator iter = fontFamilies.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- String familyName = (String)entry.getKey();
+ for (Object o : fontFamilies.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
+ String familyName = (String) entry.getKey();
System.out.println("Creating output file for " + familyName + "...");
String filename;
- switch(this.mode) {
- case GENERATE_RENDERED:
- filename = familyName + ".pdf";
- break;
- case GENERATE_FO:
- filename = familyName + ".fo";
- break;
- case GENERATE_XML:
- filename = familyName + ".xml";
- break;
- default:
- throw new IllegalStateException("Unsupported mode");
+ switch (this.mode) {
+ case GENERATE_RENDERED:
+ filename = familyName + ".pdf";
+ break;
+ case GENERATE_FO:
+ filename = familyName + ".fo";
+ break;
+ case GENERATE_XML:
+ filename = familyName + ".xml";
+ break;
+ default:
+ throw new IllegalStateException("Unsupported mode");
}
File outFile = new File(this.outputFile, filename);
generateXML(fontFamilies, outFile, familyName);
package org.apache.fop.tools.fontlist;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.SortedMap;
AttributesImpl atts = new AttributesImpl();
handler.startElement(FONTS, atts);
- Iterator iter = fontFamilies.entrySet().iterator();
- while (iter.hasNext()) {
- Map.Entry entry = (Map.Entry)iter.next();
- String familyName = (String)entry.getKey();
+ for (Object o : fontFamilies.entrySet()) {
+ Map.Entry entry = (Map.Entry) o;
+ String familyName = (String) entry.getKey();
if (singleFamily != null && !singleFamily.equals(familyName)) {
continue;
}
stripQuotes(familyName));
handler.startElement(FAMILY, atts);
- List containers = (List)entry.getValue();
+ List containers = (List) entry.getValue();
generateXMLForFontContainers(handler, containers);
handler.endElement(FAMILY);
}
private void generateXMLForFontContainers(GenerationHelperContentHandler handler,
List containers) throws SAXException {
AttributesImpl atts = new AttributesImpl();
- Iterator fontIter = containers.iterator();
- while (fontIter.hasNext()) {
- FontSpec cont = (FontSpec)fontIter.next();
+ for (Object container : containers) {
+ FontSpec cont = (FontSpec) container;
atts.clear();
atts.addAttribute(null, KEY, KEY, CDATA, cont.getKey());
atts.addAttribute(null, TYPE, TYPE, CDATA,
AttributesImpl atts = new AttributesImpl();
atts.clear();
handler.startElement(TRIPLETS, atts);
- Iterator iter = triplets.iterator();
- while (iter.hasNext()) {
- FontTriplet triplet = (FontTriplet)iter.next();
+ for (Object triplet1 : triplets) {
+ FontTriplet triplet = (FontTriplet) triplet1;
atts.clear();
atts.addAttribute(null, NAME, NAME, CDATA, triplet.getName());
atts.addAttribute(null, STYLE, STYLE, CDATA, triplet.getStyle());
package org.apache.fop.layoutengine;
-import java.util.Iterator;
import java.util.List;
import org.w3c.dom.CDATASection;
private ElementListCollector.ElementList findElementList(LayoutResult result) {
List candidates = new java.util.ArrayList();
- Iterator iter = result.getElementListCollector().getElementLists().iterator();
- while (iter.hasNext()) {
- ElementListCollector.ElementList el = (ElementListCollector.ElementList)iter.next();
+ for (Object o : result.getElementListCollector().getElementLists()) {
+ ElementListCollector.ElementList el = (ElementListCollector.ElementList) o;
if (el.getCategory().equals(category)) {
if (haveID() && this.id.equals(el.getID())) {
candidates.add(el);
package org.apache.fop.memory;
-import java.util.Iterator;
import java.util.List;
class Stats {
sb.append("&chd=t:");
boolean first = true;
int maxY = 0;
- Iterator iter = samples.iterator();
- while (iter.hasNext()) {
- Sample sample = (Sample)iter.next();
+ for (Object sample1 : samples) {
+ Sample sample = (Sample) sample1;
if (first) {
first = false;
} else {
import java.io.OutputStream;
import java.text.DecimalFormat;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import javax.xml.transform.Source;
}
//Start threads
- Iterator i = threadList.iterator();
- while (i.hasNext()) {
- ((Thread)i.next()).start();
+ for (Object aThreadList : threadList) {
+ ((Thread) aThreadList).start();
}
//Wait for threads to end
int failures = 0;
long bytesWritten = 0;
System.out.println("Report on " + count + " tasks:");
- Iterator iter = this.results.iterator();
- while (iter.hasNext()) {
- Result res = (Result)iter.next();
+ for (Object result : this.results) {
+ Result res = (Result) result;
if (res.failure != null) {
System.out.println("FAIL: " + (res.end - res.start) + " " + res.task);
System.out.println(" -> " + res.failure.getMessage());
public void run() {
try {
for (int r = 0; r < repeat; r++) {
- Iterator i = taskList.iterator();
- while (i.hasNext()) {
- TaskDef def = (TaskDef)i.next();
+ for (Object aTaskList : taskList) {
+ TaskDef def = (TaskDef) aTaskList;
final Task task = new Task(def, counter++, foprocessor);
ContainerUtil.enableLogging(task, getLogger());
task.execute();
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.MissingResourceException;
}
Map params = new java.util.HashMap();
int i = 1;
- Iterator iter = methodModel.getParameters().iterator();
- while (iter.hasNext()) {
+ for (Object o : methodModel.getParameters()) {
EventMethodModel.Parameter param
- = (EventMethodModel.Parameter)iter.next();
+ = (EventMethodModel.Parameter) o;
params.put(param.getName(), args[i]);
i++;
}
String msg = EventFormatter.format(event);
//Get original exception as cause if it is given as one of the parameters
Throwable t = null;
- Iterator<Object> iter = event.getParams().values().iterator();
- while (iter.hasNext()) {
- Object o = iter.next();
+ for (Object o : event.getParams().values()) {
if (o instanceof Throwable) {
- t = (Throwable)o;
+ t = (Throwable) o;
break;
}
}
import java.io.Serializable;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
import org.xml.sax.ContentHandler;
}
String elName = "method";
handler.startElement("", elName, elName, atts);
- Iterator iter = this.params.iterator();
- while (iter.hasNext()) {
- ((XMLizable)iter.next()).toSAX(handler);
+ for (Object param : this.params) {
+ ((XMLizable) param).toSAX(handler);
}
handler.endElement("", elName, elName);
}
protected long processFileSets(EventProducerCollector collector)
throws IOException, EventConventionException, ClassNotFoundException {
long lastModified = 0;
- Iterator<FileSet> iter = filesets.iterator();
- while (iter.hasNext()) {
- FileSet fs = (FileSet)iter.next();
+ for (FileSet fs : filesets) {
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
String[] srcFiles = ds.getIncludedFiles();
File directory = fs.getDir(getProject());
target.append(obj);
} else {
boolean handled = false;
- Iterator<ObjectFormatter> iter = OBJECT_FORMATTERS.iterator();
- while (iter.hasNext()) {
- ObjectFormatter formatter = iter.next();
+ for (ObjectFormatter formatter : OBJECT_FORMATTERS) {
if (formatter.supportsObject(obj)) {
formatter.format(target, obj);
handled = true;
public void write(StringBuffer sb, Map<String, Object> params) {
if (hasSections) {
- Iterator<Part> iter = this.parts.iterator();
- while (iter.hasNext()) {
- Part part = iter.next();
+ for (Part part : this.parts) {
if (part.isGenerated(params)) {
part.write(sb, params);
break;
}
} else {
if (isGenerated(params)) {
- Iterator<Part> iter = this.parts.iterator();
- while (iter.hasNext()) {
- Part part = iter.next();
+ for (Part part : this.parts) {
part.write(sb, params);
}
}
public boolean isGenerated(Map<String, Object> params) {
if (hasSections) {
- Iterator<Part> iter = this.parts.iterator();
- while (iter.hasNext()) {
- Part part = iter.next();
+ for (Part part : this.parts) {
if (part.isGenerated(params)) {
return true;
}
return false;
} else {
if (conditional) {
- Iterator<Part> iter = this.parts.iterator();
- while (iter.hasNext()) {
- Part part = iter.next();
+ for (Part part : this.parts) {
if (!part.isGenerated(params)) {
return false;
}