sb.append('=');
sb.append(coords[i]);
}
- return getName() + "{" + sb.toString() + "}";
+ return getName() + "{" + sb + "}";
}
/**
if (this.levels != null) {
int n = end - start;
int[] levels = new int [ n ];
- for (int i = 0; i < n; i++) {
- levels[i] = this.levels [ start + i ];
- }
+ System.arraycopy(this.levels, start + 0, levels, 0, n);
return levels;
} else {
return null;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
public List getEntries() {
if (values != null) {
List entries = new ArrayList(values.length);
- for (Value value : values) {
- entries.add(value);
- }
+ Collections.addAll(entries, values);
return entries;
} else {
return null;
package org.apache.fop.complexscripts.fonts;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Map;
/** {@inheritDoc} */
public List getEntries() {
List entries = new ArrayList(gaa.length);
- for (int[] aGaa : gaa) {
- entries.add(aGaa);
- }
+ Collections.addAll(entries, gaa);
return entries;
}
/** {@inheritDoc} */
/** {@inheritDoc} */
public List getEntries() {
List entries = new ArrayList(ligatureSets.length);
- for (LigatureSet ligatureSet : ligatureSets) {
- entries.add(ligatureSet);
- }
+ Collections.addAll(entries, ligatureSets);
return entries;
}
/** {@inheritDoc} */
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
};
static {
basicShapingFeatures = new HashSet<String>();
- for (String s : BASIC_SHAPING_FEATURE_STRINGS) {
- basicShapingFeatures.add(s);
- }
+ Collections.addAll(basicShapingFeatures, BASIC_SHAPING_FEATURE_STRINGS);
}
private boolean isBasicShapingUse(GlyphTable.UseSpec us) {
assert us != null;
};
static {
presentationFeatures = new HashSet<String>();
- for (String s : PRESENTATION_FEATURE_STRINGS) {
- presentationFeatures.add(s);
- }
+ Collections.addAll(presentationFeatures, PRESENTATION_FEATURE_STRINGS);
}
private boolean isPresentationUse(GlyphTable.UseSpec us) {
assert us != null;
import java.nio.IntBuffer;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
// CSOFF: LineLengthCheck
if (na > 0) {
List gl = new ArrayList(na);
if (baa != null) {
- for (CharAssociation aBaa : baa) {
- gl.add(aBaa);
- }
+ Collections.addAll(gl, baa);
}
if (iaa != null) {
- for (CharAssociation anIaa : iaa) {
- gl.add(anIaa);
- }
+ Collections.addAll(gl, iaa);
}
if (laa != null) {
- for (CharAssociation aLaa : laa) {
- gl.add(aLaa);
- }
+ Collections.addAll(gl, laa);
}
return gl;
} else {
package org.apache.fop.complexscripts.util;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
// CSOFF: LineLengthCheck
*/
private static void appendScalars(List<Integer> scalars, Integer[] sa) {
- for (Integer s : sa) {
- scalars.add(s);
- }
+ Collections.addAll(scalars, sa);
}
private static String scalarsToString(List<Integer> scalars) {
assert start <= end;
int n = end - start;
int[] bidiLevels = new int [ n ];
- for (int i = 0; i < n; i++) {
- bidiLevels[i] = this.bidiLevels [ start + i ];
- }
+ System.arraycopy(this.bidiLevels, start + 0, bidiLevels, 0, n);
return bidiLevels;
} else {
return null;
*/
public void setCMap(CMapSegment[] cmap) {
this.cmap.clear();
- for (CMapSegment c : cmap) {
- this.cmap.add(c);
- }
+ Collections.addAll(this.cmap, cmap);
}
/**
}
throw new IllegalStateException(
"fontLookup must return an array with at least one "
- + "FontTriplet on the last call. Lookup: " + sb.toString());
+ + "FontTriplet on the last call. Lookup: " + sb);
}
FontTriplet[] fontTriplets = new FontTriplet[matchedTriplets.size()];
gidToSID = new LinkedHashMap<Integer, Integer>();
- for (int gid : subsetGlyphs.keySet()) {
+ for (Entry<Integer, Integer> subsetGlyph : subsetGlyphs.entrySet()) {
+ int gid = subsetGlyph.getKey();
int sid = cffReader.getSIDFromGID(charsetOffset, gid);
//Check whether the SID falls into the standard string set
if (sid < NUM_STANDARD_STRINGS) {
- gidToSID.put(subsetGlyphs.get(gid), sid);
+ gidToSID.put(subsetGlyph.getValue(), sid);
if (mbFont != null) {
- mbFont.mapUsedGlyphName(subsetGlyphs.get(gid),
+ mbFont.mapUsedGlyphName(subsetGlyph.getValue(),
CFFStandardString.getName(sid));
}
} else {
//index is 0 based, should use < not <=
if (index < cffReader.getStringIndex().getNumObjects()) {
if (mbFont != null) {
- mbFont.mapUsedGlyphName(subsetGlyphs.get(gid),
+ mbFont.mapUsedGlyphName(subsetGlyph.getValue(),
new String(cffReader.getStringIndex().getValue(index)));
}
- gidToSID.put(subsetGlyphs.get(gid), stringIndexData.size() + 391);
+ gidToSID.put(subsetGlyph.getValue(), stringIndexData.size() + 391);
stringIndexData.add(cffReader.getStringIndex().getValue(index));
} else {
if (mbFont != null) {
- mbFont.mapUsedGlyphName(subsetGlyphs.get(gid), ".notdef");
+ mbFont.mapUsedGlyphName(subsetGlyph.getValue(), ".notdef");
}
- gidToSID.put(subsetGlyphs.get(gid), index);
+ gidToSID.put(subsetGlyph.getValue(), index);
}
}
}
foundLocalUniques.add(new ArrayList<Integer>());
}
Map<Integer, Integer> gidHintMaskLengths = new HashMap<Integer, Integer>();
- for (int gid : subsetGlyphs.keySet()) {
+ for (Entry<Integer, Integer> subsetGlyph : subsetGlyphs.entrySet()) {
+ int gid = subsetGlyph.getKey();
int group = subsetGroups.get(gid);
localIndexSubr = cffReader.getFDFonts().get(group).getLocalSubrData();
localUniques = foundLocalUniques.get(uniqueGroups.indexOf(subsetGroups.get(gid)));
FDIndexReference newFDReference = new FDIndexReference(
uniqueGroups.indexOf(subsetGroups.get(gid)), subsetGroups.get(gid));
- subsetFDSelect.put(subsetGlyphs.get(gid), newFDReference);
+ subsetFDSelect.put(subsetGlyph.getValue(), newFDReference);
byte[] data = charStringsIndex.getValue(gid);
preScanForSubsetIndexSize(data);
gidHintMaskLengths.put(gid, type2Parser.getMaskLength());
for (Integer uniqueGroup : uniqueGroups) {
foundLocalUniquesB.add(new ArrayList<Integer>());
}
- for (Integer gid : subsetGlyphs.keySet()) {
+ for (Entry<Integer, Integer> subsetGlyph : subsetGlyphs.entrySet()) {
+ int gid = subsetGlyph.getKey();
+ int value = subsetGlyph.getValue();
int group = subsetGroups.get(gid);
localIndexSubr = cffReader.getFDFonts().get(group).getLocalSubrData();
- localUniques = foundLocalUniquesB.get(subsetFDSelect.get(subsetGlyphs.get(gid)).getNewFDIndex());
+ localUniques = foundLocalUniquesB.get(subsetFDSelect.get(value).getNewFDIndex());
byte[] data = charStringsIndex.getValue(gid);
- subsetLocalIndexSubr = fdSubrs.get(subsetFDSelect.get(subsetGlyphs.get(gid)).getNewFDIndex());
- subsetLocalSubrCount = foundLocalUniques.get(subsetFDSelect.get(subsetGlyphs.get(gid))
+ subsetLocalIndexSubr = fdSubrs.get(subsetFDSelect.get(value).getNewFDIndex());
+ subsetLocalSubrCount = foundLocalUniques.get(subsetFDSelect.get(value)
.getNewFDIndex()).size();
type2Parser = new Type2Parser();
type2Parser.setMaskLength(gidHintMaskLengths.get(gid));
protected void writeFDSelect() {
writeByte(0); //Format
- for (Integer gid : subsetFDSelect.keySet()) {
- writeByte(subsetFDSelect.get(gid).getNewFDIndex());
+ for (FDIndexReference e : subsetFDSelect.values()) {
+ writeByte(e.getNewFDIndex());
}
}
protected List<Integer> getUsedFDFonts() {
List<Integer> uniqueNewRefs = new ArrayList<Integer>();
- for (int gid : subsetFDSelect.keySet()) {
- int fdIndex = subsetFDSelect.get(gid).getOldFDIndex();
+ for (FDIndexReference e : subsetFDSelect.values()) {
+ int fdIndex = e.getOldFDIndex();
if (!uniqueNewRefs.contains(fdIndex)) {
uniqueNewRefs.add(fdIndex);
}
private void writeCharsetTable(boolean cidFont) throws IOException {
writeByte(0);
- for (int gid : gidToSID.keySet()) {
- if (cidFont && gid == 0) {
+ for (Entry<Integer, Integer> entry : gidToSID.entrySet()) {
+ if (cidFont && entry.getKey() == 0) {
continue;
}
- writeCard16((cidFont) ? gid : gidToSID.get(gid));
+ writeCard16((cidFont) ? entry.getKey() : entry.getValue());
}
}
import java.io.IOException;
import java.io.InputStream;
import java.net.URISyntaxException;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
private Set<String> toGlyphSet(String[] glyphNames) {
Set<String> glyphSet = new java.util.HashSet<String>();
- for (String name : glyphNames) {
- glyphSet.add(name);
- }
+ Collections.addAll(glyphSet, glyphNames);
return glyphSet;
}
String str = super.toString();
StringBuffer buffer = new StringBuffer(64);
buffer.append(" number of variants = " + variantList.size());
- return str + buffer.toString();
+ return str + buffer;
}
}
}
}
if (log.isTraceEnabled()) {
- log.trace(" Word to hyphenate: " + sbChars.toString());
+ log.trace(" Word to hyphenate: " + sbChars);
}
// find hyphenation points
HyphContext hc = getHyphenContext(sbChars);
import java.io.IOException;
import java.io.OutputStream;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.Set;
/* generic creation of PDF object */
super(parent);
- for (Object value : values) {
- this.values.add(value);
- }
+ Collections.addAll(this.values, values);
}
/**
}
if (filterCount > 0) {
if (filterCount > 1) {
- return "/Filter [ " + sb.toString() + "]";
+ return "/Filter [ " + sb + "]";
} else {
- return "/Filter " + sb.toString();
+ return "/Filter " + sb;
}
} else {
return "";
if (!properties.isEmpty()) {
PDFDictionary dict = new PDFDictionary(this);
- for (String name : properties.keySet()) {
- dict.put(name, properties.get(name));
+ for (Map.Entry<String, PDFReference> stringPDFReferenceEntry : properties.entrySet()) {
+ dict.put(stringPDFReferenceEntry.getKey(), stringPDFReferenceEntry.getValue());
}
put("Properties", dict);
}
package org.apache.fop.render;
+import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
for (ImageHandler handler : this.handlerList) {
if (handler.isCompatible(context, null)) {
ImageFlavor[] f = handler.getSupportedImageFlavors();
- for (ImageFlavor aF : f) {
- flavors.add(aF);
- }
+ Collections.addAll(flavors, f);
}
}
return flavors.toArray(new ImageFlavor[flavors.size()]);
int[] paSrc = dp [ i + offset ];
if (paSrc != null) {
int[] paDst = new int [ 4 ];
- for (int k = 0; k < 4; k++) {
- paDst [ k ] = paSrc [ k ];
- }
+ System.arraycopy(paSrc, 0, paDst, 0, 4);
dpNew [ i ] = paDst;
}
}
private ByteArrayOutputStream updateOffsets(ByteArrayOutputStream baos, Map<Integer, byte[]> offsets)
throws IOException {
byte[] softFont = baos.toByteArray();
- for (int offset : offsets.keySet()) {
- PCLByteWriterUtil.updateDataAtLocation(softFont, offsets.get(offset), offset);
+ for (Entry<Integer, byte[]> integerEntry : offsets.entrySet()) {
+ PCLByteWriterUtil.updateDataAtLocation(softFont, integerEntry.getValue(), integerEntry.getKey());
}
baos = new ByteArrayOutputStream();
baos.write(softFont);
}
}
sb.append(")");
- return functionName + sb.toString();
+ return functionName + sb;
}
private static String toCIELabFunctionCall(ColorWithAlternatives color) {
public AFPRendererConfBuilder setDefaultResourceLevels(Map<String, String> levels) {
Element e = createElement(DEFAULT_RESOURCE_LEVELS.getName());
- for (String key : levels.keySet()) {
- e.setAttribute(key, levels.get(key));
+ for (Map.Entry<String, String> stringStringEntry : levels.entrySet()) {
+ e.setAttribute(stringStringEntry.getKey(), stringStringEntry.getValue());
}
return this;
}
}
}
GlyphCoverageTable[] gca = new GlyphCoverageTable [ mi + 1 ];
- for (String k : keys) {
- if (k.startsWith(prefix)) {
- int i = Integer.parseInt(k.substring(prefixLength));
+ for (Map.Entry<String, GlyphCoverageTable> stringGlyphCoverageTableEntry : coverages.entrySet()) {
+ if (stringGlyphCoverageTableEntry.getKey().startsWith(prefix)) {
+ int i = Integer.parseInt(stringGlyphCoverageTableEntry.getKey().substring(prefixLength));
if (i >= 0) {
- gca [ i ] = coverages.get(k);
+ gca [ i ] = stringGlyphCoverageTableEntry.getValue();
}
}
}
}
private Map<GlyphTable.LookupSpec, List<String>> extractLookups() {
Map<GlyphTable.LookupSpec, List<String>> lookups = new LinkedHashMap<GlyphTable.LookupSpec, List<String>>();
- for (String st : scripts.keySet()) {
- Map<String, List<String>> lm = scripts.get(st);
+ for (Map.Entry<String, Map<String, List<String>>> stringMapEntry : scripts.entrySet()) {
+ Map<String, List<String>> lm = stringMapEntry.getValue();
if (lm != null) {
- for (String lt : lm.keySet()) {
- List<String> fids = lm.get(lt);
+ for (Map.Entry<String, List<String>> stringListEntry : lm.entrySet()) {
+ List<String> fids = stringListEntry.getValue();
if (fids != null) {
for (String fid : fids) {
if (fid != null) {
String ft = (String) fa[0];
List<String> lids = (List<String>) fa[1];
if ((lids != null) && (lids.size() > 0)) {
- GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec(st, lt, ft);
+ GlyphTable.LookupSpec ls = new GlyphTable.LookupSpec(stringMapEntry.getKey(), stringListEntry.getKey(), ft);
lookups.put(ls, lids);
}
}
@Test
public void testGetGlyphs() {
Map<Integer, Integer> fontGlyphs = cidFull.getGlyphs();
- for (Integer key : fontGlyphs.keySet()) {
- assertEquals(fontGlyphs.get(key), glyphs.get(key));
+ for (Map.Entry<Integer, Integer> integerIntegerEntry : fontGlyphs.entrySet()) {
+ assertEquals(integerIntegerEntry.getValue(), glyphs.get(integerIntegerEntry.getKey()));
}
assertTrue(fontGlyphs.size() == glyphs.size());
}
.append("\n0000000000 65535 f \n");
for (Long objectReference : offsets) {
final String padding = "0000000000";
- String s = String.valueOf(objectReference).toString();
+ String s = String.valueOf(objectReference);
String loc = padding.substring(s.length()) + s;
expected.append(loc).append(" 00000 n \n");
}