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