提交 24f54a15 编写于 作者: R rupashka

6722802: Code improvement and warnings removing from the javax.swing.text package

Summary: Removed unnecessary castings and other warnings
Reviewed-by: peterz
Contributed-by: NFlorian Brunner <fbrunnerlist@gmx.ch>
上级 c9da1be8
...@@ -123,15 +123,15 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -123,15 +123,15 @@ public abstract class AbstractDocument implements Document, Serializable {
if (defaultI18NProperty == null) { if (defaultI18NProperty == null) {
// determine default setting for i18n support // determine default setting for i18n support
Object o = java.security.AccessController.doPrivileged( String o = java.security.AccessController.doPrivileged(
new java.security.PrivilegedAction() { new java.security.PrivilegedAction<String>() {
public Object run() { public String run() {
return System.getProperty(I18NProperty); return System.getProperty(I18NProperty);
} }
} }
); );
if (o != null) { if (o != null) {
defaultI18NProperty = Boolean.valueOf((String)o); defaultI18NProperty = Boolean.valueOf(o);
} else { } else {
defaultI18NProperty = Boolean.FALSE; defaultI18NProperty = Boolean.FALSE;
} }
...@@ -163,7 +163,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -163,7 +163,7 @@ public abstract class AbstractDocument implements Document, Serializable {
*/ */
public Dictionary<Object,Object> getDocumentProperties() { public Dictionary<Object,Object> getDocumentProperties() {
if (documentProperties == null) { if (documentProperties == null) {
documentProperties = new Hashtable(2); documentProperties = new Hashtable<Object, Object>(2);
} }
return documentProperties; return documentProperties;
} }
...@@ -467,8 +467,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -467,8 +467,7 @@ public abstract class AbstractDocument implements Document, Serializable {
* @since 1.4 * @since 1.4
*/ */
public DocumentListener[] getDocumentListeners() { public DocumentListener[] getDocumentListeners() {
return (DocumentListener[])listenerList.getListeners( return listenerList.getListeners(DocumentListener.class);
DocumentListener.class);
} }
/** /**
...@@ -508,8 +507,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -508,8 +507,7 @@ public abstract class AbstractDocument implements Document, Serializable {
* @since 1.4 * @since 1.4
*/ */
public UndoableEditListener[] getUndoableEditListeners() { public UndoableEditListener[] getUndoableEditListeners() {
return (UndoableEditListener[])listenerList.getListeners( return listenerList.getListeners(UndoableEditListener.class);
UndoableEditListener.class);
} }
/** /**
...@@ -610,7 +608,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -610,7 +608,7 @@ public abstract class AbstractDocument implements Document, Serializable {
DefaultDocumentEvent chng = DefaultDocumentEvent chng =
new DefaultDocumentEvent(offs, len, DocumentEvent.EventType.REMOVE); new DefaultDocumentEvent(offs, len, DocumentEvent.EventType.REMOVE);
boolean isComposedTextElement = false; boolean isComposedTextElement;
// Check whether the position of interest is the composed text // Check whether the position of interest is the composed text
isComposedTextElement = Utilities.isComposedTextElement(this, offs); isComposedTextElement = Utilities.isComposedTextElement(this, offs);
...@@ -1051,7 +1049,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -1051,7 +1049,7 @@ public abstract class AbstractDocument implements Document, Serializable {
byte levels[] = calculateBidiLevels( firstPStart, lastPEnd ); byte levels[] = calculateBidiLevels( firstPStart, lastPEnd );
Vector newElements = new Vector(); Vector<Element> newElements = new Vector<Element>();
// Calculate the first span of characters in the affected range with // Calculate the first span of characters in the affected range with
// the same bidi level. If this level is the same as the level of the // the same bidi level. If this level is the same as the level of the
...@@ -1831,7 +1829,6 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -1831,7 +1829,6 @@ public abstract class AbstractDocument implements Document, Serializable {
} }
out.println("["+contentStr+"]"); out.println("["+contentStr+"]");
} catch (BadLocationException e) { } catch (BadLocationException e) {
;
} }
} else { } else {
...@@ -2460,7 +2457,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -2460,7 +2457,7 @@ public abstract class AbstractDocument implements Document, Serializable {
if(nchildren == 0) if(nchildren == 0)
return null; return null;
Vector tempVector = new Vector(nchildren); Vector<AbstractElement> tempVector = new Vector<AbstractElement>(nchildren);
for(int counter = 0; counter < nchildren; counter++) for(int counter = 0; counter < nchildren; counter++)
tempVector.addElement(children[counter]); tempVector.addElement(children[counter]);
...@@ -2749,7 +2746,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -2749,7 +2746,7 @@ public abstract class AbstractDocument implements Document, Serializable {
// if the number of changes gets too great, start using // if the number of changes gets too great, start using
// a hashtable for to locate the change for a given element. // a hashtable for to locate the change for a given element.
if ((changeLookup == null) && (edits.size() > 10)) { if ((changeLookup == null) && (edits.size() > 10)) {
changeLookup = new Hashtable(); changeLookup = new Hashtable<Element, ElementChange>();
int n = edits.size(); int n = edits.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Object o = edits.elementAt(i); Object o = edits.elementAt(i);
...@@ -2918,7 +2915,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -2918,7 +2915,7 @@ public abstract class AbstractDocument implements Document, Serializable {
*/ */
public DocumentEvent.ElementChange getChange(Element elem) { public DocumentEvent.ElementChange getChange(Element elem) {
if (changeLookup != null) { if (changeLookup != null) {
return (DocumentEvent.ElementChange) changeLookup.get(elem); return changeLookup.get(elem);
} }
int n = edits.size(); int n = edits.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
...@@ -2937,7 +2934,7 @@ public abstract class AbstractDocument implements Document, Serializable { ...@@ -2937,7 +2934,7 @@ public abstract class AbstractDocument implements Document, Serializable {
private int offset; private int offset;
private int length; private int length;
private Hashtable changeLookup; private Hashtable<Element, ElementChange> changeLookup;
private DocumentEvent.EventType type; private DocumentEvent.EventType type;
} }
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package javax.swing.text; package javax.swing.text;
import java.util.*; import java.util.*;
import java.util.List;
import java.awt.*; import java.awt.*;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentEvent;
...@@ -58,7 +59,7 @@ public class AsyncBoxView extends View { ...@@ -58,7 +59,7 @@ public class AsyncBoxView extends View {
*/ */
public AsyncBoxView(Element elem, int axis) { public AsyncBoxView(Element elem, int axis) {
super(elem); super(elem);
stats = new ArrayList(); stats = new ArrayList<ChildState>();
this.axis = axis; this.axis = axis;
locator = new ChildLocator(); locator = new ChildLocator();
flushTask = new FlushTask(); flushTask = new FlushTask();
...@@ -197,7 +198,7 @@ public class AsyncBoxView extends View { ...@@ -197,7 +198,7 @@ public class AsyncBoxView extends View {
protected ChildState getChildState(int index) { protected ChildState getChildState(int index) {
synchronized(stats) { synchronized(stats) {
if ((index >= 0) && (index < stats.size())) { if ((index >= 0) && (index < stats.size())) {
return (ChildState) stats.get(index); return stats.get(index);
} }
return null; return null;
} }
...@@ -357,7 +358,7 @@ public class AsyncBoxView extends View { ...@@ -357,7 +358,7 @@ public class AsyncBoxView extends View {
synchronized(stats) { synchronized(stats) {
// remove the replaced state records // remove the replaced state records
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
ChildState cs = (ChildState)stats.remove(offset); ChildState cs = stats.remove(offset);
float csSpan = cs.getMajorSpan(); float csSpan = cs.getMajorSpan();
cs.getChildView().setParent(null); cs.getChildView().setParent(null);
...@@ -863,7 +864,7 @@ public class AsyncBoxView extends View { ...@@ -863,7 +864,7 @@ public class AsyncBoxView extends View {
/** /**
* The children and their layout statistics. * The children and their layout statistics.
*/ */
java.util.List stats; List<ChildState> stats;
/** /**
* Current span along the major axis. This * Current span along the major axis. This
...@@ -1110,7 +1111,7 @@ public class AsyncBoxView extends View { ...@@ -1110,7 +1111,7 @@ public class AsyncBoxView extends View {
*/ */
int updateChildOffsets(float targetOffset) { int updateChildOffsets(float targetOffset) {
int n = getViewCount(); int n = getViewCount();
int targetIndex = n - 1;; int targetIndex = n - 1;
int pos = lastValidOffset.getChildView().getStartOffset(); int pos = lastValidOffset.getChildView().getStartOffset();
int startIndex = getViewIndex(pos, Position.Bias.Forward); int startIndex = getViewIndex(pos, Position.Bias.Forward);
float start = lastValidOffset.getMajorOffset(); float start = lastValidOffset.getMajorOffset();
...@@ -1394,7 +1395,6 @@ public class AsyncBoxView extends View { ...@@ -1394,7 +1395,6 @@ public class AsyncBoxView extends View {
private float min; private float min;
private float pref; private float pref;
private float max; private float max;
private float align;
private boolean minorValid; private boolean minorValid;
// major axis // major axis
......
...@@ -27,6 +27,7 @@ package javax.swing.text; ...@@ -27,6 +27,7 @@ package javax.swing.text;
import java.awt.*; import java.awt.*;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.util.Set;
import javax.swing.SwingUtilities; import javax.swing.SwingUtilities;
import javax.swing.event.*; import javax.swing.event.*;
...@@ -434,7 +435,7 @@ public class ComponentView extends View { ...@@ -434,7 +435,7 @@ public class ComponentView extends View {
/** /**
* Shows or hides this component depending on the value of parameter * Shows or hides this component depending on the value of parameter
* <code>b</code>. * <code>b</code>.
* @param <code>b</code> If <code>true</code>, shows this component; * @param b If <code>true</code>, shows this component;
* otherwise, hides this component. * otherwise, hides this component.
* @see #isVisible * @see #isVisible
* @since JDK1.1 * @since JDK1.1
...@@ -480,7 +481,7 @@ public class ComponentView extends View { ...@@ -480,7 +481,7 @@ public class ComponentView extends View {
return yalign; return yalign;
} }
public java.util.Set getFocusTraversalKeys(int id) { public Set<AWTKeyStroke> getFocusTraversalKeys(int id) {
return KeyboardFocusManager.getCurrentKeyboardFocusManager(). return KeyboardFocusManager.getCurrentKeyboardFocusManager().
getDefaultFocusTraversalKeys(id); getDefaultFocusTraversalKeys(id);
} }
......
...@@ -774,8 +774,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou ...@@ -774,8 +774,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
/** /**
...@@ -1330,7 +1329,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou ...@@ -1330,7 +1329,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
if (this.dot != this.mark && component != null) { if (this.dot != this.mark && component != null) {
Clipboard clip = getSystemSelection(); Clipboard clip = getSystemSelection();
if (clip != null) { if (clip != null) {
String selectedText = null; String selectedText;
if (component instanceof JPasswordField if (component instanceof JPasswordField
&& component.getClientProperty("JPasswordField.cutCopyAllowed") != && component.getClientProperty("JPasswordField.cutCopyAllowed") !=
Boolean.TRUE) { Boolean.TRUE) {
......
...@@ -68,7 +68,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter ...@@ -68,7 +68,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter
private boolean commitOnEdit; private boolean commitOnEdit;
/** Class used to create new instances. */ /** Class used to create new instances. */
private Class valueClass; private Class<?> valueClass;
/** NavigationFilter that forwards calls back to DefaultFormatter. */ /** NavigationFilter that forwards calls back to DefaultFormatter. */
private NavigationFilter navigationFilter; private NavigationFilter navigationFilter;
...@@ -231,7 +231,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter ...@@ -231,7 +231,7 @@ public class DefaultFormatter extends JFormattedTextField.AbstractFormatter
* @return Object representation of text * @return Object representation of text
*/ */
public Object stringToValue(String string) throws ParseException { public Object stringToValue(String string) throws ParseException {
Class vc = getValueClass(); Class<?> vc = getValueClass();
JFormattedTextField ftf = getFormattedTextField(); JFormattedTextField ftf = getFormattedTextField();
if (vc == null && ftf != null) { if (vc == null && ftf != null) {
......
...@@ -56,7 +56,7 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -56,7 +56,7 @@ public class DefaultHighlighter extends LayeredHighlighter {
// PENDING(prinz) - should cull ranges not visible // PENDING(prinz) - should cull ranges not visible
int len = highlights.size(); int len = highlights.size();
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
HighlightInfo info = (HighlightInfo) highlights.elementAt(i); HighlightInfo info = highlights.elementAt(i);
if (!(info instanceof LayeredHighlightInfo)) { if (!(info instanceof LayeredHighlightInfo)) {
// Avoid allocing unless we need it. // Avoid allocing unless we need it.
Rectangle a = component.getBounds(); Rectangle a = component.getBounds();
...@@ -66,7 +66,7 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -66,7 +66,7 @@ public class DefaultHighlighter extends LayeredHighlighter {
a.width -= insets.left + insets.right; a.width -= insets.left + insets.right;
a.height -= insets.top + insets.bottom; a.height -= insets.top + insets.bottom;
for (; i < len; i++) { for (; i < len; i++) {
info = (HighlightInfo)highlights.elementAt(i); info = highlights.elementAt(i);
if (!(info instanceof LayeredHighlightInfo)) { if (!(info instanceof LayeredHighlightInfo)) {
Highlighter.HighlightPainter p = info.getPainter(); Highlighter.HighlightPainter p = info.getPainter();
p.paint(g, info.getStartOffset(), info.getEndOffset(), p.paint(g, info.getStartOffset(), info.getEndOffset(),
...@@ -159,7 +159,7 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -159,7 +159,7 @@ public class DefaultHighlighter extends LayeredHighlighter {
int p0 = -1; int p0 = -1;
int p1 = -1; int p1 = -1;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
HighlightInfo hi = (HighlightInfo)highlights.elementAt(i); HighlightInfo hi = highlights.elementAt(i);
if (hi instanceof LayeredHighlightInfo) { if (hi instanceof LayeredHighlightInfo) {
LayeredHighlightInfo info = (LayeredHighlightInfo)hi; LayeredHighlightInfo info = (LayeredHighlightInfo)hi;
minX = Math.min(minX, info.x); minX = Math.min(minX, info.x);
...@@ -195,7 +195,7 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -195,7 +195,7 @@ public class DefaultHighlighter extends LayeredHighlighter {
int p0 = Integer.MAX_VALUE; int p0 = Integer.MAX_VALUE;
int p1 = 0; int p1 = 0;
for (int i = 0; i < len; i++) { for (int i = 0; i < len; i++) {
HighlightInfo info = (HighlightInfo) highlights.elementAt(i); HighlightInfo info = highlights.elementAt(i);
p0 = Math.min(p0, info.p0.getOffset()); p0 = Math.min(p0, info.p0.getOffset());
p1 = Math.max(p1, info.p1.getOffset()); p1 = Math.max(p1, info.p1.getOffset());
} }
...@@ -282,7 +282,7 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -282,7 +282,7 @@ public class DefaultHighlighter extends LayeredHighlighter {
Shape viewBounds, Shape viewBounds,
JTextComponent editor, View view) { JTextComponent editor, View view) {
for (int counter = highlights.size() - 1; counter >= 0; counter--) { for (int counter = highlights.size() - 1; counter >= 0; counter--) {
Object tag = highlights.elementAt(counter); HighlightInfo tag = highlights.elementAt(counter);
if (tag instanceof LayeredHighlightInfo) { if (tag instanceof LayeredHighlightInfo) {
LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag; LayeredHighlightInfo lhi = (LayeredHighlightInfo)tag;
int start = lhi.getStartOffset(); int start = lhi.getStartOffset();
...@@ -333,7 +333,7 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -333,7 +333,7 @@ public class DefaultHighlighter extends LayeredHighlighter {
private final static Highlighter.Highlight[] noHighlights = private final static Highlighter.Highlight[] noHighlights =
new Highlighter.Highlight[0]; new Highlighter.Highlight[0];
private Vector highlights = new Vector(); // Vector<HighlightInfo> private Vector<HighlightInfo> highlights = new Vector<HighlightInfo>();
private JTextComponent component; private JTextComponent component;
private boolean drawsLayeredHighlights; private boolean drawsLayeredHighlights;
private SafeDamager safeDamager = new SafeDamager(); private SafeDamager safeDamager = new SafeDamager();
...@@ -573,8 +573,8 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -573,8 +573,8 @@ public class DefaultHighlighter extends LayeredHighlighter {
* call. * call.
*/ */
class SafeDamager implements Runnable { class SafeDamager implements Runnable {
private Vector p0 = new Vector(10); private Vector<Position> p0 = new Vector<Position>(10);
private Vector p1 = new Vector(10); private Vector<Position> p1 = new Vector<Position>(10);
private Document lastDoc = null; private Document lastDoc = null;
/** /**
...@@ -589,8 +589,8 @@ public class DefaultHighlighter extends LayeredHighlighter { ...@@ -589,8 +589,8 @@ public class DefaultHighlighter extends LayeredHighlighter {
int len = p0.size(); int len = p0.size();
for (int i = 0; i < len; i++){ for (int i = 0; i < len; i++){
mapper.damageRange(component, mapper.damageRange(component,
((Position)p0.get(i)).getOffset(), p0.get(i).getOffset(),
((Position)p1.get(i)).getOffset()); p1.get(i).getOffset());
} }
} }
} }
......
...@@ -84,7 +84,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -84,7 +84,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
*/ */
public DefaultStyledDocument(Content c, StyleContext styles) { public DefaultStyledDocument(Content c, StyleContext styles) {
super(c, styles); super(c, styles);
listeningStyles = new Vector(); listeningStyles = new Vector<Style>();
buffer = new ElementBuffer(createDefaultRoot()); buffer = new ElementBuffer(createDefaultRoot());
Style defaultStyle = styles.getStyle(StyleContext.DEFAULT_STYLE); Style defaultStyle = styles.getStyle(StyleContext.DEFAULT_STYLE);
setLogicalStyle(0, defaultStyle); setLogicalStyle(0, defaultStyle);
...@@ -349,7 +349,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -349,7 +349,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
int prevStartOffset = prevLeaf.getStartOffset(); int prevStartOffset = prevLeaf.getStartOffset();
BranchElement prevParent = (BranchElement) prevLeaf.getParentElement(); BranchElement prevParent = (BranchElement) prevLeaf.getParentElement();
int prevIndex = prevParent.getElementIndex(prevStartOffset); int prevIndex = prevParent.getElementIndex(prevStartOffset);
Element newElem = null; Element newElem;
newElem = createLeafElement(prevParent, prevLeaf.getAttributes(), newElem = createLeafElement(prevParent, prevLeaf.getAttributes(),
prevStartOffset, lastEndOffset); prevStartOffset, lastEndOffset);
Element[] prevRemoved = { prevLeaf }; Element[] prevRemoved = { prevLeaf };
...@@ -511,7 +511,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -511,7 +511,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
AttributeSet sCopy = s.copyAttributes(); AttributeSet sCopy = s.copyAttributes();
// PENDING(prinz) - this isn't a very efficient way to iterate // PENDING(prinz) - this isn't a very efficient way to iterate
int lastEnd = Integer.MAX_VALUE; int lastEnd;
for (int pos = offset; pos < (offset + length); pos = lastEnd) { for (int pos = offset; pos < (offset + length); pos = lastEnd) {
Element run = getCharacterElement(pos); Element run = getCharacterElement(pos);
lastEnd = run.getEndOffset(); lastEnd = run.getEndOffset();
...@@ -597,7 +597,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -597,7 +597,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
* @return the element * @return the element
*/ */
public Element getParagraphElement(int pos) { public Element getParagraphElement(int pos) {
Element e = null; Element e;
for (e = getDefaultRootElement(); ! e.isLeaf(); ) { for (e = getDefaultRootElement(); ! e.isLeaf(); ) {
int index = e.getElementIndex(pos); int index = e.getElementIndex(pos);
e = e.getElement(index); e = e.getElement(index);
...@@ -614,7 +614,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -614,7 +614,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
* @return the element * @return the element
*/ */
public Element getCharacterElement(int pos) { public Element getCharacterElement(int pos) {
Element e = null; Element e;
for (e = getDefaultRootElement(); ! e.isLeaf(); ) { for (e = getDefaultRootElement(); ! e.isLeaf(); ) {
int index = e.getElementIndex(pos); int index = e.getElementIndex(pos);
e = e.getElement(index); e = e.getElement(index);
...@@ -655,7 +655,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -655,7 +655,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
try { try {
Segment s = new Segment(); Segment s = new Segment();
Vector parseBuffer = new Vector(); Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>();
ElementSpec lastStartSpec = null; ElementSpec lastStartSpec = null;
boolean insertingAfterNewline = false; boolean insertingAfterNewline = false;
short lastStartDirection = ElementSpec.OriginateDirection; short lastStartDirection = ElementSpec.OriginateDirection;
...@@ -670,8 +670,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -670,8 +670,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
offset, endOffset); offset, endOffset);
for(int counter = parseBuffer.size() - 1; counter >= 0; for(int counter = parseBuffer.size() - 1; counter >= 0;
counter--) { counter--) {
ElementSpec spec = (ElementSpec)parseBuffer. ElementSpec spec = parseBuffer.elementAt(counter);
elementAt(counter);
if(spec.getType() == ElementSpec.StartTagType) { if(spec.getType() == ElementSpec.StartTagType) {
lastStartSpec = spec; lastStartSpec = spec;
break; break;
...@@ -709,7 +708,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -709,7 +708,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
n - lastOffset)); n - lastOffset));
} }
ElementSpec first = (ElementSpec) parseBuffer.firstElement(); ElementSpec first = parseBuffer.firstElement();
int docLength = getLength(); int docLength = getLength();
...@@ -750,7 +749,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -750,7 +749,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
// direction isn't originate, and the element at endOffset // direction isn't originate, and the element at endOffset
// is a leaf. // is a leaf.
if(insertingAtBoundry && endOffset < docLength) { if(insertingAtBoundry && endOffset < docLength) {
ElementSpec last = (ElementSpec) parseBuffer.lastElement(); ElementSpec last = parseBuffer.lastElement();
if(last.getType() == ElementSpec.ContentType && if(last.getType() == ElementSpec.ContentType &&
last.getDirection() != ElementSpec.JoinPreviousDirection && last.getDirection() != ElementSpec.JoinPreviousDirection &&
((lastStartSpec == null && (paragraph == pParagraph || ((lastStartSpec == null && (paragraph == pParagraph ||
...@@ -772,7 +771,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -772,7 +771,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
else if(!insertingAtBoundry && lastStartSpec != null && else if(!insertingAtBoundry && lastStartSpec != null &&
lastStartSpec.getDirection() == lastStartSpec.getDirection() ==
ElementSpec.JoinFractureDirection) { ElementSpec.JoinFractureDirection) {
ElementSpec last = (ElementSpec) parseBuffer.lastElement(); ElementSpec last = parseBuffer.lastElement();
if(last.getType() == ElementSpec.ContentType && if(last.getType() == ElementSpec.ContentType &&
last.getDirection() != ElementSpec.JoinPreviousDirection && last.getDirection() != ElementSpec.JoinPreviousDirection &&
attr.isEqual(cattr)) { attr.isEqual(cattr)) {
...@@ -805,7 +804,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -805,7 +804,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
* necessarily create the last start spec). * necessarily create the last start spec).
*/ */
short createSpecsForInsertAfterNewline(Element paragraph, short createSpecsForInsertAfterNewline(Element paragraph,
Element pParagraph, AttributeSet pattr, Vector parseBuffer, Element pParagraph, AttributeSet pattr, Vector<ElementSpec> parseBuffer,
int offset, int endOffset) { int offset, int endOffset) {
// Need to find the common parent of pParagraph and paragraph. // Need to find the common parent of pParagraph and paragraph.
if(paragraph.getParentElement() == pParagraph.getParentElement()) { if(paragraph.getParentElement() == pParagraph.getParentElement()) {
...@@ -825,8 +824,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -825,8 +824,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
else { else {
// Will only happen for text with more than 2 levels. // Will only happen for text with more than 2 levels.
// Find the common parent of a paragraph and pParagraph // Find the common parent of a paragraph and pParagraph
Vector leftParents = new Vector(); Vector<Element> leftParents = new Vector<Element>();
Vector rightParents = new Vector(); Vector<Element> rightParents = new Vector<Element>();
Element e = pParagraph; Element e = pParagraph;
while(e != null) { while(e != null) {
leftParents.addElement(e); leftParents.addElement(e);
...@@ -847,11 +846,10 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -847,11 +846,10 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
(null, ElementSpec.EndTagType)); (null, ElementSpec.EndTagType));
} }
// And the starts. // And the starts.
ElementSpec spec = null; ElementSpec spec;
for(int counter = rightParents.size() - 1; for(int counter = rightParents.size() - 1;
counter >= 0; counter--) { counter >= 0; counter--) {
spec = new ElementSpec(((Element)rightParents. spec = new ElementSpec(rightParents.elementAt(counter).getAttributes(),
elementAt(counter)).getAttributes(),
ElementSpec.StartTagType); ElementSpec.StartTagType);
if(counter > 0) if(counter > 0)
spec.setDirection(ElementSpec.JoinNextDirection); spec.setDirection(ElementSpec.JoinNextDirection);
...@@ -1007,7 +1005,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1007,7 +1005,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
if (listenerList.getListenerCount(DocumentListener.class) == 0) { if (listenerList.getListenerCount(DocumentListener.class) == 0) {
for (int counter = listeningStyles.size() - 1; counter >= 0; for (int counter = listeningStyles.size() - 1; counter >= 0;
counter--) { counter--) {
((Style)listeningStyles.elementAt(counter)). listeningStyles.elementAt(counter).
removeChangeListener(styleChangeListener); removeChangeListener(styleChangeListener);
} }
listeningStyles.removeAllElements(); listeningStyles.removeAllElements();
...@@ -1077,7 +1075,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1077,7 +1075,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
private void readObject(ObjectInputStream s) private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException { throws ClassNotFoundException, IOException {
listeningStyles = new Vector(); listeningStyles = new Vector<Style>();
s.defaultReadObject(); s.defaultReadObject();
// Reinstall style listeners. // Reinstall style listeners.
if (styleContextChangeListener == null && if (styleContextChangeListener == null &&
...@@ -1101,7 +1099,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1101,7 +1099,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
protected ElementBuffer buffer; protected ElementBuffer buffer;
/** Styles listening to. */ /** Styles listening to. */
private transient Vector listeningStyles; private transient Vector<Style> listeningStyles;
/** Listens to Styles. */ /** Listens to Styles. */
private transient ChangeListener styleChangeListener; private transient ChangeListener styleChangeListener;
...@@ -1401,8 +1399,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1401,8 +1399,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
*/ */
public ElementBuffer(Element root) { public ElementBuffer(Element root) {
this.root = root; this.root = root;
changes = new Vector(); changes = new Vector<ElemChanges>();
path = new Stack(); path = new Stack<ElemChanges>();
} }
/** /**
...@@ -1454,7 +1452,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1454,7 +1452,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
elem = child; elem = child;
index = elem.getElementIndex(0); index = elem.getElementIndex(0);
} }
ElemChanges ec = (ElemChanges) path.peek(); ElemChanges ec = path.peek();
Element child = ec.parent.getElement(ec.index); Element child = ec.parent.getElement(ec.index);
ec.added.addElement(createLeafElement(ec.parent, ec.added.addElement(createLeafElement(ec.parent,
child.getAttributes(), getLength(), child.getAttributes(), getLength(),
...@@ -1646,7 +1644,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1646,7 +1644,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
index = e.getElementIndex(offs); index = e.getElementIndex(offs);
} }
ElemChanges ec = (ElemChanges) path.peek(); ElemChanges ec = path.peek();
Element child = ec.parent.getElement(ec.index); Element child = ec.parent.getElement(ec.index);
// make sure there is something to do... if the // make sure there is something to do... if the
// offset is already at a boundary then there is // offset is already at a boundary then there is
...@@ -1722,15 +1720,14 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1722,15 +1720,14 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
void endEdits(DefaultDocumentEvent de) { void endEdits(DefaultDocumentEvent de) {
int n = changes.size(); int n = changes.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
ElemChanges ec = (ElemChanges) changes.elementAt(i); ElemChanges ec = changes.elementAt(i);
Element[] removed = new Element[ec.removed.size()]; Element[] removed = new Element[ec.removed.size()];
ec.removed.copyInto(removed); ec.removed.copyInto(removed);
Element[] added = new Element[ec.added.size()]; Element[] added = new Element[ec.added.size()];
ec.added.copyInto(added); ec.added.copyInto(added);
int index = ec.index; int index = ec.index;
((BranchElement) ec.parent).replace(index, removed.length, added); ((BranchElement) ec.parent).replace(index, removed.length, added);
ElementEdit ee = new ElementEdit((BranchElement) ec.parent, ElementEdit ee = new ElementEdit(ec.parent, index, removed, added);
index, removed, added);
de.addEdit(ee); de.addEdit(ee);
} }
...@@ -1767,12 +1764,12 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1767,12 +1764,12 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
this.endOffset = offset + length; this.endOffset = offset + length;
pos = offset; pos = offset;
if (changes == null) { if (changes == null) {
changes = new Vector(); changes = new Vector<ElemChanges>();
} else { } else {
changes.removeAllElements(); changes.removeAllElements();
} }
if (path == null) { if (path == null) {
path = new Stack(); path = new Stack<ElemChanges>();
} else { } else {
path.removeAllElements(); path.removeAllElements();
} }
...@@ -1799,7 +1796,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1799,7 +1796,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
} }
void pop() { void pop() {
ElemChanges ec = (ElemChanges) path.peek(); ElemChanges ec = path.peek();
path.pop(); path.pop();
if ((ec.added.size() > 0) || (ec.removed.size() > 0)) { if ((ec.added.size() > 0) || (ec.removed.size() > 0)) {
changes.addElement(ec); changes.addElement(ec);
...@@ -1808,7 +1805,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1808,7 +1805,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
if(e.getElementCount() == 0) { if(e.getElementCount() == 0) {
// if we pushed a branch element that didn't get // if we pushed a branch element that didn't get
// used, make sure its not marked as having been added. // used, make sure its not marked as having been added.
ec = (ElemChanges) path.peek(); ec = path.peek();
ec.added.removeElement(e); ec.added.removeElement(e);
} }
} }
...@@ -1822,7 +1819,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1822,7 +1819,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
} }
void insertElement(ElementSpec es) { void insertElement(ElementSpec es) {
ElemChanges ec = (ElemChanges) path.peek(); ElemChanges ec = path.peek();
switch(es.getType()) { switch(es.getType()) {
case ElementSpec.StartTagType: case ElementSpec.StartTagType:
switch(es.getDirection()) { switch(es.getDirection()) {
...@@ -1930,7 +1927,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -1930,7 +1927,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
int index0 = elem.getElementIndex(rmOffs0); int index0 = elem.getElementIndex(rmOffs0);
int index1 = elem.getElementIndex(rmOffs1); int index1 = elem.getElementIndex(rmOffs1);
push(elem, index0); push(elem, index0);
ElemChanges ec = (ElemChanges)path.peek(); ElemChanges ec = path.peek();
// if the range is contained by one element, // if the range is contained by one element,
// we just forward the request // we just forward the request
...@@ -2068,7 +2065,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2068,7 +2065,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
if (rj.getStartOffset() == rmOffs1) { if (rj.getStartOffset() == rmOffs1) {
rj = null; rj = null;
} }
Vector children = new Vector(); Vector<Element> children = new Vector<Element>();
// transfer the left // transfer the left
for (int i = 0; i < ljIndex; i++) { for (int i = 0; i < ljIndex; i++) {
...@@ -2142,7 +2139,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2142,7 +2139,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
} }
Element e = createBranchElement(parent, clonee.getAttributes()); Element e = createBranchElement(parent, clonee.getAttributes());
int n = clonee.getElementCount(); int n = clonee.getElementCount();
ArrayList childrenList = new ArrayList(n); ArrayList<Element> childrenList = new ArrayList<Element>(n);
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
Element elem = clonee.getElement(i); Element elem = clonee.getElement(i);
if (elem.getStartOffset() < rmOffs0 || elem.getEndOffset() > rmOffs1) { if (elem.getStartOffset() < rmOffs0 || elem.getEndOffset() > rmOffs1) {
...@@ -2150,7 +2147,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2150,7 +2147,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
} }
} }
Element[] children = new Element[childrenList.size()]; Element[] children = new Element[childrenList.size()];
children = (Element[])childrenList.toArray(children); children = childrenList.toArray(children);
((BranchElement)e).replace(0, 0, children); ((BranchElement)e).replace(0, 0, children);
return e; return e;
} }
...@@ -2355,7 +2352,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2355,7 +2352,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
*/ */
void fractureDeepestLeaf(ElementSpec[] specs) { void fractureDeepestLeaf(ElementSpec[] specs) {
// Split the bottommost leaf. It will be recreated elsewhere. // Split the bottommost leaf. It will be recreated elsewhere.
ElemChanges ec = (ElemChanges) path.peek(); ElemChanges ec = path.peek();
Element child = ec.parent.getElement(ec.index); Element child = ec.parent.getElement(ec.index);
// Inserts at offset 0 do not need to recreate child (it would // Inserts at offset 0 do not need to recreate child (it would
// have a length of 0!). // have a length of 0!).
...@@ -2380,7 +2377,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2380,7 +2377,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
*/ */
void insertFirstContent(ElementSpec[] specs) { void insertFirstContent(ElementSpec[] specs) {
ElementSpec firstSpec = specs[0]; ElementSpec firstSpec = specs[0];
ElemChanges ec = (ElemChanges) path.peek(); ElemChanges ec = path.peek();
Element child = ec.parent.getElement(ec.index); Element child = ec.parent.getElement(ec.index);
int firstEndOffset = offset + firstSpec.getLength(); int firstEndOffset = offset + firstSpec.getLength();
boolean isOnlyContent = (specs.length == 1); boolean isOnlyContent = (specs.length == 1);
...@@ -2463,8 +2460,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2463,8 +2460,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
transient int offset; transient int offset;
transient int length; transient int length;
transient int endOffset; transient int endOffset;
transient Vector changes; // Vector<ElemChanges> transient Vector<ElemChanges> changes;
transient Stack path; // Stack<ElemChanges> transient Stack<ElemChanges> path;
transient boolean insertOp; transient boolean insertOp;
transient boolean recreateLeafs; // For insert. transient boolean recreateLeafs; // For insert.
...@@ -2494,8 +2491,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2494,8 +2491,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
this.parent = parent; this.parent = parent;
this.index = index; this.index = index;
this.isFracture = isFracture; this.isFracture = isFracture;
added = new Vector(); added = new Vector<Element>();
removed = new Vector(); removed = new Vector<Element>();
} }
public String toString() { public String toString() {
...@@ -2504,8 +2501,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2504,8 +2501,8 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
Element parent; Element parent;
int index; int index;
Vector added; Vector<Element> added;
Vector removed; Vector<Element> removed;
boolean isFracture; boolean isFracture;
} }
...@@ -2611,7 +2608,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2611,7 +2608,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
/* This has an implicit reference to the handler object. */ /* This has an implicit reference to the handler object. */
private class DocReference extends WeakReference<DefaultStyledDocument> { private class DocReference extends WeakReference<DefaultStyledDocument> {
DocReference(DefaultStyledDocument d, ReferenceQueue q) { DocReference(DefaultStyledDocument d, ReferenceQueue<DefaultStyledDocument> q) {
super(d, q); super(d, q);
} }
...@@ -2624,19 +2621,19 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2624,19 +2621,19 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
} }
/** Class-specific reference queues. */ /** Class-specific reference queues. */
private final static Map<Class, ReferenceQueue> queueMap private final static Map<Class, ReferenceQueue<DefaultStyledDocument>> queueMap
= new HashMap<Class, ReferenceQueue>(); = new HashMap<Class, ReferenceQueue<DefaultStyledDocument>>();
/** A weak reference to the document object. */ /** A weak reference to the document object. */
private DocReference doc; private DocReference doc;
AbstractChangeHandler(DefaultStyledDocument d) { AbstractChangeHandler(DefaultStyledDocument d) {
Class c = getClass(); Class c = getClass();
ReferenceQueue q; ReferenceQueue<DefaultStyledDocument> q;
synchronized (queueMap) { synchronized (queueMap) {
q = queueMap.get(c); q = queueMap.get(c);
if (q == null) { if (q == null) {
q = new ReferenceQueue(); q = new ReferenceQueue<DefaultStyledDocument>();
queueMap.put(c, q); queueMap.put(c, q);
} }
} }
...@@ -2650,7 +2647,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc ...@@ -2650,7 +2647,7 @@ public class DefaultStyledDocument extends AbstractDocument implements StyledDoc
*/ */
static List<ChangeListener> getStaleListeners(ChangeListener l) { static List<ChangeListener> getStaleListeners(ChangeListener l) {
List<ChangeListener> staleListeners = new ArrayList<ChangeListener>(); List<ChangeListener> staleListeners = new ArrayList<ChangeListener>();
ReferenceQueue q = queueMap.get(l.getClass()); ReferenceQueue<DefaultStyledDocument> q = queueMap.get(l.getClass());
if (q != null) { if (q != null) {
DocReference r; DocReference r;
......
...@@ -72,7 +72,7 @@ public class ElementIterator implements Cloneable { ...@@ -72,7 +72,7 @@ public class ElementIterator implements Cloneable {
private Element root; private Element root;
private Stack elementStack = null; private Stack<StackItem> elementStack = null;
/** /**
* The StackItem class stores the element * The StackItem class stores the element
...@@ -148,9 +148,9 @@ public class ElementIterator implements Cloneable { ...@@ -148,9 +148,9 @@ public class ElementIterator implements Cloneable {
try { try {
ElementIterator it = new ElementIterator(root); ElementIterator it = new ElementIterator(root);
if (elementStack != null) { if (elementStack != null) {
it.elementStack = new Stack(); it.elementStack = new Stack<StackItem>();
for (int i = 0; i < elementStack.size(); i++) { for (int i = 0; i < elementStack.size(); i++) {
StackItem item = (StackItem)elementStack.elementAt(i); StackItem item = elementStack.elementAt(i);
StackItem clonee = (StackItem)item.clone(); StackItem clonee = (StackItem)item.clone();
it.elementStack.push(clonee); it.elementStack.push(clonee);
} }
...@@ -173,7 +173,7 @@ public class ElementIterator implements Cloneable { ...@@ -173,7 +173,7 @@ public class ElementIterator implements Cloneable {
return null; return null;
} }
elementStack = new Stack(); elementStack = new Stack<StackItem>();
if (root.getElementCount() != 0) { if (root.getElementCount() != 0) {
elementStack.push(new StackItem(root)); elementStack.push(new StackItem(root));
} }
...@@ -209,7 +209,7 @@ public class ElementIterator implements Cloneable { ...@@ -209,7 +209,7 @@ public class ElementIterator implements Cloneable {
get a handle to the element on top of the stack. get a handle to the element on top of the stack.
*/ */
if (! elementStack.empty()) { if (! elementStack.empty()) {
StackItem item = (StackItem)elementStack.peek(); StackItem item = elementStack.peek();
Element elem = item.getElement(); Element elem = item.getElement();
int index = item.getIndex(); int index = item.getIndex();
// self reference // self reference
...@@ -247,7 +247,7 @@ public class ElementIterator implements Cloneable { ...@@ -247,7 +247,7 @@ public class ElementIterator implements Cloneable {
// get a handle to the element on top of the stack // get a handle to the element on top of the stack
StackItem item = (StackItem)elementStack.peek(); StackItem item = elementStack.peek();
Element elem = item.getElement(); Element elem = item.getElement();
int index = item.getIndex(); int index = item.getIndex();
...@@ -272,7 +272,7 @@ public class ElementIterator implements Cloneable { ...@@ -272,7 +272,7 @@ public class ElementIterator implements Cloneable {
if (!elementStack.isEmpty()) { if (!elementStack.isEmpty()) {
/* Increment the child index for the item that /* Increment the child index for the item that
is now on top of the stack. */ is now on top of the stack. */
StackItem top = (StackItem)elementStack.peek(); StackItem top = elementStack.peek();
top.incrementIndex(); top.incrementIndex();
/* We now want to return its next child, therefore /* We now want to return its next child, therefore
call next() recursively. */ call next() recursively. */
...@@ -300,7 +300,7 @@ public class ElementIterator implements Cloneable { ...@@ -300,7 +300,7 @@ public class ElementIterator implements Cloneable {
// get a handle to the element on top of the stack // get a handle to the element on top of the stack
// //
StackItem item = (StackItem)elementStack.peek(); StackItem item = elementStack.peek();
Element elem = item.getElement(); Element elem = item.getElement();
int index = item.getIndex(); int index = item.getIndex();
...@@ -320,8 +320,8 @@ public class ElementIterator implements Cloneable { ...@@ -320,8 +320,8 @@ public class ElementIterator implements Cloneable {
/* We need to return either the item /* We need to return either the item
below the top item or one of the below the top item or one of the
former's children. */ former's children. */
Object top = elementStack.pop(); StackItem top = elementStack.pop();
item = (StackItem)elementStack.peek(); item = elementStack.peek();
// restore the top item. // restore the top item.
elementStack.push(top); elementStack.push(top);
......
...@@ -184,9 +184,9 @@ public abstract class FlowView extends BoxView { ...@@ -184,9 +184,9 @@ public abstract class FlowView extends BoxView {
final int faxis = getFlowAxis(); final int faxis = getFlowAxis();
int newSpan; int newSpan;
if (faxis == X_AXIS) { if (faxis == X_AXIS) {
newSpan = (int)width; newSpan = width;
} else { } else {
newSpan = (int)height; newSpan = height;
} }
if (layoutSpan != newSpan) { if (layoutSpan != newSpan) {
layoutChanged(faxis); layoutChanged(faxis);
...@@ -197,7 +197,7 @@ public abstract class FlowView extends BoxView { ...@@ -197,7 +197,7 @@ public abstract class FlowView extends BoxView {
// repair the flow if necessary // repair the flow if necessary
if (! isLayoutValid(faxis)) { if (! isLayoutValid(faxis)) {
final int heightAxis = getAxis(); final int heightAxis = getAxis();
int oldFlowHeight = (int)((heightAxis == X_AXIS)? getWidth() : getHeight()); int oldFlowHeight = (heightAxis == X_AXIS)? getWidth() : getHeight();
strategy.layout(this); strategy.layout(this);
int newFlowHeight = (int) getPreferredSpan(heightAxis); int newFlowHeight = (int) getPreferredSpan(heightAxis);
if (oldFlowHeight != newFlowHeight) { if (oldFlowHeight != newFlowHeight) {
......
...@@ -83,7 +83,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S ...@@ -83,7 +83,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
marks = new MarkVector(); marks = new MarkVector();
search = new MarkData(0); search = new MarkData(0);
queue = new ReferenceQueue(); queue = new ReferenceQueue<StickyPosition>();
} }
/** /**
...@@ -262,13 +262,13 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S ...@@ -262,13 +262,13 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
* it. The update table holds only a reference * it. The update table holds only a reference
* to this data. * to this data.
*/ */
final class MarkData extends WeakReference { final class MarkData extends WeakReference<StickyPosition> {
MarkData(int index) { MarkData(int index) {
super(null); super(null);
this.index = index; this.index = index;
} }
MarkData(int index, StickyPosition position, ReferenceQueue queue) { MarkData(int index, StickyPosition position, ReferenceQueue<? super StickyPosition> queue) {
super(position, queue); super(position, queue);
this.index = index; this.index = index;
} }
...@@ -287,7 +287,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S ...@@ -287,7 +287,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
} }
StickyPosition getPosition() { StickyPosition getPosition() {
return (StickyPosition)get(); return get();
} }
int index; int index;
} }
...@@ -329,7 +329,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S ...@@ -329,7 +329,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
*/ */
private transient int unusedMarks = 0; private transient int unusedMarks = 0;
private transient ReferenceQueue queue; private transient ReferenceQueue<StickyPosition> queue;
final static int GROWTH_SIZE = 1024 * 512; final static int GROWTH_SIZE = 1024 * 512;
...@@ -535,7 +535,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S ...@@ -535,7 +535,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
return 0; return 0;
} }
int cmp = 0; int cmp;
MarkData last = marks.elementAt(upper); MarkData last = marks.elementAt(upper);
cmp = compare(o, last); cmp = compare(o, last);
if (cmp > 0) if (cmp > 0)
...@@ -691,7 +691,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S ...@@ -691,7 +691,7 @@ public class GapContent extends GapVector implements AbstractDocument.Content, S
s.defaultReadObject(); s.defaultReadObject();
marks = new MarkVector(); marks = new MarkVector();
search = new MarkData(0); search = new MarkData(0);
queue = new ReferenceQueue(); queue = new ReferenceQueue<StickyPosition>();
} }
......
...@@ -27,6 +27,7 @@ package javax.swing.text; ...@@ -27,6 +27,7 @@ package javax.swing.text;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.io.*; import java.io.*;
import java.text.*; import java.text.*;
import java.text.AttributedCharacterIterator.Attribute;
import java.util.*; import java.util.*;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.*; import javax.swing.text.*;
...@@ -352,13 +353,13 @@ public class InternationalFormatter extends DefaultFormatter { ...@@ -352,13 +353,13 @@ public class InternationalFormatter extends DefaultFormatter {
updateMask(); updateMask();
} }
Map attrs = getAttributes(offset); Map<Attribute, Object> attrs = getAttributes(offset);
if (attrs != null && attrs.size() > 0) { if (attrs != null && attrs.size() > 0) {
ArrayList al = new ArrayList(); ArrayList<Attribute> al = new ArrayList<Attribute>();
al.addAll(attrs.keySet()); al.addAll(attrs.keySet());
return (Format.Field[])al.toArray(EMPTY_FIELD_ARRAY); return al.toArray(EMPTY_FIELD_ARRAY);
} }
return EMPTY_FIELD_ARRAY; return EMPTY_FIELD_ARRAY;
} }
...@@ -440,7 +441,7 @@ public class InternationalFormatter extends DefaultFormatter { ...@@ -440,7 +441,7 @@ public class InternationalFormatter extends DefaultFormatter {
/** /**
* Returns a Set of the attribute identifiers at <code>index</code>. * Returns a Set of the attribute identifiers at <code>index</code>.
*/ */
Map getAttributes(int index) { Map<Attribute, Object> getAttributes(int index) {
if (isValidMask()) { if (isValidMask()) {
AttributedCharacterIterator iterator = getIterator(); AttributedCharacterIterator iterator = getIterator();
......
...@@ -386,7 +386,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -386,7 +386,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* @since 1.4 * @since 1.4
*/ */
public CaretListener[] getCaretListeners() { public CaretListener[] getCaretListeners() {
return (CaretListener[])listenerList.getListeners(CaretListener.class); return listenerList.getListeners(CaretListener.class);
} }
/** /**
...@@ -1171,16 +1171,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -1171,16 +1171,15 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* @param actions the set of actions * @param actions the set of actions
*/ */
public static void loadKeymap(Keymap map, KeyBinding[] bindings, Action[] actions) { public static void loadKeymap(Keymap map, KeyBinding[] bindings, Action[] actions) {
Hashtable h = new Hashtable(); Hashtable<String, Action> h = new Hashtable<String, Action>();
for (int i = 0; i < actions.length; i++) { for (Action a : actions) {
Action a = actions[i];
String value = (String)a.getValue(Action.NAME); String value = (String)a.getValue(Action.NAME);
h.put((value!=null ? value:""), a); h.put((value!=null ? value:""), a);
} }
for (int i = 0; i < bindings.length; i++) { for (KeyBinding binding : bindings) {
Action a = (Action) h.get(bindings[i].actionName); Action a = h.get(binding.actionName);
if (a != null) { if (a != null) {
map.addActionForKeyStroke(bindings[i].key, a); map.addActionForKeyStroke(binding.key, a);
} }
} }
} }
...@@ -1192,11 +1191,11 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -1192,11 +1191,11 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* invoked from within a <code>doPrivileged</code>, and it is also * invoked from within a <code>doPrivileged</code>, and it is also
* assumed <code>klass</code> extends <code>JTextComponent</code>. * assumed <code>klass</code> extends <code>JTextComponent</code>.
*/ */
private static Boolean isProcessInputMethodEventOverridden(Class klass) { private static Boolean isProcessInputMethodEventOverridden(Class<?> klass) {
if (klass == JTextComponent.class) { if (klass == JTextComponent.class) {
return Boolean.FALSE; return Boolean.FALSE;
} }
Boolean retValue = (Boolean)overrideMap.get(klass.getName()); Boolean retValue = overrideMap.get(klass.getName());
if (retValue != null) { if (retValue != null) {
return retValue; return retValue;
...@@ -2053,7 +2052,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -2053,7 +2052,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
*/ */
public boolean getScrollableTracksViewportWidth() { public boolean getScrollableTracksViewportWidth() {
if (getParent() instanceof JViewport) { if (getParent() instanceof JViewport) {
return (((JViewport)getParent()).getWidth() > getPreferredSize().width); return (getParent().getWidth() > getPreferredSize().width);
} }
return false; return false;
} }
...@@ -2073,7 +2072,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -2073,7 +2072,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
*/ */
public boolean getScrollableTracksViewportHeight() { public boolean getScrollableTracksViewportHeight() {
if (getParent() instanceof JViewport) { if (getParent() instanceof JViewport) {
return (((JViewport)getParent()).getHeight() > getPreferredSize().height); return (getParent().getHeight() > getPreferredSize().height);
} }
return false; return false;
} }
...@@ -3033,7 +3032,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -3033,7 +3032,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
StyledDocument sdoc = (StyledDocument)model; StyledDocument sdoc = (StyledDocument)model;
return sdoc.getParagraphElement(index); return sdoc.getParagraphElement(index);
} else { } else {
Element para = null; Element para;
for (para = model.getDefaultRootElement(); ! para.isLeaf(); ) { for (para = model.getDefaultRootElement(); ! para.isLeaf(); ) {
int pos = para.getElementIndex(index); int pos = para.getElementIndex(index);
para = para.getElement(pos); para = para.getElement(pos);
...@@ -3535,7 +3534,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -3535,7 +3534,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
throw new BadLocationException("Location out of bounds", index); throw new BadLocationException("Location out of bounds", index);
} }
// locate the Element at index // locate the Element at index
Element indexElement = null; Element indexElement;
// locate the Element at our index/offset // locate the Element at our index/offset
int elementIndex = -1; // test for initialization int elementIndex = -1; // test for initialization
for (indexElement = model.getDefaultRootElement(); for (indexElement = model.getDefaultRootElement();
...@@ -3553,7 +3552,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -3553,7 +3552,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
// find the first Element before/after ours w/the same AttributeSet // find the first Element before/after ours w/the same AttributeSet
// if we are already at edge of the first element in our parent // if we are already at edge of the first element in our parent
// then return that edge // then return that edge
Element edgeElement = indexElement; Element edgeElement;
switch (direction) { switch (direction) {
case -1: case -1:
case 1: case 1:
...@@ -3903,7 +3902,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -3903,7 +3902,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
* Maps from class name to Boolean indicating if * Maps from class name to Boolean indicating if
* <code>processInputMethodEvent</code> has been overriden. * <code>processInputMethodEvent</code> has been overriden.
*/ */
private static Map overrideMap; private static Map<String, Boolean> overrideMap;
/** /**
* Returns a string representation of this <code>JTextComponent</code>. * Returns a string representation of this <code>JTextComponent</code>.
...@@ -4007,9 +4006,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4007,9 +4006,9 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
} }
private DataFlavor getFlavor(DataFlavor[] flavors) { private DataFlavor getFlavor(DataFlavor[] flavors) {
if (flavors != null) { if (flavors != null) {
for (int counter = 0; counter < flavors.length; counter++) { for (DataFlavor flavor : flavors) {
if (flavors[counter].equals(DataFlavor.stringFlavor)) { if (flavor.equals(DataFlavor.stringFlavor)) {
return flavors[counter]; return flavor;
} }
} }
} }
...@@ -4065,7 +4064,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4065,7 +4064,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
DefaultKeymap(String nm, Keymap parent) { DefaultKeymap(String nm, Keymap parent) {
this.nm = nm; this.nm = nm;
this.parent = parent; this.parent = parent;
bindings = new Hashtable(); bindings = new Hashtable<KeyStroke, Action>();
} }
/** /**
...@@ -4095,7 +4094,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4095,7 +4094,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
} }
public Action getAction(KeyStroke key) { public Action getAction(KeyStroke key) {
Action a = (Action) bindings.get(key); Action a = bindings.get(key);
if ((a == null) && (parent != null)) { if ((a == null) && (parent != null)) {
a = parent.getAction(key); a = parent.getAction(key);
} }
...@@ -4105,8 +4104,8 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4105,8 +4104,8 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
public KeyStroke[] getBoundKeyStrokes() { public KeyStroke[] getBoundKeyStrokes() {
KeyStroke[] keys = new KeyStroke[bindings.size()]; KeyStroke[] keys = new KeyStroke[bindings.size()];
int i = 0; int i = 0;
for (Enumeration e = bindings.keys() ; e.hasMoreElements() ;) { for (Enumeration<KeyStroke> e = bindings.keys() ; e.hasMoreElements() ;) {
keys[i++] = (KeyStroke) e.nextElement(); keys[i++] = e.nextElement();
} }
return keys; return keys;
} }
...@@ -4114,8 +4113,8 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4114,8 +4113,8 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
public Action[] getBoundActions() { public Action[] getBoundActions() {
Action[] actions = new Action[bindings.size()]; Action[] actions = new Action[bindings.size()];
int i = 0; int i = 0;
for (Enumeration e = bindings.elements() ; e.hasMoreElements() ;) { for (Enumeration<Action> e = bindings.elements() ; e.hasMoreElements() ;) {
actions[i++] = (Action) e.nextElement(); actions[i++] = e.nextElement();
} }
return actions; return actions;
} }
...@@ -4126,13 +4125,12 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4126,13 +4125,12 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
} }
KeyStroke[] retValue = null; KeyStroke[] retValue = null;
// Determine local bindings first. // Determine local bindings first.
Vector keyStrokes = null; Vector<KeyStroke> keyStrokes = null;
for (Enumeration enum_ = bindings.keys(); for (Enumeration<KeyStroke> keys = bindings.keys(); keys.hasMoreElements();) {
enum_.hasMoreElements();) { KeyStroke key = keys.nextElement();
Object key = enum_.nextElement();
if (bindings.get(key) == a) { if (bindings.get(key) == a) {
if (keyStrokes == null) { if (keyStrokes == null) {
keyStrokes = new Vector(); keyStrokes = new Vector<KeyStroke>();
} }
keyStrokes.addElement(key); keyStrokes.addElement(key);
} }
...@@ -4153,7 +4151,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4153,7 +4151,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
} }
if (rCount > 0 && rCount < pStrokes.length) { if (rCount > 0 && rCount < pStrokes.length) {
if (keyStrokes == null) { if (keyStrokes == null) {
keyStrokes = new Vector(); keyStrokes = new Vector<KeyStroke>();
} }
for (int counter = pStrokes.length - 1; counter >= 0; for (int counter = pStrokes.length - 1; counter >= 0;
counter--) { counter--) {
...@@ -4218,7 +4216,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4218,7 +4216,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
String nm; String nm;
Keymap parent; Keymap parent;
Hashtable bindings; Hashtable<KeyStroke, Action> bindings;
Action defaultAction; Action defaultAction;
} }
...@@ -4507,8 +4505,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4507,8 +4505,7 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
// //
public InputMethodRequests getInputMethodRequests() { public InputMethodRequests getInputMethodRequests() {
if (inputMethodRequestsHandler == null) { if (inputMethodRequestsHandler == null) {
inputMethodRequestsHandler = inputMethodRequestsHandler = new InputMethodRequestsHandler();
(InputMethodRequests)new InputMethodRequestsHandler();
Document doc = getDocument(); Document doc = getDocument();
if (doc != null) { if (doc != null) {
doc.addDocumentListener((DocumentListener)inputMethodRequestsHandler); doc.addDocumentListener((DocumentListener)inputMethodRequestsHandler);
...@@ -4923,16 +4920,16 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A ...@@ -4923,16 +4920,16 @@ public abstract class JTextComponent extends JComponent implements Scrollable, A
// //
private boolean isProcessInputMethodEventOverridden() { private boolean isProcessInputMethodEventOverridden() {
if (overrideMap == null) { if (overrideMap == null) {
overrideMap = Collections.synchronizedMap(new HashMap()); overrideMap = Collections.synchronizedMap(new HashMap<String, Boolean>());
} }
Boolean retValue = (Boolean)overrideMap.get(getClass().getName()); Boolean retValue = overrideMap.get(getClass().getName());
if (retValue != null) { if (retValue != null) {
return retValue.booleanValue(); return retValue.booleanValue();
} }
Boolean ret = (Boolean)AccessController.doPrivileged(new Boolean ret = AccessController.doPrivileged(new
PrivilegedAction() { PrivilegedAction<Boolean>() {
public Object run() { public Boolean run() {
return isProcessInputMethodEventOverridden( return isProcessInputMethodEventOverridden(
JTextComponent.this.getClass()); JTextComponent.this.getClass());
} }
......
...@@ -35,7 +35,7 @@ import java.util.Vector; ...@@ -35,7 +35,7 @@ import java.util.Vector;
*/ */
public class LayoutQueue { public class LayoutQueue {
Vector tasks; Vector<Runnable> tasks;
Thread worker; Thread worker;
static LayoutQueue defaultQueue; static LayoutQueue defaultQueue;
...@@ -44,7 +44,7 @@ public class LayoutQueue { ...@@ -44,7 +44,7 @@ public class LayoutQueue {
* Construct a layout queue. * Construct a layout queue.
*/ */
public LayoutQueue() { public LayoutQueue() {
tasks = new Vector(); tasks = new Vector<Runnable>();
} }
/** /**
...@@ -90,7 +90,7 @@ public class LayoutQueue { ...@@ -90,7 +90,7 @@ public class LayoutQueue {
return null; return null;
} }
} }
Runnable work = (Runnable) tasks.firstElement(); Runnable work = tasks.firstElement();
tasks.removeElementAt(0); tasks.removeElementAt(0);
return work; return work;
} }
......
...@@ -446,7 +446,7 @@ public class MaskFormatter extends DefaultFormatter { ...@@ -446,7 +446,7 @@ public class MaskFormatter extends DefaultFormatter {
*/ */
private Object stringToValue(String value, boolean completeMatch) throws private Object stringToValue(String value, boolean completeMatch) throws
ParseException { ParseException {
int errorOffset = -1; int errorOffset;
if ((errorOffset = getInvalidOffset(value, completeMatch)) == -1) { if ((errorOffset = getInvalidOffset(value, completeMatch)) == -1) {
if (!getValueContainsLiteralCharacters()) { if (!getValueContainsLiteralCharacters()) {
...@@ -498,8 +498,8 @@ public class MaskFormatter extends DefaultFormatter { ...@@ -498,8 +498,8 @@ public class MaskFormatter extends DefaultFormatter {
*/ */
private void updateInternalMask() throws ParseException { private void updateInternalMask() throws ParseException {
String mask = getMask(); String mask = getMask();
ArrayList fixed = new ArrayList(); ArrayList<MaskCharacter> fixed = new ArrayList<MaskCharacter>();
ArrayList temp = fixed; ArrayList<MaskCharacter> temp = fixed;
if (mask != null) { if (mask != null) {
for (int counter = 0, maxCounter = mask.length(); for (int counter = 0, maxCounter = mask.length();
......
...@@ -299,10 +299,7 @@ public class NumberFormatter extends InternationalFormatter { ...@@ -299,10 +299,7 @@ public class NumberFormatter extends InternationalFormatter {
if (attrs.get(NumberFormat.Field.SIGN) != null) { if (attrs.get(NumberFormat.Field.SIGN) != null) {
size--; size--;
} }
if (size == 0) { return size == 0;
return true;
}
return false;
} }
return true; return true;
} }
...@@ -315,10 +312,7 @@ public class NumberFormatter extends InternationalFormatter { ...@@ -315,10 +312,7 @@ public class NumberFormatter extends InternationalFormatter {
boolean isNavigatable(int index) { boolean isNavigatable(int index) {
if (!super.isNavigatable(index)) { if (!super.isNavigatable(index)) {
// Don't skip the decimal, it causes wierd behavior // Don't skip the decimal, it causes wierd behavior
if (getBufferedChar(index) == getDecimalSeparator()) { return getBufferedChar(index) == getDecimalSeparator();
return true;
}
return false;
} }
return true; return true;
} }
...@@ -341,11 +335,7 @@ public class NumberFormatter extends InternationalFormatter { ...@@ -341,11 +335,7 @@ public class NumberFormatter extends InternationalFormatter {
Map attrs = iterator.getAttributes(); Map attrs = iterator.getAttributes();
if (attrs != null && attrs.size() > 0) { if (attrs != null && attrs.size() > 0) {
Iterator keys = attrs.keySet().iterator(); for (Object key : attrs.keySet()) {
while (keys.hasNext()) {
Object key = keys.next();
if (key instanceof NumberFormat.Field) { if (key instanceof NumberFormat.Field) {
return (NumberFormat.Field)key; return (NumberFormat.Field)key;
} }
...@@ -461,7 +451,7 @@ public class NumberFormatter extends InternationalFormatter { ...@@ -461,7 +451,7 @@ public class NumberFormatter extends InternationalFormatter {
} }
} }
if (string != null) { if (string != null) {
Class valueClass = getValueClass(); Class<?> valueClass = getValueClass();
if (valueClass == null) { if (valueClass == null) {
valueClass = value.getClass(); valueClass = value.getClass();
......
...@@ -318,7 +318,7 @@ public class PlainDocument extends AbstractDocument { ...@@ -318,7 +318,7 @@ public class PlainDocument extends AbstractDocument {
} }
private AbstractElement defaultRoot; private AbstractElement defaultRoot;
private Vector added = new Vector(); // Vector<Element> private Vector<Element> added = new Vector<Element>();
private Vector removed = new Vector(); // Vector<Element> private Vector<Element> removed = new Vector<Element>();
private transient Segment s; private transient Segment s;
} }
...@@ -48,7 +48,7 @@ class SegmentCache { ...@@ -48,7 +48,7 @@ class SegmentCache {
/** /**
* A list of the currently unused Segments. * A list of the currently unused Segments.
*/ */
private List segments; private List<Segment> segments;
/** /**
...@@ -80,7 +80,7 @@ class SegmentCache { ...@@ -80,7 +80,7 @@ class SegmentCache {
* Creates and returns a SegmentCache. * Creates and returns a SegmentCache.
*/ */
public SegmentCache() { public SegmentCache() {
segments = new ArrayList(11); segments = new ArrayList<Segment>(11);
} }
/** /**
...@@ -92,7 +92,7 @@ class SegmentCache { ...@@ -92,7 +92,7 @@ class SegmentCache {
int size = segments.size(); int size = segments.size();
if (size > 0) { if (size > 0) {
return (Segment)segments.remove(size - 1); return segments.remove(size - 1);
} }
} }
return new CachedSegment(); return new CachedSegment();
......
...@@ -56,7 +56,7 @@ public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cl ...@@ -56,7 +56,7 @@ public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cl
*/ */
public static final AttributeSet EMPTY = new EmptyAttributeSet(); public static final AttributeSet EMPTY = new EmptyAttributeSet();
private transient Hashtable table = new Hashtable(3); private transient Hashtable<Object, Object> table = new Hashtable<Object, Object>(3);
/** /**
* Creates a new attribute set. * Creates a new attribute set.
...@@ -73,7 +73,7 @@ public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cl ...@@ -73,7 +73,7 @@ public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cl
addAttributes(source); addAttributes(source);
} }
private SimpleAttributeSet(Hashtable table) { private SimpleAttributeSet(Hashtable<Object, Object> table) {
this.table = table; this.table = table;
} }
...@@ -341,7 +341,7 @@ public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cl ...@@ -341,7 +341,7 @@ public class SimpleAttributeSet implements MutableAttributeSet, Serializable, Cl
private void readObject(ObjectInputStream s) private void readObject(ObjectInputStream s)
throws ClassNotFoundException, IOException { throws ClassNotFoundException, IOException {
s.defaultReadObject(); s.defaultReadObject();
table = new Hashtable(3); table = new Hashtable<Object, Object>(3);
StyleContext.readAttributeSet(s, this); StyleContext.readAttributeSet(s, this);
} }
......
...@@ -174,7 +174,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab ...@@ -174,7 +174,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
// some small documents won't have any sticky positions // some small documents won't have any sticky positions
// at all, so the buffer is created lazily. // at all, so the buffer is created lazily.
if (marks == null) { if (marks == null) {
marks = new Vector(); marks = new Vector<PosRec>();
} }
return new StickyPosition(offset); return new StickyPosition(offset);
} }
...@@ -226,7 +226,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab ...@@ -226,7 +226,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
} }
int n = marks.size(); int n = marks.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
PosRec mark = (PosRec) marks.elementAt(i); PosRec mark = marks.elementAt(i);
if (mark.unused) { if (mark.unused) {
// this record is no longer used, get rid of it // this record is no longer used, get rid of it
marks.removeElementAt(i); marks.removeElementAt(i);
...@@ -241,7 +241,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab ...@@ -241,7 +241,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
synchronized void updateMarksForRemove(int offset, int length) { synchronized void updateMarksForRemove(int offset, int length) {
int n = marks.size(); int n = marks.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
PosRec mark = (PosRec) marks.elementAt(i); PosRec mark = marks.elementAt(i);
if (mark.unused) { if (mark.unused) {
// this record is no longer used, get rid of it // this record is no longer used, get rid of it
marks.removeElementAt(i); marks.removeElementAt(i);
...@@ -276,7 +276,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab ...@@ -276,7 +276,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
int end = offset + length; int end = offset + length;
Vector placeIn = (v == null) ? new Vector() : v; Vector placeIn = (v == null) ? new Vector() : v;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
PosRec mark = (PosRec) marks.elementAt(i); PosRec mark = marks.elementAt(i);
if (mark.unused) { if (mark.unused) {
// this record is no longer used, get rid of it // this record is no longer used, get rid of it
marks.removeElementAt(i); marks.removeElementAt(i);
...@@ -312,7 +312,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab ...@@ -312,7 +312,7 @@ public final class StringContent implements AbstractDocument.Content, Serializab
private static final char[] empty = new char[0]; private static final char[] empty = new char[0];
private char[] data; private char[] data;
private int count; private int count;
transient Vector marks; transient Vector<PosRec> marks;
/** /**
* holds the data for a mark... separately from * holds the data for a mark... separately from
......
...@@ -246,7 +246,7 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -246,7 +246,7 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
*/ */
public Font getFont(String family, int style, int size) { public Font getFont(String family, int style, int size) {
fontSearch.setValue(family, style, size); fontSearch.setValue(family, style, size);
Font f = (Font) fontTable.get(fontSearch); Font f = fontTable.get(fontSearch);
if (f == null) { if (f == null) {
// haven't seen this one yet. // haven't seen this one yet.
Style defaultStyle = Style defaultStyle =
...@@ -517,12 +517,11 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -517,12 +517,11 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
// PENDING(prinz) should consider finding a alternative to // PENDING(prinz) should consider finding a alternative to
// generating extra garbage on search key. // generating extra garbage on search key.
SmallAttributeSet key = createSmallAttributeSet(search); SmallAttributeSet key = createSmallAttributeSet(search);
WeakReference reference = (WeakReference)attributesPool.get(key); WeakReference<SmallAttributeSet> reference = attributesPool.get(key);
SmallAttributeSet a; SmallAttributeSet a;
if (reference == null if (reference == null || (a = reference.get()) == null) {
|| (a = (SmallAttributeSet)reference.get()) == null) {
a = key; a = key;
attributesPool.put(a, new WeakReference(a)); attributesPool.put(a, new WeakReference<SmallAttributeSet>(a));
} }
return a; return a;
} }
...@@ -547,9 +546,7 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -547,9 +546,7 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
public String toString() { public String toString() {
removeUnusedSets(); removeUnusedSets();
String s = ""; String s = "";
Iterator iterator = attributesPool.keySet().iterator(); for (SmallAttributeSet set : attributesPool.keySet()) {
while (iterator.hasNext()) {
SmallAttributeSet set = (SmallAttributeSet)iterator.next();
s = s + set + "\n"; s = s + set + "\n";
} }
return s; return s;
...@@ -676,8 +673,8 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -676,8 +673,8 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
public static void registerStaticAttributeKey(Object key) { public static void registerStaticAttributeKey(Object key) {
String ioFmt = key.getClass().getName() + "." + key.toString(); String ioFmt = key.getClass().getName() + "." + key.toString();
if (freezeKeyMap == null) { if (freezeKeyMap == null) {
freezeKeyMap = new Hashtable(); freezeKeyMap = new Hashtable<Object, String>();
thawKeyMap = new Hashtable(); thawKeyMap = new Hashtable<String, Object>();
} }
freezeKeyMap.put(key, ioFmt); freezeKeyMap.put(key, ioFmt);
thawKeyMap.put(ioFmt, key); thawKeyMap.put(ioFmt, key);
...@@ -716,10 +713,10 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -716,10 +713,10 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
throws ClassNotFoundException, IOException throws ClassNotFoundException, IOException
{ {
fontSearch = new FontKey(null, 0, 0); fontSearch = new FontKey(null, 0, 0);
fontTable = new Hashtable(); fontTable = new Hashtable<FontKey, Font>();
search = new SimpleAttributeSet(); search = new SimpleAttributeSet();
attributesPool = Collections. attributesPool = Collections.
synchronizedMap(new WeakHashMap()); synchronizedMap(new WeakHashMap<SmallAttributeSet, WeakReference<SmallAttributeSet>>());
s.defaultReadObject(); s.defaultReadObject();
} }
...@@ -731,15 +728,15 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -731,15 +728,15 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
*/ */
public static final String DEFAULT_STYLE = "default"; public static final String DEFAULT_STYLE = "default";
private static Hashtable freezeKeyMap; private static Hashtable<Object, String> freezeKeyMap;
private static Hashtable thawKeyMap; private static Hashtable<String, Object> thawKeyMap;
private Style styles; private Style styles;
private transient FontKey fontSearch = new FontKey(null, 0, 0); private transient FontKey fontSearch = new FontKey(null, 0, 0);
private transient Hashtable fontTable = new Hashtable(); private transient Hashtable<FontKey, Font> fontTable = new Hashtable<FontKey, Font>();
private transient Map attributesPool = Collections. private transient Map<SmallAttributeSet, WeakReference<SmallAttributeSet>> attributesPool = Collections.
synchronizedMap(new WeakHashMap()); synchronizedMap(new WeakHashMap<SmallAttributeSet, WeakReference<SmallAttributeSet>>());
private transient MutableAttributeSet search = new SimpleAttributeSet(); private transient MutableAttributeSet search = new SimpleAttributeSet();
/** /**
...@@ -1176,8 +1173,8 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -1176,8 +1173,8 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
} }
} }
private Vector keys = new Vector(); private Vector<Object> keys = new Vector<Object>();
private Vector data = new Vector(); private Vector<Object> data = new Vector<Object>();
} }
/** /**
...@@ -1344,8 +1341,7 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon ...@@ -1344,8 +1341,7 @@ public class StyleContext implements Serializable, AbstractDocument.AttributeCon
* @since 1.4 * @since 1.4
*/ */
public ChangeListener[] getChangeListeners() { public ChangeListener[] getChangeListeners() {
return (ChangeListener[])listenerList.getListeners( return listenerList.getListeners(ChangeListener.class);
ChangeListener.class);
} }
......
...@@ -76,7 +76,7 @@ public abstract class TableView extends BoxView { ...@@ -76,7 +76,7 @@ public abstract class TableView extends BoxView {
*/ */
public TableView(Element elem) { public TableView(Element elem) {
super(elem, View.Y_AXIS); super(elem, View.Y_AXIS);
rows = new Vector(); rows = new Vector<TableRow>();
gridValid = false; gridValid = false;
} }
...@@ -139,7 +139,7 @@ public abstract class TableView extends BoxView { ...@@ -139,7 +139,7 @@ public abstract class TableView extends BoxView {
TableRow getRow(int row) { TableRow getRow(int row) {
if (row < rows.size()) { if (row < rows.size()) {
return (TableRow) rows.elementAt(row); return rows.elementAt(row);
} }
return null; return null;
} }
...@@ -227,7 +227,7 @@ public abstract class TableView extends BoxView { ...@@ -227,7 +227,7 @@ public abstract class TableView extends BoxView {
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
View v = getView(i); View v = getView(i);
if (v instanceof TableRow) { if (v instanceof TableRow) {
rows.addElement(v); rows.addElement((TableRow) v);
TableRow rv = (TableRow) v; TableRow rv = (TableRow) v;
rv.clearFilledColumns(); rv.clearFilledColumns();
rv.setRow(i); rv.setRow(i);
...@@ -368,8 +368,7 @@ public abstract class TableView extends BoxView { ...@@ -368,8 +368,7 @@ public abstract class TableView extends BoxView {
long min = 0; long min = 0;
long pref = 0; long pref = 0;
long max = 0; long max = 0;
for (int i = 0; i < columnRequirements.length; i++) { for (SizeRequirements req : columnRequirements) {
SizeRequirements req = columnRequirements[i];
min += req.minimum; min += req.minimum;
pref += req.preferred; pref += req.preferred;
max += req.maximum; max += req.maximum;
...@@ -578,7 +577,7 @@ public abstract class TableView extends BoxView { ...@@ -578,7 +577,7 @@ public abstract class TableView extends BoxView {
int[] columnSpans; int[] columnSpans;
int[] columnOffsets; int[] columnOffsets;
SizeRequirements[] columnRequirements; SizeRequirements[] columnRequirements;
Vector rows; Vector<TableRow> rows;
boolean gridValid; boolean gridValid;
static final private BitSet EMPTY = new BitSet(); static final private BitSet EMPTY = new BitSet();
......
...@@ -103,14 +103,12 @@ public abstract class TextAction extends AbstractAction { ...@@ -103,14 +103,12 @@ public abstract class TextAction extends AbstractAction {
* @return the augmented list * @return the augmented list
*/ */
public static final Action[] augmentList(Action[] list1, Action[] list2) { public static final Action[] augmentList(Action[] list1, Action[] list2) {
Hashtable h = new Hashtable(); Hashtable<String, Action> h = new Hashtable<String, Action>();
for (int i = 0; i < list1.length; i++) { for (Action a : list1) {
Action a = list1[i];
String value = (String)a.getValue(Action.NAME); String value = (String)a.getValue(Action.NAME);
h.put((value!=null ? value:""), a); h.put((value!=null ? value:""), a);
} }
for (int i = 0; i < list2.length; i++) { for (Action a : list2) {
Action a = list2[i];
String value = (String)a.getValue(Action.NAME); String value = (String)a.getValue(Action.NAME);
h.put((value!=null ? value:""), a); h.put((value!=null ? value:""), a);
} }
......
...@@ -103,7 +103,7 @@ class TextLayoutStrategy extends FlowView.FlowStrategy { ...@@ -103,7 +103,7 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
* constraints for each row. This is called by a FlowView.layout * constraints for each row. This is called by a FlowView.layout
* to update the child views in the flow. * to update the child views in the flow.
* *
* @param v the view to reflow * @param fv the view to reflow
*/ */
public void layout(FlowView fv) { public void layout(FlowView fv) {
super.layout(fv); super.layout(fv);
...@@ -485,9 +485,9 @@ class TextLayoutStrategy extends FlowView.FlowStrategy { ...@@ -485,9 +485,9 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
* Returns a map with the attributes defined on the current * Returns a map with the attributes defined on the current
* character. * character.
*/ */
public Map getAttributes() { public Map<Attribute, Object> getAttributes() {
Object[] ka = keys.toArray(); Object[] ka = keys.toArray();
Hashtable h = new Hashtable(); Hashtable<Attribute, Object> h = new Hashtable<Attribute, Object>();
for (int i = 0; i < ka.length; i++) { for (int i = 0; i < ka.length; i++) {
TextAttribute a = (TextAttribute) ka[i]; TextAttribute a = (TextAttribute) ka[i];
Object value = getAttribute(a); Object value = getAttribute(a);
...@@ -520,16 +520,16 @@ class TextLayoutStrategy extends FlowView.FlowStrategy { ...@@ -520,16 +520,16 @@ class TextLayoutStrategy extends FlowView.FlowStrategy {
* iterator's text range. The set is empty if no * iterator's text range. The set is empty if no
* attributes are defined. * attributes are defined.
*/ */
public Set getAllAttributeKeys() { public Set<Attribute> getAllAttributeKeys() {
return keys; return keys;
} }
View v; View v;
static Set keys; static Set<Attribute> keys;
static { static {
keys = new HashSet(); keys = new HashSet<Attribute>();
keys.add(TextAttribute.FONT); keys.add(TextAttribute.FONT);
keys.add(TextAttribute.RUN_DIRECTION); keys.add(TextAttribute.RUN_DIRECTION);
} }
......
...@@ -79,7 +79,7 @@ public class ZoneView extends BoxView { ...@@ -79,7 +79,7 @@ public class ZoneView extends BoxView {
int maxZoneSize = 8 * 1024; int maxZoneSize = 8 * 1024;
int maxZonesLoaded = 3; int maxZonesLoaded = 3;
Vector loadedZones; Vector<View> loadedZones;
/** /**
* Constructs a ZoneView. * Constructs a ZoneView.
...@@ -89,7 +89,7 @@ public class ZoneView extends BoxView { ...@@ -89,7 +89,7 @@ public class ZoneView extends BoxView {
*/ */
public ZoneView(Element elem, int axis) { public ZoneView(Element elem, int axis) {
super(elem, axis); super(elem, axis);
loadedZones = new Vector(); loadedZones = new Vector<View>();
} }
/** /**
...@@ -157,7 +157,7 @@ public class ZoneView extends BoxView { ...@@ -157,7 +157,7 @@ public class ZoneView extends BoxView {
void unloadOldZones() { void unloadOldZones() {
while (loadedZones.size() > getMaxZonesLoaded()) { while (loadedZones.size() > getMaxZonesLoaded()) {
View zone = (View) loadedZones.elementAt(0); View zone = loadedZones.elementAt(0);
loadedZones.removeElementAt(0); loadedZones.removeElementAt(0);
unloadZone(zone); unloadZone(zone);
} }
...@@ -206,7 +206,7 @@ public class ZoneView extends BoxView { ...@@ -206,7 +206,7 @@ public class ZoneView extends BoxView {
*/ */
protected View createZone(int p0, int p1) { protected View createZone(int p0, int p1) {
Document doc = getDocument(); Document doc = getDocument();
View zone = null; View zone;
try { try {
zone = new Zone(getElement(), zone = new Zone(getElement(),
doc.createPosition(p0), doc.createPosition(p0),
...@@ -285,7 +285,7 @@ public class ZoneView extends BoxView { ...@@ -285,7 +285,7 @@ public class ZoneView extends BoxView {
// divide the old zone into a new set of bins // divide the old zone into a new set of bins
Element elem = getElement(); Element elem = getElement();
Document doc = elem.getDocument(); Document doc = elem.getDocument();
Vector zones = new Vector(); Vector<View> zones = new Vector<View>();
int offs = offs0; int offs = offs0;
do { do {
offs0 = offs; offs0 = offs;
......
...@@ -456,7 +456,7 @@ class AccessibleHTML implements Accessible { ...@@ -456,7 +456,7 @@ class AccessibleHTML implements Accessible {
/** /**
* Sets the Cursor of this object. * Sets the Cursor of this object.
* *
* @param c the new Cursor for the object * @param cursor the new Cursor for the object
* @see #getCursor * @see #getCursor
*/ */
public void setCursor(Cursor cursor) { public void setCursor(Cursor cursor) {
...@@ -1076,7 +1076,7 @@ class AccessibleHTML implements Accessible { ...@@ -1076,7 +1076,7 @@ class AccessibleHTML implements Accessible {
StyledDocument sdoc = (StyledDocument)model; StyledDocument sdoc = (StyledDocument)model;
return sdoc.getParagraphElement(index); return sdoc.getParagraphElement(index);
} else { } else {
Element para = null; Element para;
for (para = model.getDefaultRootElement(); ! para.isLeaf(); ) { for (para = model.getDefaultRootElement(); ! para.isLeaf(); ) {
int pos = para.getElementIndex(index); int pos = para.getElementIndex(index);
para = para.getElement(pos); para = para.getElement(pos);
...@@ -1465,7 +1465,7 @@ class AccessibleHTML implements Accessible { ...@@ -1465,7 +1465,7 @@ class AccessibleHTML implements Accessible {
// Determine the max row/col count. // Determine the max row/col count.
int delta = 0; int delta = 0;
int maxCols = 0; int maxCols = 0;
int rows = 0; int rows;
for (int counter = 0; counter < getChildCount(); counter++) { for (int counter = 0; counter < getChildCount(); counter++) {
TableRowElementInfo row = getRow(counter); TableRowElementInfo row = getRow(counter);
int prev = 0; int prev = 0;
...@@ -1929,7 +1929,7 @@ class AccessibleHTML implements Accessible { ...@@ -1929,7 +1929,7 @@ class AccessibleHTML implements Accessible {
* Returns a boolean value indicating whether the specified column * Returns a boolean value indicating whether the specified column
* is selected. * is selected.
* *
* @param r zero-based column of the table * @param c zero-based column of the table
* @return the boolean value true if the specified column is selected. * @return the boolean value true if the specified column is selected.
* Otherwise, false. * Otherwise, false.
*/ */
...@@ -1966,7 +1966,7 @@ class AccessibleHTML implements Accessible { ...@@ -1966,7 +1966,7 @@ class AccessibleHTML implements Accessible {
public int [] getSelectedAccessibleRows() { public int [] getSelectedAccessibleRows() {
if (validateIfNecessary()) { if (validateIfNecessary()) {
int nRows = getAccessibleRowCount(); int nRows = getAccessibleRowCount();
Vector vec = new Vector(); Vector<Integer> vec = new Vector<Integer>();
for (int i = 0; i < nRows; i++) { for (int i = 0; i < nRows; i++) {
if (isAccessibleRowSelected(i)) { if (isAccessibleRowSelected(i)) {
...@@ -1975,7 +1975,7 @@ class AccessibleHTML implements Accessible { ...@@ -1975,7 +1975,7 @@ class AccessibleHTML implements Accessible {
} }
int retval[] = new int[vec.size()]; int retval[] = new int[vec.size()];
for (int i = 0; i < retval.length; i++) { for (int i = 0; i < retval.length; i++) {
retval[i] = ((Integer)vec.elementAt(i)).intValue(); retval[i] = vec.elementAt(i).intValue();
} }
return retval; return retval;
} }
...@@ -1991,7 +1991,7 @@ class AccessibleHTML implements Accessible { ...@@ -1991,7 +1991,7 @@ class AccessibleHTML implements Accessible {
public int [] getSelectedAccessibleColumns() { public int [] getSelectedAccessibleColumns() {
if (validateIfNecessary()) { if (validateIfNecessary()) {
int nColumns = getAccessibleRowCount(); int nColumns = getAccessibleRowCount();
Vector vec = new Vector(); Vector<Integer> vec = new Vector<Integer>();
for (int i = 0; i < nColumns; i++) { for (int i = 0; i < nColumns; i++) {
if (isAccessibleColumnSelected(i)) { if (isAccessibleColumnSelected(i)) {
...@@ -2000,7 +2000,7 @@ class AccessibleHTML implements Accessible { ...@@ -2000,7 +2000,7 @@ class AccessibleHTML implements Accessible {
} }
int retval[] = new int[vec.size()]; int retval[] = new int[vec.size()];
for (int i = 0; i < retval.length; i++) { for (int i = 0; i < retval.length; i++) {
retval[i] = ((Integer)vec.elementAt(i)).intValue(); retval[i] = vec.elementAt(i).intValue();
} }
return retval; return retval;
} }
...@@ -2134,15 +2134,16 @@ class AccessibleHTML implements Accessible { ...@@ -2134,15 +2134,16 @@ class AccessibleHTML implements Accessible {
// Header information is modeled as a Hashtable of // Header information is modeled as a Hashtable of
// ArrayLists where each Hashtable entry represents // ArrayLists where each Hashtable entry represents
// a row containing one or more headers. // a row containing one or more headers.
private Hashtable headers = new Hashtable(); private Hashtable<Integer, ArrayList<TableCellElementInfo>> headers =
new Hashtable<Integer, ArrayList<TableCellElementInfo>>();
private int rowCount = 0; private int rowCount = 0;
private int columnCount = 0; private int columnCount = 0;
public void addHeader(TableCellElementInfo cellInfo, int rowNumber) { public void addHeader(TableCellElementInfo cellInfo, int rowNumber) {
Integer rowInteger = Integer.valueOf(rowNumber); Integer rowInteger = Integer.valueOf(rowNumber);
ArrayList list = (ArrayList)headers.get(rowInteger); ArrayList<TableCellElementInfo> list = headers.get(rowInteger);
if (list == null) { if (list == null) {
list = new ArrayList(); list = new ArrayList<TableCellElementInfo>();
headers.put(rowInteger, list); headers.put(rowInteger, list);
} }
list.add(cellInfo); list.add(cellInfo);
...@@ -2201,9 +2202,9 @@ class AccessibleHTML implements Accessible { ...@@ -2201,9 +2202,9 @@ class AccessibleHTML implements Accessible {
} }
private TableCellElementInfo getElementInfoAt(int r, int c) { private TableCellElementInfo getElementInfoAt(int r, int c) {
ArrayList list = (ArrayList)headers.get(Integer.valueOf(r)); ArrayList<TableCellElementInfo> list = headers.get(Integer.valueOf(r));
if (list != null) { if (list != null) {
return (TableCellElementInfo)list.get(c); return list.get(c);
} else { } else {
return null; return null;
} }
...@@ -2364,7 +2365,7 @@ class AccessibleHTML implements Accessible { ...@@ -2364,7 +2365,7 @@ class AccessibleHTML implements Accessible {
* Returns a boolean value indicating whether the specified column * Returns a boolean value indicating whether the specified column
* is selected. * is selected.
* *
* @param r zero-based column of the table * @param c zero-based column of the table
* @return the boolean value true if the specified column is selected. * @return the boolean value true if the specified column is selected.
* Otherwise, false. * Otherwise, false.
*/ */
...@@ -2585,7 +2586,6 @@ class AccessibleHTML implements Accessible { ...@@ -2585,7 +2586,6 @@ class AccessibleHTML implements Accessible {
private void getAccessible(ElementInfo elementInfo) { private void getAccessible(ElementInfo elementInfo) {
if (elementInfo instanceof Accessible) { if (elementInfo instanceof Accessible) {
accessible = (Accessible)elementInfo; accessible = (Accessible)elementInfo;
return;
} else { } else {
for (int i = 0; i < elementInfo.getChildCount(); i++) { for (int i = 0; i < elementInfo.getChildCount(); i++) {
getAccessible(elementInfo.getChild(i)); getAccessible(elementInfo.getChild(i));
...@@ -2643,7 +2643,7 @@ class AccessibleHTML implements Accessible { ...@@ -2643,7 +2643,7 @@ class AccessibleHTML implements Accessible {
/** /**
* The children of this ElementInfo. * The children of this ElementInfo.
*/ */
private ArrayList children; private ArrayList<ElementInfo> children;
/** /**
* The Element this ElementInfo is providing information for. * The Element this ElementInfo is providing information for.
*/ */
...@@ -2754,11 +2754,11 @@ class AccessibleHTML implements Accessible { ...@@ -2754,11 +2754,11 @@ class AccessibleHTML implements Accessible {
*/ */
public ElementInfo getChild(int index) { public ElementInfo getChild(int index) {
if (validateIfNecessary()) { if (validateIfNecessary()) {
ArrayList children = this.children; ArrayList<ElementInfo> children = this.children;
if (children != null && index >= 0 && if (children != null && index >= 0 &&
index < children.size()) { index < children.size()) {
return (ElementInfo)children.get(index); return children.get(index);
} }
} }
return null; return null;
...@@ -2777,7 +2777,7 @@ class AccessibleHTML implements Accessible { ...@@ -2777,7 +2777,7 @@ class AccessibleHTML implements Accessible {
*/ */
protected void addChild(ElementInfo child) { protected void addChild(ElementInfo child) {
if (children == null) { if (children == null) {
children = new ArrayList(); children = new ArrayList<ElementInfo>();
} }
children.add(child); children.add(child);
} }
...@@ -2927,8 +2927,8 @@ class AccessibleHTML implements Accessible { ...@@ -2927,8 +2927,8 @@ class AccessibleHTML implements Accessible {
isValid = false; isValid = false;
canBeValid = first; canBeValid = first;
if (children != null) { if (children != null) {
for (int counter = 0; counter < children.size(); counter++) { for (ElementInfo child : children) {
((ElementInfo)children.get(counter)).invalidate(false); child.invalidate(false);
} }
children = null; children = null;
} }
......
...@@ -468,7 +468,7 @@ public class CSS implements Serializable { ...@@ -468,7 +468,7 @@ public class CSS implements Serializable {
public CSS() { public CSS() {
baseFontSize = baseFontSizeIndex + 1; baseFontSize = baseFontSizeIndex + 1;
// setup the css conversion table // setup the css conversion table
valueConvertor = new Hashtable(); valueConvertor = new Hashtable<Object, Object>();
valueConvertor.put(CSS.Attribute.FONT_SIZE, new FontSize()); valueConvertor.put(CSS.Attribute.FONT_SIZE, new FontSize());
valueConvertor.put(CSS.Attribute.FONT_FAMILY, new FontFamily()); valueConvertor.put(CSS.Attribute.FONT_FAMILY, new FontFamily());
valueConvertor.put(CSS.Attribute.FONT_WEIGHT, new FontWeight()); valueConvertor.put(CSS.Attribute.FONT_WEIGHT, new FontWeight());
...@@ -637,7 +637,7 @@ public class CSS implements Serializable { ...@@ -637,7 +637,7 @@ public class CSS implements Serializable {
* Maps from a StyleConstants to a CSS Attribute. * Maps from a StyleConstants to a CSS Attribute.
*/ */
Attribute styleConstantsKeyToCSSKey(StyleConstants sc) { Attribute styleConstantsKeyToCSSKey(StyleConstants sc) {
return (Attribute)styleConstantToCssMap.get(sc); return styleConstantToCssMap.get(sc);
} }
/** /**
...@@ -645,7 +645,7 @@ public class CSS implements Serializable { ...@@ -645,7 +645,7 @@ public class CSS implements Serializable {
*/ */
Object styleConstantsValueToCSSValue(StyleConstants sc, Object styleConstantsValueToCSSValue(StyleConstants sc,
Object styleValue) { Object styleValue) {
Object cssKey = styleConstantsKeyToCSSKey(sc); Attribute cssKey = styleConstantsKeyToCSSKey(sc);
if (cssKey != null) { if (cssKey != null) {
CssValue conv = (CssValue)valueConvertor.get(cssKey); CssValue conv = (CssValue)valueConvertor.get(cssKey);
return conv.fromStyleConstants(sc, styleValue); return conv.fromStyleConstants(sc, styleValue);
...@@ -659,8 +659,7 @@ public class CSS implements Serializable { ...@@ -659,8 +659,7 @@ public class CSS implements Serializable {
*/ */
Object cssValueToStyleConstantsValue(StyleConstants key, Object value) { Object cssValueToStyleConstantsValue(StyleConstants key, Object value) {
if (value instanceof CssValue) { if (value instanceof CssValue) {
return ((CssValue)value).toStyleConstants((StyleConstants)key, return ((CssValue)value).toStyleConstants(key, null);
null);
} }
return null; return null;
} }
...@@ -784,7 +783,7 @@ public class CSS implements Serializable { ...@@ -784,7 +783,7 @@ public class CSS implements Serializable {
* Convert a set of HTML attributes to an equivalent * Convert a set of HTML attributes to an equivalent
* set of CSS attributes. * set of CSS attributes.
* *
* @param AttributeSet containing the HTML attributes. * @param htmlAttrSet AttributeSet containing the HTML attributes.
* @return AttributeSet containing the corresponding CSS attributes. * @return AttributeSet containing the corresponding CSS attributes.
* The AttributeSet will be empty if there are no mapping * The AttributeSet will be empty if there are no mapping
* CSS attributes. * CSS attributes.
...@@ -841,8 +840,8 @@ public class CSS implements Serializable { ...@@ -841,8 +840,8 @@ public class CSS implements Serializable {
return cssAttrSet; return cssAttrSet;
} }
private static final Hashtable attributeMap = new Hashtable(); private static final Hashtable<String, Attribute> attributeMap = new Hashtable<String, Attribute>();
private static final Hashtable valueMap = new Hashtable(); private static final Hashtable<String, Value> valueMap = new Hashtable<String, Value>();
/** /**
* The hashtable and the static initalization block below, * The hashtable and the static initalization block below,
...@@ -854,18 +853,18 @@ public class CSS implements Serializable { ...@@ -854,18 +853,18 @@ public class CSS implements Serializable {
* Therefore, the value associated with each HTML.Attribute. * Therefore, the value associated with each HTML.Attribute.
* key ends up being an array of CSS.Attribute.* objects. * key ends up being an array of CSS.Attribute.* objects.
*/ */
private static final Hashtable htmlAttrToCssAttrMap = new Hashtable(20); private static final Hashtable<HTML.Attribute, CSS.Attribute[]> htmlAttrToCssAttrMap = new Hashtable<HTML.Attribute, CSS.Attribute[]>(20);
/** /**
* The hashtable and static initialization that follows sets * The hashtable and static initialization that follows sets
* up a translation from StyleConstants (i.e. the <em>well known</em> * up a translation from StyleConstants (i.e. the <em>well known</em>
* attributes) to the associated CSS attributes. * attributes) to the associated CSS attributes.
*/ */
private static final Hashtable styleConstantToCssMap = new Hashtable(17); private static final Hashtable<Object, Attribute> styleConstantToCssMap = new Hashtable<Object, Attribute>(17);
/** Maps from HTML value to a CSS value. Used in internal mapping. */ /** Maps from HTML value to a CSS value. Used in internal mapping. */
private static final Hashtable htmlValueToCssValueMap = new Hashtable(8); private static final Hashtable<String, CSS.Value> htmlValueToCssValueMap = new Hashtable<String, CSS.Value>(8);
/** Maps from CSS value (string) to internal value. */ /** Maps from CSS value (string) to internal value. */
private static final Hashtable cssValueToInternalValueMap = new Hashtable(13); private static final Hashtable<String, CSS.Value> cssValueToInternalValueMap = new Hashtable<String, CSS.Value>(13);
static { static {
// load the attribute map // load the attribute map
...@@ -995,8 +994,8 @@ public class CSS implements Serializable { ...@@ -995,8 +994,8 @@ public class CSS implements Serializable {
// Register all the CSS attribute keys for archival/unarchival // Register all the CSS attribute keys for archival/unarchival
Object[] keys = CSS.Attribute.allAttributes; Object[] keys = CSS.Attribute.allAttributes;
try { try {
for (int i = 0; i < keys.length; i++) { for (Object key : keys) {
StyleContext.registerStaticAttributeKey(keys[i]); StyleContext.registerStaticAttributeKey(key);
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
...@@ -1005,8 +1004,8 @@ public class CSS implements Serializable { ...@@ -1005,8 +1004,8 @@ public class CSS implements Serializable {
// Register all the CSS Values for archival/unarchival // Register all the CSS Values for archival/unarchival
keys = CSS.Value.allValues; keys = CSS.Value.allValues;
try { try {
for (int i = 0; i < keys.length; i++) { for (Object key : keys) {
StyleContext.registerStaticAttributeKey(keys[i]); StyleContext.registerStaticAttributeKey(key);
} }
} catch (Throwable e) { } catch (Throwable e) {
e.printStackTrace(); e.printStackTrace();
...@@ -1034,7 +1033,7 @@ public class CSS implements Serializable { ...@@ -1034,7 +1033,7 @@ public class CSS implements Serializable {
* doesn't represent a valid attribute key * doesn't represent a valid attribute key
*/ */
public static final Attribute getAttribute(String name) { public static final Attribute getAttribute(String name) {
return (Attribute) attributeMap.get(name); return attributeMap.get(name);
} }
/** /**
...@@ -1050,7 +1049,7 @@ public class CSS implements Serializable { ...@@ -1050,7 +1049,7 @@ public class CSS implements Serializable {
* not mean that it doesn't represent a valid CSS value * not mean that it doesn't represent a valid CSS value
*/ */
static final Value getValue(String name) { static final Value getValue(String name) {
return (Value) valueMap.get(name); return valueMap.get(name);
} }
...@@ -1159,7 +1158,7 @@ public class CSS implements Serializable { ...@@ -1159,7 +1158,7 @@ public class CSS implements Serializable {
* to a Color. * to a Color.
*/ */
static Color stringToColor(String str) { static Color stringToColor(String str) {
Color color = null; Color color;
if (str == null) { if (str == null) {
return null; return null;
...@@ -1299,7 +1298,7 @@ public class CSS implements Serializable { ...@@ -1299,7 +1298,7 @@ public class CSS implements Serializable {
static String[] parseStrings(String value) { static String[] parseStrings(String value) {
int current, last; int current, last;
int length = (value == null) ? 0 : value.length(); int length = (value == null) ? 0 : value.length();
Vector temp = new Vector(4); Vector<String> temp = new Vector<String>(4);
current = 0; current = 0;
while (current < length) { while (current < length) {
...@@ -1423,10 +1422,10 @@ public class CSS implements Serializable { ...@@ -1423,10 +1422,10 @@ public class CSS implements Serializable {
if (cssAttrList == null || htmlAttrValue == null) { if (cssAttrList == null || htmlAttrValue == null) {
return; return;
} }
for (int i = 0; i < cssAttrList.length; i++) { for (Attribute cssAttr : cssAttrList) {
Object o = getCssValue(cssAttrList[i], htmlAttrValue); Object o = getCssValue(cssAttr, htmlAttrValue);
if (o != null) { if (o != null) {
cssAttrSet.addAttribute(cssAttrList[i], o); cssAttrSet.addAttribute(cssAttr , o);
} }
} }
} }
...@@ -1452,7 +1451,7 @@ public class CSS implements Serializable { ...@@ -1452,7 +1451,7 @@ public class CSS implements Serializable {
* @return CSS.Attribute[] * @return CSS.Attribute[]
*/ */
private CSS.Attribute[] getCssAttribute(HTML.Attribute hAttr) { private CSS.Attribute[] getCssAttribute(HTML.Attribute hAttr) {
return (CSS.Attribute[])htmlAttrToCssAttrMap.get(hAttr); return htmlAttrToCssAttrMap.get(hAttr);
} }
/** /**
...@@ -2599,8 +2598,8 @@ public class CSS implements Serializable { ...@@ -2599,8 +2598,8 @@ public class CSS implements Serializable {
* to an AttributeSet or returned to the developer. * to an AttributeSet or returned to the developer.
*/ */
static class LengthUnit implements Serializable { static class LengthUnit implements Serializable {
static Hashtable lengthMapping = new Hashtable(6); static Hashtable<String, Float> lengthMapping = new Hashtable<String, Float>(6);
static Hashtable w3cLengthMapping = new Hashtable(6); static Hashtable<String, Float> w3cLengthMapping = new Hashtable<String, Float>(6);
static { static {
lengthMapping.put("pt", new Float(1f)); lengthMapping.put("pt", new Float(1f));
// Not sure about 1.3, determined by experiementation. // Not sure about 1.3, determined by experiementation.
...@@ -2642,7 +2641,7 @@ public class CSS implements Serializable { ...@@ -2642,7 +2641,7 @@ public class CSS implements Serializable {
} }
if (length >= 2) { if (length >= 2) {
units = value.substring(length - 2, length); units = value.substring(length - 2, length);
Float scale = (Float)lengthMapping.get(units); Float scale = lengthMapping.get(units);
if (scale != null) { if (scale != null) {
try { try {
this.value = Float.valueOf(value.substring(0, this.value = Float.valueOf(value.substring(0,
...@@ -2686,10 +2685,10 @@ public class CSS implements Serializable { ...@@ -2686,10 +2685,10 @@ public class CSS implements Serializable {
} }
float getValue(boolean w3cLengthUnits) { float getValue(boolean w3cLengthUnits) {
Hashtable mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping; Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
float scale = 1; float scale = 1;
if (units != null) { if (units != null) {
Float scaleFloat = (Float)mapping.get(units); Float scaleFloat = mapping.get(units);
if (scaleFloat != null) { if (scaleFloat != null) {
scale = scaleFloat.floatValue(); scale = scaleFloat.floatValue();
} }
...@@ -2699,10 +2698,10 @@ public class CSS implements Serializable { ...@@ -2699,10 +2698,10 @@ public class CSS implements Serializable {
} }
static float getValue(float value, String units, Boolean w3cLengthUnits) { static float getValue(float value, String units, Boolean w3cLengthUnits) {
Hashtable mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping; Hashtable<String, Float> mapping = (w3cLengthUnits) ? w3cLengthMapping : lengthMapping;
float scale = 1; float scale = 1;
if (units != null) { if (units != null) {
Float scaleFloat = (Float)mapping.get(units); Float scaleFloat = mapping.get(units);
if (scaleFloat != null) { if (scaleFloat != null) {
scale = scaleFloat.floatValue(); scale = scaleFloat.floatValue();
} }
...@@ -3089,7 +3088,7 @@ public class CSS implements Serializable { ...@@ -3089,7 +3088,7 @@ public class CSS implements Serializable {
iter.setIndex(i); iter.setIndex(i);
int margin0 = lastMargin; int margin0 = lastMargin;
int margin1 = (int) iter.getLeadingCollapseSpan(); int margin1 = (int) iter.getLeadingCollapseSpan();
totalSpacing += Math.max(margin0, margin1);; totalSpacing += Math.max(margin0, margin1);
preferred += (int) iter.getPreferredSpan(0); preferred += (int) iter.getPreferredSpan(0);
minimum += iter.getMinimumSpan(0); minimum += iter.getMinimumSpan(0);
maximum += iter.getMaximumSpan(0); maximum += iter.getMaximumSpan(0);
...@@ -3127,7 +3126,7 @@ public class CSS implements Serializable { ...@@ -3127,7 +3126,7 @@ public class CSS implements Serializable {
* of margin collapsing, and the flexibility to adjust the sizes. * of margin collapsing, and the flexibility to adjust the sizes.
*/ */
long preferred = 0; long preferred = 0;
long currentPreferred = 0; long currentPreferred;
int lastMargin = 0; int lastMargin = 0;
int totalSpacing = 0; int totalSpacing = 0;
int n = iter.getCount(); int n = iter.getCount();
...@@ -3199,7 +3198,7 @@ public class CSS implements Serializable { ...@@ -3199,7 +3198,7 @@ public class CSS implements Serializable {
} }
} }
// make the adjustments // make the adjustments
int totalOffset = (int)iter.getBorderWidth();; int totalOffset = (int)iter.getBorderWidth();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
iter.setIndex(i); iter.setIndex(i);
iter.setOffset( iter.getOffset() + totalOffset); iter.setOffset( iter.getOffset() + totalOffset);
...@@ -3331,7 +3330,7 @@ public class CSS implements Serializable { ...@@ -3331,7 +3330,7 @@ public class CSS implements Serializable {
s.defaultReadObject(); s.defaultReadObject();
// Reconstruct the hashtable. // Reconstruct the hashtable.
int numValues = s.readInt(); int numValues = s.readInt();
valueConvertor = new Hashtable(Math.max(1, numValues)); valueConvertor = new Hashtable<Object, Object>(Math.max(1, numValues));
while (numValues-- > 0) { while (numValues-- > 0) {
Object key = s.readObject(); Object key = s.readObject();
Object value = s.readObject(); Object value = s.readObject();
...@@ -3372,7 +3371,7 @@ public class CSS implements Serializable { ...@@ -3372,7 +3371,7 @@ public class CSS implements Serializable {
// //
/** Maps from CSS key to CssValue. */ /** Maps from CSS key to CssValue. */
private transient Hashtable valueConvertor; private transient Hashtable<Object, Object> valueConvertor;
/** Size used for relative units. */ /** Size used for relative units. */
private int baseFontSize; private int baseFontSize;
......
...@@ -133,7 +133,7 @@ public class HTML { ...@@ -133,7 +133,7 @@ public class HTML {
* *
* @return <code>true</code> if this tag is considered to be a paragraph * @return <code>true</code> if this tag is considered to be a paragraph
* in the internal HTML model. <code>false</code> - otherwise. * in the internal HTML model. <code>false</code> - otherwise.
* @see javax.swing.text.html.HTMLDocument#HTMLReader#ParagraphAction * @see HTMLDocument.HTMLReader.ParagraphAction
*/ */
boolean isParagraph() { boolean isParagraph() {
return ( return (
...@@ -536,10 +536,10 @@ public class HTML { ...@@ -536,10 +536,10 @@ public class HTML {
// that the hashtable grew to was determined, and then that very size // that the hashtable grew to was determined, and then that very size
// is used. // is used.
// //
private static final Hashtable tagHashtable = new Hashtable(73); private static final Hashtable<String, Tag> tagHashtable = new Hashtable<String, Tag>(73);
/** Maps from StyleConstant key to HTML.Tag. */ /** Maps from StyleConstant key to HTML.Tag. */
private static final Hashtable scMapping = new Hashtable(8); private static final Hashtable<Object, Tag> scMapping = new Hashtable<Object, Tag>(8);
static { static {
...@@ -598,8 +598,8 @@ public class HTML { ...@@ -598,8 +598,8 @@ public class HTML {
*/ */
public static Tag getTag(String tagName) { public static Tag getTag(String tagName) {
Object t = tagHashtable.get(tagName); Tag t = tagHashtable.get(tagName);
return (t == null ? null : (Tag)t); return (t == null ? null : t);
} }
/** /**
...@@ -613,7 +613,7 @@ public class HTML { ...@@ -613,7 +613,7 @@ public class HTML {
* <code>null</code> if not found * <code>null</code> if not found
*/ */
static Tag getTagForStyleConstantsKey(StyleConstants sc) { static Tag getTagForStyleConstantsKey(StyleConstants sc) {
return (Tag)scMapping.get(sc); return scMapping.get(sc);
} }
/** /**
...@@ -646,7 +646,7 @@ public class HTML { ...@@ -646,7 +646,7 @@ public class HTML {
public static final String NULL_ATTRIBUTE_VALUE = "#DEFAULT"; public static final String NULL_ATTRIBUTE_VALUE = "#DEFAULT";
// size determined similar to size of tagHashtable // size determined similar to size of tagHashtable
private static final Hashtable attHashtable = new Hashtable(77); private static final Hashtable<String, Attribute> attHashtable = new Hashtable<String, Attribute>(77);
static { static {
...@@ -687,11 +687,11 @@ public class HTML { ...@@ -687,11 +687,11 @@ public class HTML {
* @return the <code>Attribute</code> corresponding to <code>attName</code> * @return the <code>Attribute</code> corresponding to <code>attName</code>
*/ */
public static Attribute getAttributeKey(String attName) { public static Attribute getAttributeKey(String attName) {
Object a = attHashtable.get(attName); Attribute a = attHashtable.get(attName);
if (a == null) { if (a == null) {
return null; return null;
} }
return (Attribute)a; return a;
} }
} }
...@@ -745,7 +745,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -745,7 +745,7 @@ public class HTMLDocument extends DefaultStyledDocument {
*/ */
private Element findFrame(String frameName) { private Element findFrame(String frameName) {
ElementIterator it = new ElementIterator(this); ElementIterator it = new ElementIterator(this);
Element next = null; Element next;
while ((next = it.next()) != null) { while ((next = it.next()) != null) {
AttributeSet attr = next.getAttributes(); AttributeSet attr = next.getAttributes();
...@@ -891,7 +891,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -891,7 +891,7 @@ public class HTMLDocument extends DefaultStyledDocument {
/** /**
* Returns the Map associated with the given name. * Returns the Map associated with the given name.
* @param the name of the desired <code>Map</code> * @param name the name of the desired <code>Map</code>
* @return the <code>Map</code> or <code>null</code> if it can't * @return the <code>Map</code> or <code>null</code> if it can't
* be found, or if <code>name</code> is <code>null</code> * be found, or if <code>name</code> is <code>null</code>
*/ */
...@@ -1759,7 +1759,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -1759,7 +1759,7 @@ public class HTMLDocument extends DefaultStyledDocument {
* Used to store button groups for radio buttons in * Used to store button groups for radio buttons in
* a form. * a form.
*/ */
private HashMap radioButtonGroupsMap; private HashMap<String, ButtonGroup> radioButtonGroupsMap;
/** /**
* Document property for the number of tokens to buffer * Document property for the number of tokens to buffer
...@@ -1824,7 +1824,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -1824,7 +1824,7 @@ public class HTMLDocument extends DefaultStyledDocument {
/** /**
* I18N property key. * I18N property key.
* *
* @see AbstractDocument.I18NProperty * @see AbstractDocument#I18NProperty
*/ */
private static final String I18NProperty = "i18n"; private static final String I18NProperty = "i18n";
...@@ -1915,7 +1915,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -1915,7 +1915,7 @@ public class HTMLDocument extends DefaultStyledDocument {
AttributeSet a = (AttributeSet) AttributeSet a = (AttributeSet)
elem.getAttributes().getAttribute(tag); elem.getAttributes().getAttribute(tag);
if (a == null) { if (a == null) {
a = (AttributeSet)elem.getAttributes(); a = elem.getAttributes();
} }
return a; return a;
} }
...@@ -2193,7 +2193,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2193,7 +2193,7 @@ public class HTMLDocument extends DefaultStyledDocument {
isStyleCSS = "text/css".equals(getDefaultStyleSheetType()); isStyleCSS = "text/css".equals(getDefaultStyleSheetType());
this.offset = offset; this.offset = offset;
threshold = HTMLDocument.this.getTokenThreshold(); threshold = HTMLDocument.this.getTokenThreshold();
tagMap = new Hashtable(57); tagMap = new Hashtable<HTML.Tag, TagAction>(57);
TagAction na = new TagAction(); TagAction na = new TagAction();
TagAction ba = new BlockAction(); TagAction ba = new BlockAction();
TagAction pa = new ParagraphAction(); TagAction pa = new ParagraphAction();
...@@ -2435,7 +2435,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2435,7 +2435,7 @@ public class HTMLDocument extends DefaultStyledDocument {
(StyleConstants.NameAttribute) == HTML.Tag.BODY && (StyleConstants.NameAttribute) == HTML.Tag.BODY &&
pPath[1].getEndOffset() == length) { pPath[1].getEndOffset() == length) {
String lastText = getText(length - 1, 1); String lastText = getText(length - 1, 1);
DefaultDocumentEvent event = null; DefaultDocumentEvent event;
Element[] added; Element[] added;
Element[] removed; Element[] removed;
int index; int index;
...@@ -2496,7 +2496,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2496,7 +2496,7 @@ public class HTMLDocument extends DefaultStyledDocument {
} }
private Element[] getPathTo(int offset) { private Element[] getPathTo(int offset) {
Stack elements = new Stack(); Stack<Element> elements = new Stack<Element>();
Element e = getDefaultRootElement(); Element e = getDefaultRootElement();
int index; int index;
while (!e.isLeaf()) { while (!e.isLeaf()) {
...@@ -2610,7 +2610,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2610,7 +2610,7 @@ public class HTMLDocument extends DefaultStyledDocument {
else { else {
styleAttributes = null; styleAttributes = null;
} }
TagAction action = (TagAction) tagMap.get(t); TagAction action = tagMap.get(t);
if (action != null) { if (action != null) {
action.start(t, a); action.start(t, a);
...@@ -2640,7 +2640,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2640,7 +2640,7 @@ public class HTMLDocument extends DefaultStyledDocument {
addSpecialElement(HTML.Tag.COMMENT, sas); addSpecialElement(HTML.Tag.COMMENT, sas);
} }
TagAction action = (TagAction)tagMap.get(HTML.Tag.COMMENT); TagAction action = tagMap.get(HTML.Tag.COMMENT);
if (action != null) { if (action != null) {
action.start(HTML.Tag.COMMENT, new SimpleAttributeSet()); action.start(HTML.Tag.COMMENT, new SimpleAttributeSet());
action.end(HTML.Tag.COMMENT); action.end(HTML.Tag.COMMENT);
...@@ -2681,7 +2681,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2681,7 +2681,7 @@ public class HTMLDocument extends DefaultStyledDocument {
inBlock--; inBlock--;
} }
} }
TagAction action = (TagAction) tagMap.get(t); TagAction action = tagMap.get(t);
if (action != null) { if (action != null) {
action.end(t); action.end(t);
} }
...@@ -2707,7 +2707,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2707,7 +2707,7 @@ public class HTMLDocument extends DefaultStyledDocument {
styleAttributes = null; styleAttributes = null;
} }
TagAction action = (TagAction) tagMap.get(t); TagAction action = tagMap.get(t);
if (action != null) { if (action != null) {
action.start(t, a); action.start(t, a);
action.end(t); action.end(t);
...@@ -2802,7 +2802,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -2802,7 +2802,7 @@ public class HTMLDocument extends DefaultStyledDocument {
// might be defined in the FORM. // might be defined in the FORM.
// for new group new ButtonGroup will be created (fix for 4529702) // for new group new ButtonGroup will be created (fix for 4529702)
// group name is a key in radioButtonGroupsMap // group name is a key in radioButtonGroupsMap
radioButtonGroupsMap = new HashMap(); radioButtonGroupsMap = new HashMap<String, ButtonGroup>();
} }
public void end(HTML.Tag t) { public void end(HTML.Tag t) {
...@@ -3015,7 +3015,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3015,7 +3015,7 @@ public class HTMLDocument extends DefaultStyledDocument {
if (rel.equals("stylesheet") || if (rel.equals("stylesheet") ||
rel.equals("alternate stylesheet")) { rel.equals("alternate stylesheet")) {
if (styles == null) { if (styles == null) {
styles = new Vector(3); styles = new Vector<Object>(3);
} }
styles.addElement(t); styles.addElement(t);
styles.addElement(a.copyAttributes()); styles.addElement(a.copyAttributes());
...@@ -3055,7 +3055,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3055,7 +3055,7 @@ public class HTMLDocument extends DefaultStyledDocument {
public void start(HTML.Tag t, MutableAttributeSet a) { public void start(HTML.Tag t, MutableAttributeSet a) {
if (inHead) { if (inHead) {
if (styles == null) { if (styles == null) {
styles = new Vector(3); styles = new Vector<Object>(3);
} }
styles.addElement(t); styles.addElement(t);
styles.addElement(a.getAttribute(HTML.Attribute.TYPE)); styles.addElement(a.getAttribute(HTML.Attribute.TYPE));
...@@ -3280,7 +3280,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3280,7 +3280,7 @@ public class HTMLDocument extends DefaultStyledDocument {
String name = (String) a.getAttribute(HTML.Attribute.NAME); String name = (String) a.getAttribute(HTML.Attribute.NAME);
String value = (String) a.getAttribute(HTML.Attribute.VALUE); String value = (String) a.getAttribute(HTML.Attribute.VALUE);
if ((name != null) && (value != null)) { if ((name != null) && (value != null)) {
ElementSpec objSpec = (ElementSpec) parseBuffer.lastElement(); ElementSpec objSpec = parseBuffer.lastElement();
MutableAttributeSet objAttr = (MutableAttributeSet) objSpec.getAttributes(); MutableAttributeSet objAttr = (MutableAttributeSet) objSpec.getAttributes();
objAttr.addAttribute(name, value); objAttr.addAttribute(name, value);
} }
...@@ -3360,7 +3360,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3360,7 +3360,7 @@ public class HTMLDocument extends DefaultStyledDocument {
int size = HTML.getIntegerAttributeValue(attr, int size = HTML.getIntegerAttributeValue(attr,
HTML.Attribute.SIZE, HTML.Attribute.SIZE,
1); 1);
boolean multiple = ((String)attr.getAttribute(HTML.Attribute.MULTIPLE) != null); boolean multiple = attr.getAttribute(HTML.Attribute.MULTIPLE) != null;
if ((size > 1) || multiple) { if ((size > 1) || multiple) {
OptionListModel m = new OptionListModel(); OptionListModel m = new OptionListModel();
if (multiple) { if (multiple) {
...@@ -3460,9 +3460,9 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3460,9 +3460,9 @@ public class HTMLDocument extends DefaultStyledDocument {
if (type.equals("radio")) { if (type.equals("radio")) {
String name = (String) attr.getAttribute(HTML.Attribute.NAME); String name = (String) attr.getAttribute(HTML.Attribute.NAME);
if ( radioButtonGroupsMap == null ) { //fix for 4772743 if ( radioButtonGroupsMap == null ) { //fix for 4772743
radioButtonGroupsMap = new HashMap(); radioButtonGroupsMap = new HashMap<String, ButtonGroup>();
} }
ButtonGroup radioButtonGroup = (ButtonGroup)radioButtonGroupsMap.get(name); ButtonGroup radioButtonGroup = radioButtonGroupsMap.get(name);
if (radioButtonGroup == null) { if (radioButtonGroup == null) {
radioButtonGroup = new ButtonGroup(); radioButtonGroup = new ButtonGroup();
radioButtonGroupsMap.put(name,radioButtonGroup); radioButtonGroupsMap.put(name,radioButtonGroup);
...@@ -3604,7 +3604,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3604,7 +3604,7 @@ public class HTMLDocument extends DefaultStyledDocument {
// an open/close with no content will be removed, so we // an open/close with no content will be removed, so we
// add a space of content to keep the element being formed. // add a space of content to keep the element being formed.
ElementSpec prev = (parseBuffer.size() > 0) ? ElementSpec prev = (parseBuffer.size() > 0) ?
(ElementSpec) parseBuffer.lastElement() : null; parseBuffer.lastElement() : null;
if (prev != null && prev.getType() == ElementSpec.StartTagType) { if (prev != null && prev.getType() == ElementSpec.StartTagType) {
char[] one = new char[1]; char[] one = new char[1];
one[0] = ' '; one[0] = ' ';
...@@ -3737,7 +3737,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3737,7 +3737,7 @@ public class HTMLDocument extends DefaultStyledDocument {
// This attemps to clean it up. // This attemps to clean it up.
int removeCounter = insertTagDepthDelta; int removeCounter = insertTagDepthDelta;
while (removeCounter < 0 && size >= 0 && while (removeCounter < 0 && size >= 0 &&
((ElementSpec)parseBuffer.elementAt(size - 1)). parseBuffer.elementAt(size - 1).
getType() == ElementSpec.EndTagType) { getType() == ElementSpec.EndTagType) {
parseBuffer.removeElementAt(--size); parseBuffer.removeElementAt(--size);
removeCounter++; removeCounter++;
...@@ -3751,7 +3751,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3751,7 +3751,7 @@ public class HTMLDocument extends DefaultStyledDocument {
// an extra \n in the middle of content. // an extra \n in the middle of content.
int index = 0; int index = 0;
if (pushDepth > 0) { if (pushDepth > 0) {
if (((ElementSpec)parseBuffer.elementAt(0)).getType() == if (parseBuffer.elementAt(0).getType() ==
ElementSpec.ContentType) { ElementSpec.ContentType) {
index++; index++;
} }
...@@ -3759,19 +3759,19 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3759,19 +3759,19 @@ public class HTMLDocument extends DefaultStyledDocument {
index += (popDepth + pushDepth); index += (popDepth + pushDepth);
int cCount = 0; int cCount = 0;
int cStart = index; int cStart = index;
while (index < size && ((ElementSpec)parseBuffer.elementAt while (index < size && parseBuffer.elementAt
(index)).getType() == ElementSpec.ContentType) { (index).getType() == ElementSpec.ContentType) {
index++; index++;
cCount++; cCount++;
} }
if (cCount > 1) { if (cCount > 1) {
while (index < size && ((ElementSpec)parseBuffer.elementAt while (index < size && parseBuffer.elementAt
(index)).getType() == ElementSpec.EndTagType) { (index).getType() == ElementSpec.EndTagType) {
index++; index++;
} }
if (index == size) { if (index == size) {
char[] lastText = ((ElementSpec)parseBuffer.elementAt char[] lastText = parseBuffer.elementAt
(cStart + cCount - 1)).getArray(); (cStart + cCount - 1).getArray();
if (lastText.length == 1 && lastText[0] == NEWLINE[0]){ if (lastText.length == 1 && lastText[0] == NEWLINE[0]){
index = cStart + cCount - 1; index = cStart + cCount - 1;
while (size > index) { while (size > index) {
...@@ -3785,8 +3785,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3785,8 +3785,7 @@ public class HTMLDocument extends DefaultStyledDocument {
// Make sure there is in fact a newline // Make sure there is in fact a newline
for (int counter = parseBuffer.size() - 1; counter >= 0; for (int counter = parseBuffer.size() - 1; counter >= 0;
counter--) { counter--) {
ElementSpec spec = (ElementSpec)parseBuffer. ElementSpec spec = parseBuffer.elementAt(counter);
elementAt(counter);
if (spec.getType() == ElementSpec.ContentType) { if (spec.getType() == ElementSpec.ContentType) {
if (spec.getArray()[spec.getLength() - 1] != '\n') { if (spec.getArray()[spec.getLength() - 1] != '\n') {
SimpleAttributeSet attrs =new SimpleAttributeSet(); SimpleAttributeSet attrs =new SimpleAttributeSet();
...@@ -3817,7 +3816,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -3817,7 +3816,7 @@ public class HTMLDocument extends DefaultStyledDocument {
* of stylesheets. * of stylesheets.
*/ */
void linkCSSStyleSheet(String href) { void linkCSSStyleSheet(String href) {
URL url = null; URL url;
try { try {
url = new URL(base, href); url = new URL(base, href);
} catch (MalformedURLException mfe) { } catch (MalformedURLException mfe) {
...@@ -4031,7 +4030,7 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -4031,7 +4030,7 @@ public class HTMLDocument extends DefaultStyledDocument {
* indicating the type (may be null), and the elements following * indicating the type (may be null), and the elements following
* it until the next HTML.Tag are the rules as Strings. * it until the next HTML.Tag are the rules as Strings.
*/ */
Vector styles; Vector<Object> styles;
/** True if inside the head tag. */ /** True if inside the head tag. */
boolean inHead = false; boolean inHead = false;
/** Set to true if the style language is text/css. Since this is /** Set to true if the style language is text/css. Since this is
...@@ -4048,10 +4047,10 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -4048,10 +4047,10 @@ public class HTMLDocument extends DefaultStyledDocument {
*/ */
Option option; Option option;
protected Vector<ElementSpec> parseBuffer = new Vector(); // Vector<ElementSpec> protected Vector<ElementSpec> parseBuffer = new Vector<ElementSpec>();
protected MutableAttributeSet charAttr = new TaggedAttributeSet(); protected MutableAttributeSet charAttr = new TaggedAttributeSet();
Stack charAttrStack = new Stack(); Stack<AttributeSet> charAttrStack = new Stack<AttributeSet>();
Hashtable tagMap; Hashtable<HTML.Tag, TagAction> tagMap;
int inBlock = 0; int inBlock = 0;
/** /**
......
...@@ -898,7 +898,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -898,7 +898,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
} catch (MalformedURLException m) { } catch (MalformedURLException m) {
u = null; u = null;
} }
HyperlinkEvent linkEvent = null; HyperlinkEvent linkEvent;
if (!hdoc.isFrameDocument()) { if (!hdoc.isFrameDocument()) {
linkEvent = new HyperlinkEvent( linkEvent = new HyperlinkEvent(
...@@ -1271,11 +1271,11 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -1271,11 +1271,11 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
&& (parentContainer = container.getParent()) != null && (parentContainer = container.getParent()) != null
&& (parentContainer instanceof javax.swing.JViewport)) { && (parentContainer instanceof javax.swing.JViewport)) {
JViewport viewPort = (JViewport)parentContainer; JViewport viewPort = (JViewport)parentContainer;
Object cachedObject;
if (cachedViewPort != null) { if (cachedViewPort != null) {
if ((cachedObject = cachedViewPort.get()) != null) { JViewport cachedObject = cachedViewPort.get();
if (cachedObject != null) {
if (cachedObject != viewPort) { if (cachedObject != viewPort) {
((JComponent)cachedObject).removeComponentListener(this); cachedObject.removeComponentListener(this);
} }
} else { } else {
cachedViewPort = null; cachedViewPort = null;
...@@ -1283,7 +1283,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -1283,7 +1283,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
} }
if (cachedViewPort == null) { if (cachedViewPort == null) {
viewPort.addComponentListener(this); viewPort.addComponentListener(this);
cachedViewPort = new WeakReference(viewPort); cachedViewPort = new WeakReference<JViewport>(viewPort);
} }
componentVisibleWidth = viewPort.getExtentSize().width; componentVisibleWidth = viewPort.getExtentSize().width;
...@@ -1295,9 +1295,9 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -1295,9 +1295,9 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
} }
} else { } else {
if (cachedViewPort != null) { if (cachedViewPort != null) {
Object cachedObject; JViewport cachedObject = cachedViewPort.get();
if ((cachedObject = cachedViewPort.get()) != null) { if (cachedObject != null) {
((JComponent)cachedObject).removeComponentListener(this); cachedObject.removeComponentListener(this);
} }
cachedViewPort = null; cachedViewPort = null;
} }
...@@ -1351,7 +1351,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -1351,7 +1351,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
* we need to keep this reference in order to remove BodyBoxView from viewPort listeners. * we need to keep this reference in order to remove BodyBoxView from viewPort listeners.
* *
*/ */
private Reference cachedViewPort = null; private Reference<JViewport> cachedViewPort = null;
private boolean isListening = false; private boolean isListening = false;
private int viewVisibleWidth = Integer.MAX_VALUE; private int viewVisibleWidth = Integer.MAX_VALUE;
private int componentVisibleWidth = Integer.MAX_VALUE; private int componentVisibleWidth = Integer.MAX_VALUE;
...@@ -1928,7 +1928,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -1928,7 +1928,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
int prevEndOffset = -1; int prevEndOffset = -1;
// highlight the next link or object after the current caret position // highlight the next link or object after the current caret position
Element nextElement = null; Element nextElement;
while ((nextElement = ei.next()) != null) { while ((nextElement = ei.next()) != null) {
String name = nextElement.getName(); String name = nextElement.getName();
AttributeSet attr = nextElement.getAttributes(); AttributeSet attr = nextElement.getAttributes();
...@@ -1969,7 +1969,6 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -1969,7 +1969,6 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
comp.setCaretPosition(prevStartOffset); comp.setCaretPosition(prevStartOffset);
moveCaretPosition(comp, kit, prevStartOffset, prevEndOffset); moveCaretPosition(comp, kit, prevStartOffset, prevEndOffset);
kit.prevHypertextOffset = prevStartOffset; kit.prevHypertextOffset = prevStartOffset;
return;
} }
} }
...@@ -2113,7 +2112,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -2113,7 +2112,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
if (view != null && view instanceof ObjectView) { if (view != null && view instanceof ObjectView) {
Component comp = ((ObjectView)view).getComponent(); Component comp = ((ObjectView)view).getComponent();
if (comp != null && comp instanceof Accessible) { if (comp != null && comp instanceof Accessible) {
AccessibleContext ac = ((Accessible)comp).getAccessibleContext(); AccessibleContext ac = comp.getAccessibleContext();
if (ac != null) { if (ac != null) {
AccessibleAction aa = ac.getAccessibleAction(); AccessibleAction aa = ac.getAccessibleAction();
if (aa != null) { if (aa != null) {
...@@ -2207,7 +2206,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { ...@@ -2207,7 +2206,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible {
// invoke the next link or object action // invoke the next link or object action
String urlString = null; String urlString = null;
String objString = null; String objString = null;
Element currentElement = null; Element currentElement;
while ((currentElement = ei.next()) != null) { while ((currentElement = ei.next()) != null) {
String name = currentElement.getName(); String name = currentElement.getName();
AttributeSet attr = currentElement.getAttributes(); AttributeSet attr = currentElement.getAttributes();
......
...@@ -46,7 +46,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -46,7 +46,7 @@ public class HTMLWriter extends AbstractWriter {
* Stores all elements for which end tags have to * Stores all elements for which end tags have to
* be emitted. * be emitted.
*/ */
private Stack blockElementStack = new Stack(); private Stack<Element> blockElementStack = new Stack<Element>();
private boolean inContent = false; private boolean inContent = false;
private boolean inPre = false; private boolean inPre = false;
/** When inPre is true, this will indicate the end offset of the pre /** When inPre is true, this will indicate the end offset of the pre
...@@ -62,12 +62,12 @@ public class HTMLWriter extends AbstractWriter { ...@@ -62,12 +62,12 @@ public class HTMLWriter extends AbstractWriter {
* character level attributes. Examples include * character level attributes. Examples include
* &lt;b&gt;, &lt;i&gt;, &lt;font&gt;, and &lt;a&gt;. * &lt;b&gt;, &lt;i&gt;, &lt;font&gt;, and &lt;a&gt;.
*/ */
private Vector tags = new Vector(10); private Vector<HTML.Tag> tags = new Vector<HTML.Tag>(10);
/** /**
* Values for the tags. * Values for the tags.
*/ */
private Vector tagValues = new Vector(10); private Vector<Object> tagValues = new Vector<Object>(10);
/** /**
* Used when writing out content. * Used when writing out content.
...@@ -77,7 +77,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -77,7 +77,7 @@ public class HTMLWriter extends AbstractWriter {
/* /*
* This is used in closeOutUnwantedEmbeddedTags. * This is used in closeOutUnwantedEmbeddedTags.
*/ */
private Vector tagsToRemove = new Vector(10); private Vector<HTML.Tag> tagsToRemove = new Vector<HTML.Tag>(10);
/** /**
* Set to true after the head has been output. * Set to true after the head has been output.
...@@ -133,7 +133,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -133,7 +133,7 @@ public class HTMLWriter extends AbstractWriter {
public void write() throws IOException, BadLocationException { public void write() throws IOException, BadLocationException {
ElementIterator it = getElementIterator(); ElementIterator it = getElementIterator();
Element current = null; Element current = null;
Element next = null; Element next;
wroteHead = false; wroteHead = false;
setCurrentLineLength(0); setCurrentLineLength(0);
...@@ -169,7 +169,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -169,7 +169,7 @@ public class HTMLWriter extends AbstractWriter {
item on top of the stack, is the parent of the item on top of the stack, is the parent of the
next. next.
*/ */
Element top = (Element)blockElementStack.peek(); Element top = blockElementStack.peek();
while (top != next.getParentElement()) { while (top != next.getParentElement()) {
/* /*
pop() will return top. pop() will return top.
...@@ -183,7 +183,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -183,7 +183,7 @@ public class HTMLWriter extends AbstractWriter {
} }
endTag(top); endTag(top);
} }
top = (Element)blockElementStack.peek(); top = blockElementStack.peek();
} }
} else if (current.getParentElement() == next.getParentElement()) { } else if (current.getParentElement() == next.getParentElement()) {
/* /*
...@@ -191,7 +191,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -191,7 +191,7 @@ public class HTMLWriter extends AbstractWriter {
is correct. But, we need to make sure that if current is is correct. But, we need to make sure that if current is
on the stack, we pop it off, and put out its end tag. on the stack, we pop it off, and put out its end tag.
*/ */
Element top = (Element)blockElementStack.peek(); Element top = blockElementStack.peek();
if (top == current) { if (top == current) {
blockElementStack.pop(); blockElementStack.pop();
endTag(top); endTag(top);
...@@ -219,7 +219,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -219,7 +219,7 @@ public class HTMLWriter extends AbstractWriter {
endTag(current); endTag(current);
} }
while (!blockElementStack.empty()) { while (!blockElementStack.empty()) {
current = (Element)blockElementStack.pop(); current = blockElementStack.pop();
if (!synthesizedElement(current)) { if (!synthesizedElement(current)) {
AttributeSet attrs = current.getAttributes(); AttributeSet attrs = current.getAttributes();
if (!matchNameAttribute(attrs, HTML.Tag.PRE) && if (!matchNameAttribute(attrs, HTML.Tag.PRE) &&
...@@ -308,7 +308,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -308,7 +308,7 @@ public class HTMLWriter extends AbstractWriter {
// //
if (nameTag != null && endTag != null && if (nameTag != null && endTag != null &&
(endTag instanceof String) && (endTag instanceof String) &&
((String)endTag).equals("true")) { endTag.equals("true")) {
outputEndTag = true; outputEndTag = true;
} }
...@@ -769,7 +769,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -769,7 +769,7 @@ public class HTMLWriter extends AbstractWriter {
int size = tags.size(); int size = tags.size();
// First, find all the tags that need to be removed. // First, find all the tags that need to be removed.
for (int i = size - 1; i >= 0; i--) { for (int i = size - 1; i >= 0; i--) {
t = (HTML.Tag)tags.elementAt(i); t = tags.elementAt(i);
tValue = tagValues.elementAt(i); tValue = tagValues.elementAt(i);
if ((attr == null) || noMatchForTagInAttributes(attr, t, tValue)) { if ((attr == null) || noMatchForTagInAttributes(attr, t, tValue)) {
firstIndex = i; firstIndex = i;
...@@ -780,7 +780,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -780,7 +780,7 @@ public class HTMLWriter extends AbstractWriter {
// Then close them out. // Then close them out.
boolean removeAll = ((size - firstIndex) == tagsToRemove.size()); boolean removeAll = ((size - firstIndex) == tagsToRemove.size());
for (int i = size - 1; i >= firstIndex; i--) { for (int i = size - 1; i >= firstIndex; i--) {
t = (HTML.Tag)tags.elementAt(i); t = tags.elementAt(i);
if (removeAll || tagsToRemove.contains(t)) { if (removeAll || tagsToRemove.contains(t)) {
tags.removeElementAt(i); tags.removeElementAt(i);
tagValues.removeElementAt(i); tagValues.removeElementAt(i);
...@@ -794,7 +794,7 @@ public class HTMLWriter extends AbstractWriter { ...@@ -794,7 +794,7 @@ public class HTMLWriter extends AbstractWriter {
// as we closed them out, but they should remain open. // as we closed them out, but they should remain open.
size = tags.size(); size = tags.size();
for (int i = firstIndex; i < size; i++) { for (int i = firstIndex; i < size; i++) {
t = (HTML.Tag)tags.elementAt(i); t = tags.elementAt(i);
write('<'); write('<');
write(t.toString()); write(t.toString());
Object o = tagValues.elementAt(i); Object o = tagValues.elementAt(i);
...@@ -813,11 +813,8 @@ public class HTMLWriter extends AbstractWriter { ...@@ -813,11 +813,8 @@ public class HTMLWriter extends AbstractWriter {
* false * false
*/ */
private boolean isFormElementWithContent(AttributeSet attr) { private boolean isFormElementWithContent(AttributeSet attr) {
if (matchNameAttribute(attr, HTML.Tag.TEXTAREA) || return matchNameAttribute(attr, HTML.Tag.TEXTAREA) ||
matchNameAttribute(attr, HTML.Tag.SELECT)) { matchNameAttribute(attr, HTML.Tag.SELECT);
return true;
}
return false;
} }
......
...@@ -41,10 +41,10 @@ class Map implements Serializable { ...@@ -41,10 +41,10 @@ class Map implements Serializable {
/** Name of the Map. */ /** Name of the Map. */
private String name; private String name;
/** An array of AttributeSets. */ /** An array of AttributeSets. */
private Vector areaAttributes; private Vector<AttributeSet> areaAttributes;
/** An array of RegionContainments, will slowly grow to match the /** An array of RegionContainments, will slowly grow to match the
* length of areaAttributes as needed. */ * length of areaAttributes as needed. */
private Vector areas; private Vector<RegionContainment> areas;
public Map() { public Map() {
} }
...@@ -68,7 +68,7 @@ class Map implements Serializable { ...@@ -68,7 +68,7 @@ class Map implements Serializable {
return; return;
} }
if (areaAttributes == null) { if (areaAttributes == null) {
areaAttributes = new Vector(2); areaAttributes = new Vector<AttributeSet>(2);
} }
areaAttributes.addElement(as.copyAttributes()); areaAttributes.addElement(as.copyAttributes());
} }
...@@ -81,8 +81,7 @@ class Map implements Serializable { ...@@ -81,8 +81,7 @@ class Map implements Serializable {
int numAreas = (areas != null) ? areas.size() : 0; int numAreas = (areas != null) ? areas.size() : 0;
for (int counter = areaAttributes.size() - 1; counter >= 0; for (int counter = areaAttributes.size() - 1; counter >= 0;
counter--) { counter--) {
if (((AttributeSet)areaAttributes.elementAt(counter)). if (areaAttributes.elementAt(counter).isEqual(as)){
isEqual(as)){
areaAttributes.removeElementAt(counter); areaAttributes.removeElementAt(counter);
if (counter < numAreas) { if (counter < numAreas) {
areas.removeElementAt(counter); areas.removeElementAt(counter);
...@@ -121,17 +120,16 @@ class Map implements Serializable { ...@@ -121,17 +120,16 @@ class Map implements Serializable {
int numAreas = (areas != null) ? areas.size() : 0; int numAreas = (areas != null) ? areas.size() : 0;
if (areas == null) { if (areas == null) {
areas = new Vector(numAttributes); areas = new Vector<RegionContainment>(numAttributes);
} }
for (int counter = 0; counter < numAttributes; counter++) { for (int counter = 0; counter < numAttributes; counter++) {
if (counter >= numAreas) { if (counter >= numAreas) {
areas.addElement(createRegionContainment areas.addElement(createRegionContainment
((AttributeSet)areaAttributes.elementAt(counter))); (areaAttributes.elementAt(counter)));
} }
RegionContainment rc = (RegionContainment)areas. RegionContainment rc = areas.elementAt(counter);
elementAt(counter);
if (rc != null && rc.contains(x, y, width, height)) { if (rc != null && rc.contains(x, y, width, height)) {
return (AttributeSet)areaAttributes.elementAt(counter); return areaAttributes.elementAt(counter);
} }
} }
} }
......
...@@ -97,7 +97,7 @@ public class MinimalHTMLWriter extends AbstractWriter { ...@@ -97,7 +97,7 @@ public class MinimalHTMLWriter extends AbstractWriter {
* Maps from style name as held by the Document, to the archived * Maps from style name as held by the Document, to the archived
* style name (style name written out). These may differ. * style name (style name written out). These may differ.
*/ */
private Hashtable styleNameMapping; private Hashtable<String, String> styleNameMapping;
/** /**
* Creates a new MinimalHTMLWriter. * Creates a new MinimalHTMLWriter.
...@@ -134,7 +134,7 @@ public class MinimalHTMLWriter extends AbstractWriter { ...@@ -134,7 +134,7 @@ public class MinimalHTMLWriter extends AbstractWriter {
* *
*/ */
public void write() throws IOException, BadLocationException { public void write() throws IOException, BadLocationException {
styleNameMapping = new Hashtable(); styleNameMapping = new Hashtable<String, String>();
writeStartTag("<html>"); writeStartTag("<html>");
writeHeader(); writeHeader();
writeBody(); writeBody();
...@@ -296,7 +296,7 @@ public class MinimalHTMLWriter extends AbstractWriter { ...@@ -296,7 +296,7 @@ public class MinimalHTMLWriter extends AbstractWriter {
*/ */
it.current(); it.current();
Element next = null; Element next;
writeStartTag("<body>"); writeStartTag("<body>");
...@@ -715,7 +715,7 @@ public class MinimalHTMLWriter extends AbstractWriter { ...@@ -715,7 +715,7 @@ public class MinimalHTMLWriter extends AbstractWriter {
if (styleNameMapping == null) { if (styleNameMapping == null) {
return style; return style;
} }
String retValue = (String)styleNameMapping.get(style); String retValue = styleNameMapping.get(style);
return (retValue == null) ? style : retValue; return (retValue == null) ? style : retValue;
} }
......
...@@ -108,8 +108,7 @@ class OptionListModel extends DefaultListModel implements ListSelectionModel, Se ...@@ -108,8 +108,7 @@ class OptionListModel extends DefaultListModel implements ListSelectionModel, Se
* @since 1.4 * @since 1.4
*/ */
public ListSelectionListener[] getListSelectionListeners() { public ListSelectionListener[] getListSelectionListeners() {
return (ListSelectionListener[])listenerList.getListeners( return listenerList.getListeners(ListSelectionListener.class);
ListSelectionListener.class);
} }
/** /**
...@@ -131,7 +130,7 @@ class OptionListModel extends DefaultListModel implements ListSelectionModel, Se ...@@ -131,7 +130,7 @@ class OptionListModel extends DefaultListModel implements ListSelectionModel, Se
/** /**
* @param firstIndex The first index in the interval. * @param firstIndex The first index in the interval.
* @param index1 The last index in the interval. * @param lastIndex The last index in the interval.
* @param isAdjusting True if this is the final change in a series of them. * @param isAdjusting True if this is the final change in a series of them.
* @see EventListenerList * @see EventListenerList
*/ */
...@@ -528,8 +527,8 @@ class OptionListModel extends DefaultListModel implements ListSelectionModel, Se ...@@ -528,8 +527,8 @@ class OptionListModel extends DefaultListModel implements ListSelectionModel, Se
anchorIndex = leadIndex; anchorIndex = leadIndex;
} }
int oldMin = Math.min(this.anchorIndex, this.leadIndex);; int oldMin = Math.min(this.anchorIndex, this.leadIndex);
int oldMax = Math.max(this.anchorIndex, this.leadIndex);; int oldMax = Math.max(this.anchorIndex, this.leadIndex);
int newMin = Math.min(anchorIndex, leadIndex); int newMin = Math.min(anchorIndex, leadIndex);
int newMax = Math.max(anchorIndex, leadIndex); int newMax = Math.max(anchorIndex, leadIndex);
if (value.get(this.anchorIndex)) { if (value.get(this.anchorIndex)) {
......
...@@ -164,7 +164,7 @@ public class StyleSheet extends StyleContext { ...@@ -164,7 +164,7 @@ public class StyleSheet extends StyleContext {
public StyleSheet() { public StyleSheet() {
super(); super();
selectorMapping = new SelectorMapping(0); selectorMapping = new SelectorMapping(0);
resolvedStyles = new Hashtable(); resolvedStyles = new Hashtable<String, ResolvedStyle>();
if (css == null) { if (css == null) {
css = new CSS(); css = new CSS();
} }
...@@ -190,7 +190,7 @@ public class StyleSheet extends StyleContext { ...@@ -190,7 +190,7 @@ public class StyleSheet extends StyleContext {
try { try {
// Build an array of all the parent elements. // Build an array of all the parent elements.
Vector searchContext = sb.getVector(); Vector<Element> searchContext = sb.getVector();
for (Element p = e; p != null; p = p.getParentElement()) { for (Element p = e; p != null; p = p.getParentElement()) {
searchContext.addElement(p); searchContext.addElement(p);
...@@ -205,7 +205,7 @@ public class StyleSheet extends StyleContext { ...@@ -205,7 +205,7 @@ public class StyleSheet extends StyleContext {
// >= 1 as the HTML.Tag for the 0th element is passed in. // >= 1 as the HTML.Tag for the 0th element is passed in.
for (int counter = n - 1; counter >= 1; counter--) { for (int counter = n - 1; counter >= 1; counter--) {
e = (Element)searchContext.elementAt(counter); e = searchContext.elementAt(counter);
attr = e.getAttributes(); attr = e.getAttributes();
name = attr.getAttribute(StyleConstants.NameAttribute); name = attr.getAttribute(StyleConstants.NameAttribute);
eName = name.toString(); eName = name.toString();
...@@ -225,7 +225,7 @@ public class StyleSheet extends StyleContext { ...@@ -225,7 +225,7 @@ public class StyleSheet extends StyleContext {
cacheLookup.append(' '); cacheLookup.append(' ');
} }
cacheLookup.append(t.toString()); cacheLookup.append(t.toString());
e = (Element)searchContext.elementAt(0); e = searchContext.elementAt(0);
attr = e.getAttributes(); attr = e.getAttributes();
if (e.isLeaf()) { if (e.isLeaf()) {
// For leafs, we use the second tier attributes. // For leafs, we use the second tier attributes.
...@@ -368,10 +368,9 @@ public class StyleSheet extends StyleContext { ...@@ -368,10 +368,9 @@ public class StyleSheet extends StyleContext {
if (rule != null) { if (rule != null) {
mapping.setStyle(null); mapping.setStyle(null);
if (resolvedStyles.size() > 0) { if (resolvedStyles.size() > 0) {
Enumeration values = resolvedStyles.elements(); Enumeration<ResolvedStyle> values = resolvedStyles.elements();
while (values.hasMoreElements()) { while (values.hasMoreElements()) {
ResolvedStyle style = (ResolvedStyle)values. ResolvedStyle style = values.nextElement();
nextElement();
style.removeStyle(rule); style.removeStyle(rule);
} }
} }
...@@ -392,7 +391,7 @@ public class StyleSheet extends StyleContext { ...@@ -392,7 +391,7 @@ public class StyleSheet extends StyleContext {
public void addStyleSheet(StyleSheet ss) { public void addStyleSheet(StyleSheet ss) {
synchronized(this) { synchronized(this) {
if (linkedStyleSheets == null) { if (linkedStyleSheets == null) {
linkedStyleSheets = new Vector(); linkedStyleSheets = new Vector<StyleSheet>();
} }
if (!linkedStyleSheets.contains(ss)) { if (!linkedStyleSheets.contains(ss)) {
int index = 0; int index = 0;
...@@ -828,7 +827,7 @@ public class StyleSheet extends StyleContext { ...@@ -828,7 +827,7 @@ public class StyleSheet extends StyleContext {
/** /**
* Creates a new attribute set based on a supplied set of attributes. * Creates a new attribute set based on a supplied set of attributes.
* *
* @param source the set of attributes * @param attrs the set of attributes
*/ */
public SmallConversionSet(AttributeSet attrs) { public SmallConversionSet(AttributeSet attrs) {
super(attrs); super(attrs);
...@@ -1045,9 +1044,9 @@ public class StyleSheet extends StyleContext { ...@@ -1045,9 +1044,9 @@ public class StyleSheet extends StyleContext {
*/ */
private synchronized void linkStyleSheetAt(StyleSheet ss, int index) { private synchronized void linkStyleSheetAt(StyleSheet ss, int index) {
if (resolvedStyles.size() > 0) { if (resolvedStyles.size() > 0) {
Enumeration values = resolvedStyles.elements(); Enumeration<ResolvedStyle> values = resolvedStyles.elements();
while (values.hasMoreElements()) { while (values.hasMoreElements()) {
ResolvedStyle rule = (ResolvedStyle)values.nextElement(); ResolvedStyle rule = values.nextElement();
rule.insertExtendedStyleAt(ss.getRule(rule.getName()), rule.insertExtendedStyleAt(ss.getRule(rule.getName()),
index); index);
} }
...@@ -1061,9 +1060,9 @@ public class StyleSheet extends StyleContext { ...@@ -1061,9 +1060,9 @@ public class StyleSheet extends StyleContext {
*/ */
private synchronized void unlinkStyleSheet(StyleSheet ss, int index) { private synchronized void unlinkStyleSheet(StyleSheet ss, int index) {
if (resolvedStyles.size() > 0) { if (resolvedStyles.size() > 0) {
Enumeration values = resolvedStyles.elements(); Enumeration<ResolvedStyle> values = resolvedStyles.elements();
while (values.hasMoreElements()) { while (values.hasMoreElements()) {
ResolvedStyle rule = (ResolvedStyle)values.nextElement(); ResolvedStyle rule = values.nextElement();
rule.removeExtendedStyleAt(index); rule.removeExtendedStyleAt(index);
} }
} }
...@@ -1076,7 +1075,7 @@ public class StyleSheet extends StyleContext { ...@@ -1076,7 +1075,7 @@ public class StyleSheet extends StyleContext {
String[] getSimpleSelectors(String selector) { String[] getSimpleSelectors(String selector) {
selector = cleanSelectorString(selector); selector = cleanSelectorString(selector);
SearchBuffer sb = SearchBuffer.obtainSearchBuffer(); SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
Vector selectors = sb.getVector(); Vector<String> selectors = sb.getVector();
int lastIndex = 0; int lastIndex = 0;
int length = selector.length(); int length = selector.length();
while (lastIndex != -1) { while (lastIndex != -1) {
...@@ -1256,7 +1255,7 @@ public class StyleSheet extends StyleContext { ...@@ -1256,7 +1255,7 @@ public class StyleSheet extends StyleContext {
private synchronized Style getResolvedStyle(String selector, private synchronized Style getResolvedStyle(String selector,
Vector elements, Vector elements,
HTML.Tag t) { HTML.Tag t) {
Style retStyle = (Style)resolvedStyles.get(selector); Style retStyle = resolvedStyles.get(selector);
if (retStyle == null) { if (retStyle == null) {
retStyle = createResolvedStyle(selector, elements, t); retStyle = createResolvedStyle(selector, elements, t);
} }
...@@ -1268,7 +1267,7 @@ public class StyleSheet extends StyleContext { ...@@ -1268,7 +1267,7 @@ public class StyleSheet extends StyleContext {
* create the resolved style, if necessary. * create the resolved style, if necessary.
*/ */
private synchronized Style getResolvedStyle(String selector) { private synchronized Style getResolvedStyle(String selector) {
Style retStyle = (Style)resolvedStyles.get(selector); Style retStyle = resolvedStyles.get(selector);
if (retStyle == null) { if (retStyle == null) {
retStyle = createResolvedStyle(selector); retStyle = createResolvedStyle(selector);
} }
...@@ -1280,15 +1279,14 @@ public class StyleSheet extends StyleContext { ...@@ -1280,15 +1279,14 @@ public class StyleSheet extends StyleContext {
* such that <code>elements</code> will remain ordered by * such that <code>elements</code> will remain ordered by
* specificity. * specificity.
*/ */
private void addSortedStyle(SelectorMapping mapping, Vector elements) { private void addSortedStyle(SelectorMapping mapping, Vector<SelectorMapping> elements) {
int size = elements.size(); int size = elements.size();
if (size > 0) { if (size > 0) {
int specificity = mapping.getSpecificity(); int specificity = mapping.getSpecificity();
for (int counter = 0; counter < size; counter++) { for (int counter = 0; counter < size; counter++) {
if (specificity >= ((SelectorMapping)elements.elementAt if (specificity >= elements.elementAt(counter).getSpecificity()) {
(counter)).getSpecificity()) {
elements.insertElementAt(mapping, counter); elements.insertElementAt(mapping, counter);
return; return;
} }
...@@ -1303,10 +1301,10 @@ public class StyleSheet extends StyleContext { ...@@ -1303,10 +1301,10 @@ public class StyleSheet extends StyleContext {
* any child mappings for any of the Elements in <code>elements</code>. * any child mappings for any of the Elements in <code>elements</code>.
*/ */
private synchronized void getStyles(SelectorMapping parentMapping, private synchronized void getStyles(SelectorMapping parentMapping,
Vector styles, Vector<SelectorMapping> styles,
String[] tags, String[] ids, String[] classes, String[] tags, String[] ids, String[] classes,
int index, int numElements, int index, int numElements,
Hashtable alreadyChecked) { Hashtable<SelectorMapping, SelectorMapping> alreadyChecked) {
// Avoid desending the same mapping twice. // Avoid desending the same mapping twice.
if (alreadyChecked.contains(parentMapping)) { if (alreadyChecked.contains(parentMapping)) {
return; return;
...@@ -1367,8 +1365,8 @@ public class StyleSheet extends StyleContext { ...@@ -1367,8 +1365,8 @@ public class StyleSheet extends StyleContext {
String[] tags, String[] tags,
String[] ids, String[] classes) { String[] ids, String[] classes) {
SearchBuffer sb = SearchBuffer.obtainSearchBuffer(); SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
Vector tempVector = sb.getVector(); Vector<SelectorMapping> tempVector = sb.getVector();
Hashtable tempHashtable = sb.getHashtable(); Hashtable<SelectorMapping, SelectorMapping> tempHashtable = sb.getHashtable();
// Determine all the Styles that are appropriate, placing them // Determine all the Styles that are appropriate, placing them
// in tempVector // in tempVector
try { try {
...@@ -1418,13 +1416,11 @@ public class StyleSheet extends StyleContext { ...@@ -1418,13 +1416,11 @@ public class StyleSheet extends StyleContext {
int numStyles = tempVector.size(); int numStyles = tempVector.size();
AttributeSet[] attrs = new AttributeSet[numStyles + numLinkedSS]; AttributeSet[] attrs = new AttributeSet[numStyles + numLinkedSS];
for (int counter = 0; counter < numStyles; counter++) { for (int counter = 0; counter < numStyles; counter++) {
attrs[counter] = ((SelectorMapping)tempVector. attrs[counter] = tempVector.elementAt(counter).getStyle();
elementAt(counter)).getStyle();
} }
// Get the AttributeSet from linked style sheets. // Get the AttributeSet from linked style sheets.
for (int counter = 0; counter < numLinkedSS; counter++) { for (int counter = 0; counter < numLinkedSS; counter++) {
AttributeSet attr = ((StyleSheet)linkedStyleSheets. AttributeSet attr = linkedStyleSheets.elementAt(counter).getRule(selector);
elementAt(counter)).getRule(selector);
if (attr == null) { if (attr == null) {
attrs[counter + numStyles] = SimpleAttributeSet.EMPTY; attrs[counter + numStyles] = SimpleAttributeSet.EMPTY;
} }
...@@ -1514,11 +1510,11 @@ public class StyleSheet extends StyleContext { ...@@ -1514,11 +1510,11 @@ public class StyleSheet extends StyleContext {
private Style createResolvedStyle(String selector) { private Style createResolvedStyle(String selector) {
SearchBuffer sb = SearchBuffer.obtainSearchBuffer(); SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
// Will contain the tags, ids, and classes, in that order. // Will contain the tags, ids, and classes, in that order.
Vector elements = sb.getVector(); Vector<String> elements = sb.getVector();
try { try {
boolean done; boolean done;
int dotIndex = 0; int dotIndex = 0;
int spaceIndex = 0; int spaceIndex;
int poundIndex = 0; int poundIndex = 0;
int lastIndex = 0; int lastIndex = 0;
int length = selector.length(); int length = selector.length();
...@@ -1640,9 +1636,9 @@ public class StyleSheet extends StyleContext { ...@@ -1640,9 +1636,9 @@ public class StyleSheet extends StyleContext {
String[] classes = new String[numTags]; String[] classes = new String[numTags];
for (int index = 0, eIndex = total - 3; index < numTags; for (int index = 0, eIndex = total - 3; index < numTags;
index++, eIndex -= 3) { index++, eIndex -= 3) {
tags[index] = (String)elements.elementAt(eIndex); tags[index] = elements.elementAt(eIndex);
classes[index] = (String)elements.elementAt(eIndex + 1); classes[index] = elements.elementAt(eIndex + 1);
ids[index] = (String)elements.elementAt(eIndex + 2); ids[index] = elements.elementAt(eIndex + 2);
} }
return createResolvedStyle(selector, tags, ids, classes); return createResolvedStyle(selector, tags, ids, classes);
} }
...@@ -1661,9 +1657,9 @@ public class StyleSheet extends StyleContext { ...@@ -1661,9 +1657,9 @@ public class StyleSheet extends StyleContext {
Style newStyle, Style newStyle,
int specificity) { int specificity) {
if (resolvedStyles.size() > 0) { if (resolvedStyles.size() > 0) {
Enumeration values = resolvedStyles.elements(); Enumeration<ResolvedStyle> values = resolvedStyles.elements();
while (values.hasMoreElements()) { while (values.hasMoreElements()) {
ResolvedStyle style = (ResolvedStyle)values.nextElement(); ResolvedStyle style = values.nextElement();
if (style.matches(selectorName)) { if (style.matches(selectorName)) {
style.insertStyle(newStyle, specificity); style.insertStyle(newStyle, specificity);
} }
...@@ -1682,7 +1678,7 @@ public class StyleSheet extends StyleContext { ...@@ -1682,7 +1678,7 @@ public class StyleSheet extends StyleContext {
private static class SearchBuffer { private static class SearchBuffer {
/** A stack containing instances of SearchBuffer. Used in getting /** A stack containing instances of SearchBuffer. Used in getting
* rules. */ * rules. */
static Stack searchBuffers = new Stack(); static Stack<SearchBuffer> searchBuffers = new Stack<SearchBuffer>();
// A set of temporary variables that can be used in whatever way. // A set of temporary variables that can be used in whatever way.
Vector vector = null; Vector vector = null;
StringBuffer stringBuffer = null; StringBuffer stringBuffer = null;
...@@ -1696,7 +1692,7 @@ public class StyleSheet extends StyleContext { ...@@ -1696,7 +1692,7 @@ public class StyleSheet extends StyleContext {
SearchBuffer sb; SearchBuffer sb;
try { try {
if(!searchBuffers.empty()) { if(!searchBuffers.empty()) {
sb = (SearchBuffer)searchBuffers.pop(); sb = searchBuffers.pop();
} else { } else {
sb = new SearchBuffer(); sb = new SearchBuffer();
} }
...@@ -1922,7 +1918,7 @@ public class StyleSheet extends StyleContext { ...@@ -1922,7 +1918,7 @@ public class StyleSheet extends StyleContext {
static boolean isLeftToRight(View v) { static boolean isLeftToRight(View v) {
boolean ret = true; boolean ret = true;
if (isOrientationAware(v)) { if (isOrientationAware(v)) {
Container container = null; Container container;
if (v != null && (container = v.getContainer()) != null) { if (v != null && (container = v.getContainer()) != null) {
ret = container.getComponentOrientation().isLeftToRight(); ret = container.getComponentOrientation().isLeftToRight();
} }
...@@ -1938,8 +1934,8 @@ public class StyleSheet extends StyleContext { ...@@ -1938,8 +1934,8 @@ public class StyleSheet extends StyleContext {
*/ */
static boolean isOrientationAware(View v) { static boolean isOrientationAware(View v) {
boolean ret = false; boolean ret = false;
AttributeSet attr = null; AttributeSet attr;
Object obj = null; Object obj;
if (v != null if (v != null
&& (attr = v.getElement().getAttributes()) != null && (attr = v.getElement().getAttributes()) != null
&& (obj = attr.getAttribute(StyleConstants.NameAttribute)) instanceof HTML.Tag && (obj = attr.getAttribute(StyleConstants.NameAttribute)) instanceof HTML.Tag
...@@ -1953,7 +1949,7 @@ public class StyleSheet extends StyleContext { ...@@ -1953,7 +1949,7 @@ public class StyleSheet extends StyleContext {
return ret; return ret;
} }
static enum HorizontalMargin { LEFT, RIGHT }; static enum HorizontalMargin { LEFT, RIGHT }
/** /**
* for <dir>, <menu>, <ul> etc. * for <dir>, <menu>, <ul> etc.
...@@ -2362,7 +2358,7 @@ public class StyleSheet extends StyleContext { ...@@ -2362,7 +2358,7 @@ public class StyleSheet extends StyleContext {
* @param itemNum number to format * @param itemNum number to format
*/ */
String formatAlphaNumerals(int itemNum) { String formatAlphaNumerals(int itemNum) {
String result = ""; String result;
if (itemNum > 26) { if (itemNum > 26) {
result = formatAlphaNumerals(itemNum / 26) + result = formatAlphaNumerals(itemNum / 26) +
...@@ -2411,7 +2407,7 @@ public class StyleSheet extends StyleContext { ...@@ -2411,7 +2407,7 @@ public class StyleSheet extends StyleContext {
* Converts the item number into a roman numeral * Converts the item number into a roman numeral
* *
* @param level position * @param level position
* @param num digit to format * @param digit digit to format
*/ */
String formatRomanDigit(int level, int digit) { String formatRomanDigit(int level, int digit) {
String result = ""; String result = "";
...@@ -2625,7 +2621,7 @@ public class StyleSheet extends StyleContext { ...@@ -2625,7 +2621,7 @@ public class StyleSheet extends StyleContext {
// implementation. // implementation.
Document doc = v.getDocument(); Document doc = v.getDocument();
SearchBuffer sb = SearchBuffer.obtainSearchBuffer(); SearchBuffer sb = SearchBuffer.obtainSearchBuffer();
Vector muxList = sb.getVector(); Vector<AttributeSet> muxList = sb.getVector();
try { try {
if (doc instanceof HTMLDocument) { if (doc instanceof HTMLDocument) {
StyleSheet styles = StyleSheet.this; StyleSheet styles = StyleSheet.this;
...@@ -2641,8 +2637,8 @@ public class StyleSheet extends StyleContext { ...@@ -2641,8 +2637,8 @@ public class StyleSheet extends StyleContext {
while (keys.hasMoreElements()) { while (keys.hasMoreElements()) {
Object key = keys.nextElement(); Object key = keys.nextElement();
if (key instanceof HTML.Tag) { if (key instanceof HTML.Tag) {
if ((HTML.Tag)key == HTML.Tag.A) { if (key == HTML.Tag.A) {
Object o = a.getAttribute((HTML.Tag)key); Object o = a.getAttribute(key);
/** /**
In the case of an A tag, the css rules In the case of an A tag, the css rules
apply only for tags that have their apply only for tags that have their
...@@ -3059,10 +3055,10 @@ public class StyleSheet extends StyleContext { ...@@ -3059,10 +3055,10 @@ public class StyleSheet extends StyleContext {
SelectorMapping retValue = null; SelectorMapping retValue = null;
if (children != null) { if (children != null) {
retValue = (SelectorMapping)children.get(selector); retValue = children.get(selector);
} }
else if (create) { else if (create) {
children = new HashMap(7); children = new HashMap<String, SelectorMapping>(7);
} }
if (retValue == null && create) { if (retValue == null && create) {
int specificity = getChildSpecificity(selector); int specificity = getChildSpecificity(selector);
...@@ -3121,7 +3117,7 @@ public class StyleSheet extends StyleContext { ...@@ -3121,7 +3117,7 @@ public class StyleSheet extends StyleContext {
* Any sub selectors. Key will be String, and value will be * Any sub selectors. Key will be String, and value will be
* another SelectorMapping. * another SelectorMapping.
*/ */
private HashMap children; private HashMap<String, SelectorMapping> children;
} }
...@@ -3138,11 +3134,11 @@ public class StyleSheet extends StyleContext { ...@@ -3138,11 +3134,11 @@ public class StyleSheet extends StyleContext {
/** Maps from selector (as a string) to Style that includes all /** Maps from selector (as a string) to Style that includes all
* relevant styles. */ * relevant styles. */
private Hashtable resolvedStyles; private Hashtable<String, ResolvedStyle> resolvedStyles;
/** Vector of StyleSheets that the rules are to reference. /** Vector of StyleSheets that the rules are to reference.
*/ */
private Vector linkedStyleSheets; private Vector<StyleSheet> linkedStyleSheets;
/** Where the style sheet was found. Used for relative imports. */ /** Where the style sheet was found. Used for relative imports. */
private URL base; private URL base;
...@@ -3279,7 +3275,7 @@ public class StyleSheet extends StyleContext { ...@@ -3279,7 +3275,7 @@ public class StyleSheet extends StyleContext {
public void endRule() { public void endRule() {
int n = selectors.size(); int n = selectors.size();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
String[] selector = (String[]) selectors.elementAt(i); String[] selector = selectors.elementAt(i);
if (selector.length > 0) { if (selector.length > 0) {
StyleSheet.this.addRule(selector, declaration, isLink); StyleSheet.this.addRule(selector, declaration, isLink);
} }
...@@ -3296,8 +3292,8 @@ public class StyleSheet extends StyleContext { ...@@ -3296,8 +3292,8 @@ public class StyleSheet extends StyleContext {
} }
Vector selectors = new Vector(); Vector<String[]> selectors = new Vector<String[]>();
Vector selectorTokens = new Vector(); Vector<String> selectorTokens = new Vector<String>();
/** Name of the current property. */ /** Name of the current property. */
String propertyName; String propertyName;
MutableAttributeSet declaration = new SimpleAttributeSet(); MutableAttributeSet declaration = new SimpleAttributeSet();
......
...@@ -48,7 +48,7 @@ import javax.swing.text.*; ...@@ -48,7 +48,7 @@ import javax.swing.text.*;
*/ */
public TableView(Element elem) { public TableView(Element elem) {
super(elem, View.Y_AXIS); super(elem, View.Y_AXIS);
rows = new Vector(); rows = new Vector<RowView>();
gridValid = false; gridValid = false;
captionIndex = -1; captionIndex = -1;
totalColumnRequirements = new SizeRequirements(); totalColumnRequirements = new SizeRequirements();
...@@ -127,14 +127,14 @@ import javax.swing.text.*; ...@@ -127,14 +127,14 @@ import javax.swing.text.*;
RowView getRow(int row) { RowView getRow(int row) {
if (row < rows.size()) { if (row < rows.size()) {
return (RowView) rows.elementAt(row); return rows.elementAt(row);
} }
return null; return null;
} }
protected View getViewAtPoint(int x, int y, Rectangle alloc) { protected View getViewAtPoint(int x, int y, Rectangle alloc) {
int n = getViewCount(); int n = getViewCount();
View v = null; View v;
Rectangle allocation = new Rectangle(); Rectangle allocation = new Rectangle();
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
allocation.setBounds(alloc); allocation.setBounds(alloc);
...@@ -273,7 +273,7 @@ import javax.swing.text.*; ...@@ -273,7 +273,7 @@ import javax.swing.text.*;
for (int i = 0; i < n; i++) { for (int i = 0; i < n; i++) {
View v = getView(i); View v = getView(i);
if (v instanceof RowView) { if (v instanceof RowView) {
rows.addElement(v); rows.addElement((RowView) v);
RowView rv = (RowView) v; RowView rv = (RowView) v;
rv.clearFilledColumns(); rv.clearFilledColumns();
rv.rowIndex = rows.size() - 1; rv.rowIndex = rows.size() - 1;
...@@ -990,7 +990,7 @@ import javax.swing.text.*; ...@@ -990,7 +990,7 @@ import javax.swing.text.*;
RowIterator rowIterator = new RowIterator(); RowIterator rowIterator = new RowIterator();
ColumnIterator colIterator = new ColumnIterator(); ColumnIterator colIterator = new ColumnIterator();
Vector rows; Vector<RowView> rows;
// whether to display comments inside table or not. // whether to display comments inside table or not.
boolean skipComments = false; boolean skipComments = false;
......
...@@ -129,7 +129,7 @@ class AttributeList implements DTDConstants, Serializable { ...@@ -129,7 +129,7 @@ class AttributeList implements DTDConstants, Serializable {
/** /**
* Create a hashtable of attribute types. * Create a hashtable of attribute types.
*/ */
static Hashtable attributeTypes = new Hashtable(); static Hashtable<Object, Object> attributeTypes = new Hashtable<Object, Object>();
static void defineAttributeType(String nm, int val) { static void defineAttributeType(String nm, int val) {
Integer num = Integer.valueOf(val); Integer num = Integer.valueOf(val);
......
...@@ -104,7 +104,7 @@ class DTD implements DTDConstants { ...@@ -104,7 +104,7 @@ class DTD implements DTDConstants {
* <code>name</code> <code>String</code> * <code>name</code> <code>String</code>
*/ */
public Entity getEntity(String name) { public Entity getEntity(String name) {
return (Entity)entityHash.get(name); return entityHash.get(name);
} }
/** /**
...@@ -113,7 +113,7 @@ class DTD implements DTDConstants { ...@@ -113,7 +113,7 @@ class DTD implements DTDConstants {
* <code>ch</code> character * <code>ch</code> character
*/ */
public Entity getEntity(int ch) { public Entity getEntity(int ch) {
return (Entity)entityHash.get(Integer.valueOf(ch)); return entityHash.get(Integer.valueOf(ch));
} }
/** /**
...@@ -137,7 +137,7 @@ class DTD implements DTDConstants { ...@@ -137,7 +137,7 @@ class DTD implements DTDConstants {
* <code>name</code>, which may be newly created * <code>name</code>, which may be newly created
*/ */
public Element getElement(String name) { public Element getElement(String name) {
Element e = (Element)elementHash.get(name); Element e = elementHash.get(name);
if (e == null) { if (e == null) {
e = new Element(name, elements.size()); e = new Element(name, elements.size());
elements.addElement(e); elements.addElement(e);
...@@ -154,7 +154,7 @@ class DTD implements DTDConstants { ...@@ -154,7 +154,7 @@ class DTD implements DTDConstants {
* <code>index</code> * <code>index</code>
*/ */
public Element getElement(int index) { public Element getElement(int index) {
return (Element)elements.elementAt(index); return elements.elementAt(index);
} }
/** /**
...@@ -170,7 +170,7 @@ class DTD implements DTDConstants { ...@@ -170,7 +170,7 @@ class DTD implements DTDConstants {
* if not found * if not found
*/ */
public Entity defineEntity(String name, int type, char data[]) { public Entity defineEntity(String name, int type, char data[]) {
Entity ent = (Entity)entityHash.get(name); Entity ent = entityHash.get(name);
if (ent == null) { if (ent == null) {
ent = new Entity(name, type, data); ent = new Entity(name, type, data);
entityHash.put(name, ent); entityHash.put(name, ent);
...@@ -259,8 +259,7 @@ class DTD implements DTDConstants { ...@@ -259,8 +259,7 @@ class DTD implements DTDConstants {
BitSet excl = null; BitSet excl = null;
if (exclusions != null && exclusions.length > 0) { if (exclusions != null && exclusions.length > 0) {
excl = new BitSet(); excl = new BitSet();
for (int i = 0; i < exclusions.length; i++) { for (String str : exclusions) {
String str = exclusions[i];
if (str.length() > 0) { if (str.length() > 0) {
excl.set(getElement(str).getIndex()); excl.set(getElement(str).getIndex());
} }
...@@ -269,8 +268,7 @@ class DTD implements DTDConstants { ...@@ -269,8 +268,7 @@ class DTD implements DTDConstants {
BitSet incl = null; BitSet incl = null;
if (inclusions != null && inclusions.length > 0) { if (inclusions != null && inclusions.length > 0) {
incl = new BitSet(); incl = new BitSet();
for (int i = 0; i < inclusions.length; i++) { for (String str : inclusions) {
String str = inclusions[i];
if (str.length() > 0) { if (str.length() > 0) {
incl.set(getElement(str).getIndex()); incl.set(getElement(str).getIndex());
} }
...@@ -285,9 +283,9 @@ class DTD implements DTDConstants { ...@@ -285,9 +283,9 @@ class DTD implements DTDConstants {
* @return the new <code>AttributeList</code> * @return the new <code>AttributeList</code>
*/ */
protected AttributeList defAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts) { protected AttributeList defAttributeList(String name, int type, int modifier, String value, String values, AttributeList atts) {
Vector vals = null; Vector<String> vals = null;
if (values != null) { if (values != null) {
vals = new Vector(); vals = new Vector<String>();
for (StringTokenizer s = new StringTokenizer(values, "|") ; s.hasMoreTokens() ;) { for (StringTokenizer s = new StringTokenizer(values, "|") ; s.hasMoreTokens() ;) {
String str = s.nextToken(); String str = s.nextToken();
if (str.length() > 0) { if (str.length() > 0) {
...@@ -318,7 +316,7 @@ class DTD implements DTDConstants { ...@@ -318,7 +316,7 @@ class DTD implements DTDConstants {
/** /**
* The hashtable of DTDs. * The hashtable of DTDs.
*/ */
static Hashtable dtdHash = new Hashtable(); static Hashtable<String, DTD> dtdHash = new Hashtable<String, DTD>();
public static void putDTDHash(String name, DTD dtd) { public static void putDTDHash(String name, DTD dtd) {
dtdHash.put(name, dtd); dtdHash.put(name, dtd);
...@@ -334,7 +332,7 @@ class DTD implements DTDConstants { ...@@ -334,7 +332,7 @@ class DTD implements DTDConstants {
*/ */
public static DTD getDTD(String name) throws IOException { public static DTD getDTD(String name) throws IOException {
name = name.toLowerCase(); name = name.toLowerCase();
DTD dtd = (DTD)dtdHash.get(name); DTD dtd = dtdHash.get(name);
if (dtd == null) if (dtd == null)
dtd = new DTD(name); dtd = new DTD(name);
...@@ -432,10 +430,10 @@ class DTD implements DTDConstants { ...@@ -432,10 +430,10 @@ class DTD implements DTDConstants {
int modifier = in.readByte(); int modifier = in.readByte();
short valueId = in.readShort(); short valueId = in.readShort();
String value = (valueId == -1) ? null : names[valueId]; String value = (valueId == -1) ? null : names[valueId];
Vector values = null; Vector<String> values = null;
short numValues = in.readShort(); short numValues = in.readShort();
if (numValues > 0) { if (numValues > 0) {
values = new Vector(numValues); values = new Vector<String>(numValues);
for (int i = 0; i < numValues; i++) { for (int i = 0; i < numValues; i++) {
values.addElement(names[in.readShort()]); values.addElement(names[in.readShort()]);
} }
......
...@@ -159,7 +159,7 @@ class Element implements DTDConstants, Serializable { ...@@ -159,7 +159,7 @@ class Element implements DTDConstants, Serializable {
} }
static Hashtable contentTypes = new Hashtable(); static Hashtable<String, Integer> contentTypes = new Hashtable<String, Integer>();
static { static {
contentTypes.put("CDATA", Integer.valueOf(CDATA)); contentTypes.put("CDATA", Integer.valueOf(CDATA));
...@@ -169,7 +169,7 @@ class Element implements DTDConstants, Serializable { ...@@ -169,7 +169,7 @@ class Element implements DTDConstants, Serializable {
} }
public static int name2type(String nm) { public static int name2type(String nm) {
Integer val = (Integer)contentTypes.get(nm); Integer val = contentTypes.get(nm);
return (val != null) ? val.intValue() : 0; return (val != null) ? val.intValue() : 0;
} }
} }
...@@ -107,7 +107,7 @@ class Entity implements DTDConstants { ...@@ -107,7 +107,7 @@ class Entity implements DTDConstants {
} }
static Hashtable entityTypes = new Hashtable(); static Hashtable<String, Integer> entityTypes = new Hashtable<String, Integer>();
static { static {
entityTypes.put("PUBLIC", Integer.valueOf(PUBLIC)); entityTypes.put("PUBLIC", Integer.valueOf(PUBLIC));
...@@ -133,7 +133,7 @@ class Entity implements DTDConstants { ...@@ -133,7 +133,7 @@ class Entity implements DTDConstants {
* to "CDATA", if none exists * to "CDATA", if none exists
*/ */
public static int name2type(String nm) { public static int name2type(String nm) {
Integer i = (Integer)entityTypes.get(nm); Integer i = entityTypes.get(nm);
return (i == null) ? CDATA : i.intValue(); return (i == null) ? CDATA : i.intValue();
} }
} }
...@@ -649,12 +649,10 @@ class Parser implements DTDConstants { ...@@ -649,12 +649,10 @@ class Parser implements DTDConstants {
if (!strict) { if (!strict) {
ContentModel content = stack.contentModel(); ContentModel content = stack.contentModel();
Vector elemVec = new Vector(); Vector<Element> elemVec = new Vector<Element>();
if (content != null) { if (content != null) {
content.getElements(elemVec); content.getElements(elemVec);
for (Enumeration v = elemVec.elements(); v.hasMoreElements();) { for (Element e : elemVec) {
Element e = (Element)v.nextElement();
// Ensure that this element has not been included as // Ensure that this element has not been included as
// part of the exclusions in the DTD. // part of the exclusions in the DTD.
// //
...@@ -1349,9 +1347,9 @@ class Parser implements DTDConstants { ...@@ -1349,9 +1347,9 @@ class Parser implements DTDConstants {
continue; continue;
} }
AttributeList att = null; AttributeList att;
String attname = null; String attname;
String attvalue = null; String attvalue;
if (parseIdentifier(true)) { if (parseIdentifier(true)) {
attname = getString(0); attname = getString(0);
...@@ -1549,7 +1547,7 @@ class Parser implements DTDConstants { ...@@ -1549,7 +1547,7 @@ class Parser implements DTDConstants {
* Parse a start or end tag. * Parse a start or end tag.
*/ */
void parseTag() throws IOException { void parseTag() throws IOException {
Element elem = null; Element elem;
boolean net = false; boolean net = false;
boolean warned = false; boolean warned = false;
boolean unknown = false; boolean unknown = false;
......
...@@ -124,22 +124,6 @@ class TagStack implements DTDConstants { ...@@ -124,22 +124,6 @@ class TagStack implements DTDConstants {
return (exclusions != null) && exclusions.get(elem.getIndex()); return (exclusions != null) && exclusions.get(elem.getIndex());
} }
/**
* Update the Vector elemVec with all the elements that
* are part of the inclusions listed in DTD for the element
* currently on the TagStack.
*/
boolean included(Vector elemVec, DTD dtd) {
for (int i = 0 ; i < inclusions.size(); i++) {
if (inclusions.get(i)) {
elemVec.addElement(dtd.getElement(i));
System.out.println("Element add thru' inclusions: " + dtd.getElement(i).getName());
}
}
return (!elemVec.isEmpty());
}
/** /**
* Advance the state by reducing the given element. * Advance the state by reducing the given element.
......
...@@ -35,7 +35,7 @@ import javax.swing.text.MutableAttributeSet; ...@@ -35,7 +35,7 @@ import javax.swing.text.MutableAttributeSet;
class MockAttributeSet class MockAttributeSet
implements AttributeSet, MutableAttributeSet implements AttributeSet, MutableAttributeSet
{ {
public Dictionary backing; public Dictionary<Object, Object> backing;
public boolean isEmpty() public boolean isEmpty()
{ {
......
...@@ -36,7 +36,7 @@ class RTFAttributes ...@@ -36,7 +36,7 @@ class RTFAttributes
static RTFAttribute attributes[]; static RTFAttribute attributes[];
static { static {
Vector a = new Vector(); Vector<RTFAttribute> a = new Vector<RTFAttribute>();
int CHR = RTFAttribute.D_CHARACTER; int CHR = RTFAttribute.D_CHARACTER;
int PGF = RTFAttribute.D_PARAGRAPH; int PGF = RTFAttribute.D_PARAGRAPH;
int SEC = RTFAttribute.D_SECTION; int SEC = RTFAttribute.D_SECTION;
...@@ -131,14 +131,13 @@ class RTFAttributes ...@@ -131,14 +131,13 @@ class RTFAttributes
attributes = attrs; attributes = attrs;
} }
static Dictionary attributesByKeyword() static Dictionary<String, RTFAttribute> attributesByKeyword()
{ {
Dictionary d = new Hashtable(attributes.length); Dictionary<String, RTFAttribute> d = new Hashtable<String, RTFAttribute>(attributes.length);
int i, m;
m = attributes.length; for (RTFAttribute attribute : attributes) {
for(i = 0; i < m; i++) d.put(attribute.rtfName(), attribute);
d.put(attributes[i].rtfName(), attributes[i]); }
return d; return d;
} }
......
...@@ -52,11 +52,11 @@ class RTFGenerator extends Object ...@@ -52,11 +52,11 @@ class RTFGenerator extends Object
{ {
/* These dictionaries map Colors, font names, or Style objects /* These dictionaries map Colors, font names, or Style objects
to Integers */ to Integers */
Dictionary colorTable; Dictionary<Object, Integer> colorTable;
int colorCount; int colorCount;
Dictionary fontTable; Dictionary<String, Integer> fontTable;
int fontCount; int fontCount;
Dictionary styleTable; Dictionary<AttributeSet, Integer> styleTable;
int styleCount; int styleCount;
/* where all the text is going */ /* where all the text is going */
...@@ -90,7 +90,7 @@ class RTFGenerator extends Object ...@@ -90,7 +90,7 @@ class RTFGenerator extends Object
would require allocating an object for every character would require allocating an object for every character
written (slow!). */ written (slow!). */
static class CharacterKeywordPair static class CharacterKeywordPair
{ public char character; public String keyword; }; { public char character; public String keyword; }
static protected CharacterKeywordPair[] textKeywords; static protected CharacterKeywordPair[] textKeywords;
static { static {
...@@ -98,7 +98,7 @@ class RTFGenerator extends Object ...@@ -98,7 +98,7 @@ class RTFGenerator extends Object
Dictionary textKeywordDictionary = RTFReader.textKeywords; Dictionary textKeywordDictionary = RTFReader.textKeywords;
Enumeration keys = textKeywordDictionary.keys(); Enumeration keys = textKeywordDictionary.keys();
Vector tempPairs = new Vector(); Vector<CharacterKeywordPair> tempPairs = new Vector<CharacterKeywordPair>();
while(keys.hasMoreElements()) { while(keys.hasMoreElements()) {
CharacterKeywordPair pair = new CharacterKeywordPair(); CharacterKeywordPair pair = new CharacterKeywordPair();
pair.keyword = (String)keys.nextElement(); pair.keyword = (String)keys.nextElement();
...@@ -133,14 +133,14 @@ static public void writeDocument(Document d, OutputStream to) ...@@ -133,14 +133,14 @@ static public void writeDocument(Document d, OutputStream to)
public RTFGenerator(OutputStream to) public RTFGenerator(OutputStream to)
{ {
colorTable = new Hashtable(); colorTable = new Hashtable<Object, Integer>();
colorTable.put(defaultRTFColor, Integer.valueOf(0)); colorTable.put(defaultRTFColor, Integer.valueOf(0));
colorCount = 1; colorCount = 1;
fontTable = new Hashtable(); fontTable = new Hashtable<String, Integer>();
fontCount = 0; fontCount = 0;
styleTable = new Hashtable(); styleTable = new Hashtable<AttributeSet, Integer>();
/* TODO: put default style in style table */ /* TODO: put default style in style table */
styleCount = 0; styleCount = 0;
...@@ -197,7 +197,7 @@ public void examineElement(Element el) ...@@ -197,7 +197,7 @@ public void examineElement(Element el)
private void tallyStyles(AttributeSet a) { private void tallyStyles(AttributeSet a) {
while (a != null) { while (a != null) {
if (a instanceof Style) { if (a instanceof Style) {
Integer aNum = (Integer)styleTable.get(a); Integer aNum = styleTable.get(a);
if (aNum == null) { if (aNum == null) {
styleCount = styleCount + 1; styleCount = styleCount + 1;
aNum = new Integer(styleCount); aNum = new Integer(styleCount);
...@@ -225,7 +225,7 @@ private Integer findStyleNumber(AttributeSet a, String domain) ...@@ -225,7 +225,7 @@ private Integer findStyleNumber(AttributeSet a, String domain)
{ {
while(a != null) { while(a != null) {
if (a instanceof Style) { if (a instanceof Style) {
Integer aNum = (Integer)styleTable.get(a); Integer aNum = styleTable.get(a);
if (aNum != null) { if (aNum != null) {
if (domain == null || if (domain == null ||
domain.equals(a.getAttribute(Constants.StyleType))) domain.equals(a.getAttribute(Constants.StyleType)))
...@@ -319,11 +319,11 @@ public void writeRTFHeader() ...@@ -319,11 +319,11 @@ public void writeRTFHeader()
/* write font table */ /* write font table */
String[] sortedFontTable = new String[fontCount]; String[] sortedFontTable = new String[fontCount];
Enumeration fonts = fontTable.keys(); Enumeration<String> fonts = fontTable.keys();
String font; String font;
while(fonts.hasMoreElements()) { while(fonts.hasMoreElements()) {
font = (String)fonts.nextElement(); font = fonts.nextElement();
Integer num = (Integer)(fontTable.get(font)); Integer num = fontTable.get(font);
sortedFontTable[num.intValue()] = font; sortedFontTable[num.intValue()] = font;
} }
writeBegingroup(); writeBegingroup();
...@@ -344,7 +344,7 @@ public void writeRTFHeader() ...@@ -344,7 +344,7 @@ public void writeRTFHeader()
Color color; Color color;
while(colors.hasMoreElements()) { while(colors.hasMoreElements()) {
color = (Color)colors.nextElement(); color = (Color)colors.nextElement();
Integer num = (Integer)(colorTable.get(color)); Integer num = colorTable.get(color);
sortedColorTable[num.intValue()] = color; sortedColorTable[num.intValue()] = color;
} }
writeBegingroup(); writeBegingroup();
...@@ -366,10 +366,10 @@ public void writeRTFHeader() ...@@ -366,10 +366,10 @@ public void writeRTFHeader()
if (styleCount > 1) { if (styleCount > 1) {
writeBegingroup(); writeBegingroup();
writeControlWord("stylesheet"); writeControlWord("stylesheet");
Enumeration styles = styleTable.keys(); Enumeration<AttributeSet> styles = styleTable.keys();
while(styles.hasMoreElements()) { while(styles.hasMoreElements()) {
Style style = (Style)styles.nextElement(); Style style = (Style)styles.nextElement();
int styleNumber = ((Integer)styleTable.get(style)).intValue(); int styleNumber = styleTable.get(style).intValue();
writeBegingroup(); writeBegingroup();
String styleType = (String)style.getAttribute(Constants.StyleType); String styleType = (String)style.getAttribute(Constants.StyleType);
if (styleType == null) if (styleType == null)
...@@ -398,7 +398,7 @@ public void writeRTFHeader() ...@@ -398,7 +398,7 @@ public void writeRTFHeader()
basis = style.getResolveParent(); basis = style.getResolveParent();
if (basis != null && basis instanceof Style) { if (basis != null && basis instanceof Style) {
Integer basedOn = (Integer)styleTable.get(basis); Integer basedOn = styleTable.get(basis);
if (basedOn != null) { if (basedOn != null) {
writeControlWord("sbasedon", basedOn.intValue()); writeControlWord("sbasedon", basedOn.intValue());
} }
...@@ -406,7 +406,7 @@ public void writeRTFHeader() ...@@ -406,7 +406,7 @@ public void writeRTFHeader()
Style nextStyle = (Style)style.getAttribute(Constants.StyleNext); Style nextStyle = (Style)style.getAttribute(Constants.StyleNext);
if (nextStyle != null) { if (nextStyle != null) {
Integer nextNum = (Integer)styleTable.get(nextStyle); Integer nextNum = styleTable.get(nextStyle);
if (nextNum != null) { if (nextNum != null) {
writeControlWord("snext", nextNum.intValue()); writeControlWord("snext", nextNum.intValue());
} }
...@@ -725,7 +725,7 @@ void updateCharacterAttributes(MutableAttributeSet current, ...@@ -725,7 +725,7 @@ void updateCharacterAttributes(MutableAttributeSet current,
if ((parm = attrDiff(current, newAttributes, if ((parm = attrDiff(current, newAttributes,
StyleConstants.FontFamily, null)) != null) { StyleConstants.FontFamily, null)) != null) {
Number fontNum = (Number)fontTable.get(parm); Integer fontNum = fontTable.get(parm);
writeControlWord("f", fontNum.intValue()); writeControlWord("f", fontNum.intValue());
} }
...@@ -746,7 +746,7 @@ void updateCharacterAttributes(MutableAttributeSet current, ...@@ -746,7 +746,7 @@ void updateCharacterAttributes(MutableAttributeSet current,
if (parm == MagicToken) if (parm == MagicToken)
colorNum = 0; colorNum = 0;
else else
colorNum = ((Number)colorTable.get(parm)).intValue(); colorNum = colorTable.get(parm).intValue();
writeControlWord("cb", colorNum); writeControlWord("cb", colorNum);
} }
...@@ -756,7 +756,7 @@ void updateCharacterAttributes(MutableAttributeSet current, ...@@ -756,7 +756,7 @@ void updateCharacterAttributes(MutableAttributeSet current,
if (parm == MagicToken) if (parm == MagicToken)
colorNum = 0; colorNum = 0;
else else
colorNum = ((Number)colorTable.get(parm)).intValue(); colorNum = colorTable.get(parm).intValue();
writeControlWord("cf", colorNum); writeControlWord("cf", colorNum);
} }
} }
......
...@@ -92,7 +92,7 @@ abstract class RTFParser extends AbstractFilter ...@@ -92,7 +92,7 @@ abstract class RTFParser extends AbstractFilter
// table of non-text characters in rtf // table of non-text characters in rtf
static final boolean rtfSpecialsTable[]; static final boolean rtfSpecialsTable[];
static { static {
rtfSpecialsTable = (boolean[])noSpecialsTable.clone(); rtfSpecialsTable = noSpecialsTable.clone();
rtfSpecialsTable['\n'] = true; rtfSpecialsTable['\n'] = true;
rtfSpecialsTable['\r'] = true; rtfSpecialsTable['\r'] = true;
rtfSpecialsTable['{'] = true; rtfSpecialsTable['{'] = true;
......
...@@ -54,7 +54,7 @@ class RTFReader extends RTFParser ...@@ -54,7 +54,7 @@ class RTFReader extends RTFParser
/** Miscellaneous information about the parser's state. This /** Miscellaneous information about the parser's state. This
* dictionary is saved and restored when an RTF group begins * dictionary is saved and restored when an RTF group begins
* or ends. */ * or ends. */
Dictionary parserState; /* Current parser state */ Dictionary<Object, Object> parserState; /* Current parser state */
/** This is the "dst" item from parserState. rtfDestination /** This is the "dst" item from parserState. rtfDestination
* is the current rtf destination. It is cached in an instance * is the current rtf destination. It is cached in an instance
* variable for speed. */ * variable for speed. */
...@@ -63,7 +63,7 @@ class RTFReader extends RTFParser ...@@ -63,7 +63,7 @@ class RTFReader extends RTFParser
MutableAttributeSet documentAttributes; MutableAttributeSet documentAttributes;
/** This Dictionary maps Integer font numbers to String font names. */ /** This Dictionary maps Integer font numbers to String font names. */
Dictionary fontTable; Dictionary<Integer, String> fontTable;
/** This array maps color indices to Color objects. */ /** This array maps color indices to Color objects. */
Color[] colorTable; Color[] colorTable;
/** This array maps character style numbers to Style objects. */ /** This array maps character style numbers to Style objects. */
...@@ -86,7 +86,7 @@ class RTFReader extends RTFParser ...@@ -86,7 +86,7 @@ class RTFReader extends RTFParser
* Unicode character. */ * Unicode character. */
int skippingCharacters; int skippingCharacters;
static private Dictionary straightforwardAttributes; static private Dictionary<String, RTFAttribute> straightforwardAttributes;
static { static {
straightforwardAttributes = RTFAttributes.attributesByKeyword(); straightforwardAttributes = RTFAttributes.attributesByKeyword();
} }
...@@ -96,9 +96,9 @@ class RTFReader extends RTFParser ...@@ -96,9 +96,9 @@ class RTFReader extends RTFParser
/* this should be final, but there's a bug in javac... */ /* this should be final, but there's a bug in javac... */
/** textKeywords maps RTF keywords to single-character strings, /** textKeywords maps RTF keywords to single-character strings,
* for those keywords which simply insert some text. */ * for those keywords which simply insert some text. */
static Dictionary textKeywords = null; static Dictionary<String, String> textKeywords = null;
static { static {
textKeywords = new Hashtable(); textKeywords = new Hashtable<String, String>();
textKeywords.put("\\", "\\"); textKeywords.put("\\", "\\");
textKeywords.put("{", "{"); textKeywords.put("{", "{");
textKeywords.put("}", "}"); textKeywords.put("}", "}");
...@@ -129,10 +129,10 @@ class RTFReader extends RTFParser ...@@ -129,10 +129,10 @@ class RTFReader extends RTFParser
static final String TabAlignmentKey = "tab_alignment"; static final String TabAlignmentKey = "tab_alignment";
static final String TabLeaderKey = "tab_leader"; static final String TabLeaderKey = "tab_leader";
static Dictionary characterSets; static Dictionary<String, char[]> characterSets;
static boolean useNeXTForAnsi = false; static boolean useNeXTForAnsi = false;
static { static {
characterSets = new Hashtable(); characterSets = new Hashtable<String, char[]>();
} }
/* TODO: per-font font encodings ( \fcharset control word ) ? */ /* TODO: per-font font encodings ( \fcharset control word ) ? */
...@@ -148,8 +148,8 @@ public RTFReader(StyledDocument destination) ...@@ -148,8 +148,8 @@ public RTFReader(StyledDocument destination)
int i; int i;
target = destination; target = destination;
parserState = new Hashtable(); parserState = new Hashtable<Object, Object>();
fontTable = new Hashtable(); fontTable = new Hashtable<Integer, String>();
rtfversion = -1; rtfversion = -1;
...@@ -220,7 +220,7 @@ public void begingroup() ...@@ -220,7 +220,7 @@ public void begingroup()
Object oldSaveState = parserState.get("_savedState"); Object oldSaveState = parserState.get("_savedState");
if (oldSaveState != null) if (oldSaveState != null)
parserState.remove("_savedState"); parserState.remove("_savedState");
Dictionary saveState = (Dictionary)((Hashtable)parserState).clone(); Dictionary<String, Object> saveState = (Dictionary<String, Object>)((Hashtable)parserState).clone();
if (oldSaveState != null) if (oldSaveState != null)
saveState.put("_savedState", oldSaveState); saveState.put("_savedState", oldSaveState);
parserState.put("_savedState", saveState); parserState.put("_savedState", saveState);
...@@ -242,7 +242,7 @@ public void endgroup() ...@@ -242,7 +242,7 @@ public void endgroup()
skippingCharacters = 0; skippingCharacters = 0;
} }
Dictionary restoredState = (Dictionary)parserState.get("_savedState"); Dictionary<Object, Object> restoredState = (Dictionary<Object, Object>)parserState.get("_savedState");
Destination restoredDestination = (Destination)restoredState.get("dst"); Destination restoredDestination = (Destination)restoredState.get("dst");
if (restoredDestination != rtfDestination) { if (restoredDestination != rtfDestination) {
rtfDestination.close(); /* allow the destination to clean up */ rtfDestination.close(); /* allow the destination to clean up */
...@@ -281,7 +281,7 @@ public void close() ...@@ -281,7 +281,7 @@ public void close()
while(docProps.hasMoreElements()) { while(docProps.hasMoreElements()) {
Object propName = docProps.nextElement(); Object propName = docProps.nextElement();
target.putProperty(propName, target.putProperty(propName,
documentAttributes.getAttribute((String)propName)); documentAttributes.getAttribute(propName));
} }
/* RTFParser should have ensured that all our groups are closed */ /* RTFParser should have ensured that all our groups are closed */
...@@ -301,7 +301,7 @@ public void close() ...@@ -301,7 +301,7 @@ public void close()
*/ */
public boolean handleKeyword(String keyword) public boolean handleKeyword(String keyword)
{ {
Object item; String item;
boolean ignoreGroupIfUnknownKeywordSave = ignoreGroupIfUnknownKeyword; boolean ignoreGroupIfUnknownKeywordSave = ignoreGroupIfUnknownKeyword;
if (skippingCharacters > 0) { if (skippingCharacters > 0) {
...@@ -312,7 +312,7 @@ public boolean handleKeyword(String keyword) ...@@ -312,7 +312,7 @@ public boolean handleKeyword(String keyword)
ignoreGroupIfUnknownKeyword = false; ignoreGroupIfUnknownKeyword = false;
if ((item = textKeywords.get(keyword)) != null) { if ((item = textKeywords.get(keyword)) != null) {
handleText((String)item); handleText(item);
return true; return true;
} }
...@@ -556,14 +556,12 @@ public static Object ...@@ -556,14 +556,12 @@ public static Object
getCharacterSet(final String name) getCharacterSet(final String name)
throws IOException throws IOException
{ {
char[] set; char[] set = characterSets.get(name);
set = (char [])characterSets.get(name);
if (set == null) { if (set == null) {
InputStream charsetStream; InputStream charsetStream;
charsetStream = (InputStream)java.security.AccessController. charsetStream = java.security.AccessController.
doPrivileged(new java.security.PrivilegedAction() { doPrivileged(new java.security.PrivilegedAction<InputStream>() {
public Object run() { public InputStream run() {
return RTFReader.class.getResourceAsStream return RTFReader.class.getResourceAsStream
("charsets/" + name + ".txt"); ("charsets/" + name + ".txt");
} }
...@@ -686,7 +684,7 @@ class DiscardingDestination implements Destination ...@@ -686,7 +684,7 @@ class DiscardingDestination implements Destination
class FonttblDestination implements Destination class FonttblDestination implements Destination
{ {
int nextFontNumber; int nextFontNumber;
Object fontNumberKey = null; Integer fontNumberKey = null;
String nextFontFamily; String nextFontFamily;
public void handleBinaryBlob(byte[] data) public void handleBinaryBlob(byte[] data)
...@@ -716,7 +714,6 @@ class FonttblDestination implements Destination ...@@ -716,7 +714,6 @@ class FonttblDestination implements Destination
nextFontNumber = -1; nextFontNumber = -1;
nextFontFamily = null; nextFontFamily = null;
return;
} }
public boolean handleKeyword(String keyword) public boolean handleKeyword(String keyword)
...@@ -747,10 +744,10 @@ class FonttblDestination implements Destination ...@@ -747,10 +744,10 @@ class FonttblDestination implements Destination
dump its contents to the debugging log. */ dump its contents to the debugging log. */
public void close() public void close()
{ {
Enumeration nums = fontTable.keys(); Enumeration<Integer> nums = fontTable.keys();
warning("Done reading font table."); warning("Done reading font table.");
while(nums.hasMoreElements()) { while(nums.hasMoreElements()) {
Integer num = (Integer)nums.nextElement(); Integer num = nums.nextElement();
warning("Number " + num + ": " + fontTable.get(num)); warning("Number " + num + ": " + fontTable.get(num));
} }
} }
...@@ -761,19 +758,19 @@ class FonttblDestination implements Destination ...@@ -761,19 +758,19 @@ class FonttblDestination implements Destination
class ColortblDestination implements Destination class ColortblDestination implements Destination
{ {
int red, green, blue; int red, green, blue;
Vector proTemTable; Vector<Color> proTemTable;
public ColortblDestination() public ColortblDestination()
{ {
red = 0; red = 0;
green = 0; green = 0;
blue = 0; blue = 0;
proTemTable = new Vector(); proTemTable = new Vector<Color>();
} }
public void handleText(String text) public void handleText(String text)
{ {
int index = 0; int index;
for (index = 0; index < text.length(); index ++) { for (index = 0; index < text.length(); index ++) {
if (text.charAt(index) == ';') { if (text.charAt(index) == ';') {
...@@ -823,11 +820,11 @@ class StylesheetDestination ...@@ -823,11 +820,11 @@ class StylesheetDestination
extends DiscardingDestination extends DiscardingDestination
implements Destination implements Destination
{ {
Dictionary definedStyles; Dictionary<Integer, StyleDefiningDestination> definedStyles;
public StylesheetDestination() public StylesheetDestination()
{ {
definedStyles = new Hashtable(); definedStyles = new Hashtable<Integer, StyleDefiningDestination>();
} }
public void begingroup() public void begingroup()
...@@ -837,19 +834,18 @@ class StylesheetDestination ...@@ -837,19 +834,18 @@ class StylesheetDestination
public void close() public void close()
{ {
Vector chrStyles, pgfStyles, secStyles; Vector<Style> chrStyles = new Vector<Style>();
chrStyles = new Vector(); Vector<Style> pgfStyles = new Vector<Style>();
pgfStyles = new Vector(); Vector<Style> secStyles = new Vector<Style>();
secStyles = new Vector(); Enumeration<StyleDefiningDestination> styles = definedStyles.elements();
Enumeration styles = definedStyles.elements();
while(styles.hasMoreElements()) { while(styles.hasMoreElements()) {
StyleDefiningDestination style; StyleDefiningDestination style;
Style defined; Style defined;
style = (StyleDefiningDestination)styles.nextElement(); style = styles.nextElement();
defined = style.realize(); defined = style.realize();
warning("Style "+style.number+" ("+style.styleName+"): "+defined); warning("Style "+style.number+" ("+style.styleName+"): "+defined);
String stype = (String)defined.getAttribute(Constants.StyleType); String stype = (String)defined.getAttribute(Constants.StyleType);
Vector toSet; Vector<Style> toSet;
if (stype.equals(Constants.STSection)) { if (stype.equals(Constants.STSection)) {
toSet = secStyles; toSet = secStyles;
} else if (stype.equals(Constants.STCharacter)) { } else if (stype.equals(Constants.STCharacter)) {
...@@ -989,7 +985,7 @@ class StylesheetDestination ...@@ -989,7 +985,7 @@ class StylesheetDestination
if (basedOn != STYLENUMBER_NONE) { if (basedOn != STYLENUMBER_NONE) {
StyleDefiningDestination styleDest; StyleDefiningDestination styleDest;
styleDest = (StyleDefiningDestination)definedStyles.get(Integer.valueOf(basedOn)); styleDest = definedStyles.get(Integer.valueOf(basedOn));
if (styleDest != null && styleDest != this) { if (styleDest != null && styleDest != this) {
basis = styleDest.realize(); basis = styleDest.realize();
} }
...@@ -1016,7 +1012,7 @@ class StylesheetDestination ...@@ -1016,7 +1012,7 @@ class StylesheetDestination
if (nextStyle != STYLENUMBER_NONE) { if (nextStyle != STYLENUMBER_NONE) {
StyleDefiningDestination styleDest; StyleDefiningDestination styleDest;
styleDest = (StyleDefiningDestination)definedStyles.get(Integer.valueOf(nextStyle)); styleDest = definedStyles.get(Integer.valueOf(nextStyle));
if (styleDest != null) { if (styleDest != null) {
next = styleDest.realize(); next = styleDest.realize();
} }
...@@ -1122,9 +1118,8 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1122,9 +1118,8 @@ abstract class AttributeTrackingDestination implements Destination
} }
{ {
Object item = straightforwardAttributes.get(keyword); RTFAttribute attr = straightforwardAttributes.get(keyword);
if (item != null) { if (attr != null) {
RTFAttribute attr = (RTFAttribute)item;
boolean ok; boolean ok;
switch(attr.domain()) { switch(attr.domain()) {
...@@ -1191,9 +1186,8 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1191,9 +1186,8 @@ abstract class AttributeTrackingDestination implements Destination
} }
{ {
Object item = straightforwardAttributes.get(keyword); RTFAttribute attr = straightforwardAttributes.get(keyword);
if (item != null) { if (attr != null) {
RTFAttribute attr = (RTFAttribute)item;
boolean ok; boolean ok;
switch(attr.domain()) { switch(attr.domain()) {
...@@ -1267,12 +1261,12 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1267,12 +1261,12 @@ abstract class AttributeTrackingDestination implements Destination
parserState.remove("tab_leader"); parserState.remove("tab_leader");
TabStop newStop = new TabStop(tabPosition, tabAlignment, tabLeader); TabStop newStop = new TabStop(tabPosition, tabAlignment, tabLeader);
Dictionary tabs; Dictionary<Object, Object> tabs;
Integer stopCount; Integer stopCount;
tabs = (Dictionary)parserState.get("_tabs"); tabs = (Dictionary<Object, Object>)parserState.get("_tabs");
if (tabs == null) { if (tabs == null) {
tabs = new Hashtable(); tabs = new Hashtable<Object, Object>();
parserState.put("_tabs", tabs); parserState.put("_tabs", tabs);
stopCount = Integer.valueOf(1); stopCount = Integer.valueOf(1);
} else { } else {
...@@ -1369,7 +1363,7 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1369,7 +1363,7 @@ abstract class AttributeTrackingDestination implements Destination
/* note setFontFamily() can not handle a null font */ /* note setFontFamily() can not handle a null font */
String fontFamily; String fontFamily;
if (fontnum != null) if (fontnum != null)
fontFamily = (String)fontTable.get(fontnum); fontFamily = fontTable.get(fontnum);
else else
fontFamily = null; fontFamily = null;
if (fontFamily != null) if (fontFamily != null)
...@@ -1474,9 +1468,9 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1474,9 +1468,9 @@ abstract class AttributeTrackingDestination implements Destination
handleKeyword("fs", 24); /* 12 pt. */ handleKeyword("fs", 24); /* 12 pt. */
Enumeration attributes = straightforwardAttributes.elements(); Enumeration<RTFAttribute> attributes = straightforwardAttributes.elements();
while(attributes.hasMoreElements()) { while(attributes.hasMoreElements()) {
RTFAttribute attr = (RTFAttribute)attributes.nextElement(); RTFAttribute attr = attributes.nextElement();
if (attr.domain() == RTFAttribute.D_CHARACTER) if (attr.domain() == RTFAttribute.D_CHARACTER)
attr.setDefault(characterAttributes); attr.setDefault(characterAttributes);
} }
...@@ -1498,9 +1492,9 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1498,9 +1492,9 @@ abstract class AttributeTrackingDestination implements Destination
StyleConstants.setAlignment(paragraphAttributes, StyleConstants.setAlignment(paragraphAttributes,
StyleConstants.ALIGN_LEFT); StyleConstants.ALIGN_LEFT);
Enumeration attributes = straightforwardAttributes.elements(); Enumeration<RTFAttribute> attributes = straightforwardAttributes.elements();
while(attributes.hasMoreElements()) { while(attributes.hasMoreElements()) {
RTFAttribute attr = (RTFAttribute)attributes.nextElement(); RTFAttribute attr = attributes.nextElement();
if (attr.domain() == RTFAttribute.D_PARAGRAPH) if (attr.domain() == RTFAttribute.D_PARAGRAPH)
attr.setDefault(characterAttributes); attr.setDefault(characterAttributes);
} }
...@@ -1511,9 +1505,9 @@ abstract class AttributeTrackingDestination implements Destination ...@@ -1511,9 +1505,9 @@ abstract class AttributeTrackingDestination implements Destination
* \sectd keyword. */ * \sectd keyword. */
protected void resetSectionAttributes() protected void resetSectionAttributes()
{ {
Enumeration attributes = straightforwardAttributes.elements(); Enumeration<RTFAttribute> attributes = straightforwardAttributes.elements();
while(attributes.hasMoreElements()) { while(attributes.hasMoreElements()) {
RTFAttribute attr = (RTFAttribute)attributes.nextElement(); RTFAttribute attr = attributes.nextElement();
if (attr.domain() == RTFAttribute.D_SECTION) if (attr.domain() == RTFAttribute.D_SECTION)
attr.setDefault(characterAttributes); attr.setDefault(characterAttributes);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册