private void addAllStylesheets(List stylesheets, TreeMap sorter, String medium) {
int count = 0;
int pCount = 0;
for (Iterator i = stylesheets.iterator(); i.hasNext(); ) {
Stylesheet stylesheet = (Stylesheet)i.next();
for (Iterator j = stylesheet.getContents().iterator(); j.hasNext(); ) {
Object obj = (Object)j.next();
if (obj instanceof Ruleset) {
for (Iterator k = ((Ruleset)obj).getFSSelectors().iterator(); k.hasNext(); ) {
Selector selector = (Selector)k.next();
selector.setPos(++count);
sorter.put(selector.getOrder(), selector);
}
} else if (obj instanceof PageRule) {
((PageRule)obj).setPos(++pCount);
_pageRules.add(obj);
} else if (obj instanceof MediaRule) {
MediaRule mediaRule = (MediaRule)obj;
if (mediaRule.matches(medium)) {
for (Iterator k = mediaRule.getContents().iterator(); k.hasNext(); ) {
Ruleset ruleset = (Ruleset)k.next();
for (Iterator l = ruleset.getFSSelectors().iterator(); l.hasNext(); ) {
Selector selector = (Selector)l.next();
selector.setPos(++count);
sorter.put(selector.getOrder(), selector);
}
}
}
}
}
_fontFaceRules.addAll(stylesheet.getFontFaceRules());
}
Collections.sort(_pageRules, new Comparator() {
public int compare(Object o1, Object o2) {
PageRule p1 = (PageRule)o1;