Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Make XMLWorker CssAppliers framework generic
Only allow subclasses of iText Elements in Map<>
  • Loading branch information
Benoit Lagae committed Apr 5, 2016
1 parent 145fd3c commit c17051c
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -68,12 +68,12 @@ public class CssAppliersImpl implements CssAppliers {
*
* public static CssAppliersImpl getInstance() { return myself; }
*/
private Map<Class<?>, CssApplier> map;
private Map<Class<?>, CssApplier<? extends Element>> map;
/**
*
*/
public CssAppliersImpl() {
map = new HashMap<Class<?>, CssApplier>();
map = new HashMap<Class<?>, CssApplier<? extends Element>>();
map.put(Chunk.class, new ChunkCssApplier(null));
map.put(Paragraph.class, new ParagraphCssApplier(this));
map.put(NoNewLineParagraph.class, new NoNewLineParagraphCssApplier());
Expand Down Expand Up @@ -102,7 +102,7 @@ public CssApplier getCssApplier(Class<?> s) {
*/
public Element apply(Element e, final Tag t, final MarginMemory mm, final PageSizeContainable psc, final HtmlPipelineContext ctx) {
CssApplier c = null;
for (Map.Entry<Class<?>, CssApplier> entry : map.entrySet()) {
for (Map.Entry<Class<?>, CssApplier<? extends Element>> entry : map.entrySet()) {
if (entry.getKey().isInstance(e)) {
c = entry.getValue();
break;
Expand Down Expand Up @@ -132,7 +132,7 @@ public void setChunkCssAplier(final ChunkCssApplier chunkCssAplier) {

public CssAppliers clone() {
CssAppliersImpl clone = getClonedObject();
clone.map = new HashMap<Class<?>, CssApplier>(this.map);
clone.map = new HashMap<Class<?>, CssApplier<? extends Element>>(this.map);
return clone;
}

Expand Down

0 comments on commit c17051c

Please sign in to comment.