replace remaining use of java.util.Vector by ArrayList (WebCat-swf)

pull/41/merge
reger 9 years ago
parent 9331acdb18
commit 11b1587067

@ -3,8 +3,7 @@ package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
@ -550,7 +549,7 @@ public class ActionParser implements SWFActionCodes {
List records = new ArrayList();
List<ActionRecord> jumpers = new ArrayList();
List<Integer> skippers = new ArrayList();
Hashtable offsetTable = new Hashtable();
HashMap offsetTable = new HashMap();
Stack blockSizes = new Stack();

@ -3,11 +3,11 @@ package pt.tumba.parser.swf;
import com.anotherbigidea.flash.SWFActionCodes;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Hashtable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Stack;
import java.util.Vector;
/**
* A writer that implements the SWFActions interface and writes action bytes to
@ -17,53 +17,21 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class ActionWriter implements SWFActions, SWFActionCodes {
/**
* Description of the Field
*/
protected TagWriter tagWriter;
/**
* Description of the Field
*/
protected OutStream out;
/**
* Description of the Field
*/
protected ByteArrayOutputStream bout;
/**
* Description of the Field
*/
protected int count;
/**
* Description of the Field
*/
protected int flashVersion;
/**
* Description of the Field
*/
protected List pushValues;
/**
* Description of the Field
*/
protected Hashtable labels;
/**
* Description of the Field
*/
protected HashMap labels;
protected List jumps;
/**
* Description of the Field
*/
protected List skips;
//--for fixing up functions and WITH blocks..
/**
* Description of the Field
*/
protected List blocks;
/**
* Description of the Field
*/
protected Stack blockStack;
@ -106,7 +74,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
count = 0;
bout = new ByteArrayOutputStream();
out = new OutStream(bout);
pushValues = new Vector();
pushValues = new ArrayList();
labels = null;
jumps = null;
skips = null;
@ -315,7 +283,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
int offset = (int) out.getBytesWritten();
if (labels == null) {
labels = new Hashtable();
labels = new HashMap();
}
labels.put(label, new int[]{offset, count + 1});
}
@ -452,7 +420,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
//--save jump info for later fix-up logic
if (jumps == null) {
jumps = new Vector();
jumps = new ArrayList();
}
jumps.add(new Object[]{label, new Integer(here)});
}
@ -498,7 +466,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
//--save skip info for later fix-up logic
if (skips == null) {
skips = new Vector();
skips = new ArrayList();
}
skips.add(new Object[]{jumpLabel, new int[]{count, here}});
}
@ -520,7 +488,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
//--save skip info for later fix-up logic
if (skips == null) {
skips = new Vector();
skips = new ArrayList();
}
skips.add(new Object[]{jumpLabel, new int[]{count, here}});
}
@ -1032,7 +1000,7 @@ public class ActionWriter implements SWFActions, SWFActionCodes {
int[] blockInfo = (int[]) blockStack.pop();
if (blocks == null) {
blocks = new Vector();
blocks = new ArrayList();
}
int offset = blockInfo[0];

@ -2,7 +2,7 @@ package pt.tumba.parser.swf;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.util.Vector;
import java.util.ArrayList;
/**
* A set of actions
@ -11,13 +11,8 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class Actions extends ActionWriter {
/**
* Description of the Field
*/
protected int conditions;
/**
* Description of the Field
*/
protected byte[] bytes;
@ -34,7 +29,7 @@ public class Actions extends ActionWriter {
count = 0;
bout = new ByteArrayOutputStream();
out = new OutStream(bout);
pushValues = new Vector();
pushValues = new ArrayList();
labels = null;
jumps = null;
skips = null;

@ -11,7 +11,7 @@ import java.io.Reader;
import java.io.StringReader;
import java.io.StringWriter;
import java.io.Writer;
import java.util.Hashtable;
import java.util.HashMap;
/**
* Base64 encoding/decoding utilities
@ -31,9 +31,6 @@ public class Base64 {
}
/**
* Description of the Field
*/
public final static char[] charset =
{
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H',
@ -46,15 +43,9 @@ public class Base64 {
'4', '5', '6', '7', '8', '9', '+', '/'
};
/**
* Description of the Field
*/
public final static char paddingChar = '=';
/**
* Description of the Field
*/
protected static Hashtable charLookup = new Hashtable();
protected static HashMap charLookup = new HashMap();
static {
//initialize the hashtable

@ -1,9 +1,9 @@
package pt.tumba.parser.swf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
/**
* Description of the Class
@ -12,38 +12,15 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class ButtonRecord {
/**
* Description of the Field
*/
public final static int BUTTON_HITTEST = 0x08;
/**
* Description of the Field
*/
public final static int BUTTON_DOWN = 0x04;
/**
* Description of the Field
*/
public final static int BUTTON_OVER = 0x02;
/**
* Description of the Field
*/
public final static int BUTTON_UP = 0x01;
/**
* Description of the Field
*/
protected int flags;
/**
* Description of the Field
*/
protected int id;
/**
* Description of the Field
*/
protected int layer;
/**
* Description of the Field
*/
protected Matrix matrix;
@ -175,11 +152,11 @@ public class ButtonRecord {
*@exception IOException Description of the Exception
*/
public static List read(InStream in) throws IOException {
Vector records = new Vector();
List records = new ArrayList();
int firstByte = 0;
while ((firstByte = in.readUI8()) != 0) {
records.addElement(new ButtonRecord(in, firstByte));
records.add(new ButtonRecord(in, firstByte));
}
return records;

@ -1,9 +1,9 @@
package pt.tumba.parser.swf;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Vector;
/**
* Description of the Class
@ -12,9 +12,7 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class ButtonRecord2 extends ButtonRecord {
/**
* Description of the Field
*/
protected AlphaTransform transform;
@ -46,11 +44,11 @@ public class ButtonRecord2 extends ButtonRecord {
*@exception IOException Description of the Exception
*/
public static List read(InStream in) throws IOException {
Vector records = new Vector();
List records = new ArrayList();
int firstByte = 0;
while ((firstByte = in.readUI8()) != 0) {
records.addElement(new ButtonRecord2(in, firstByte));
records.add(new ButtonRecord2(in, firstByte));
}
return records;

@ -1,9 +1,8 @@
package pt.tumba.parser.swf;
import java.io.IOException;
import java.util.Iterator;
import java.util.ArrayList;
import java.util.List;
import java.util.Vector;
/**
* A Movie or Movie Clip frame
@ -12,29 +11,12 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class Frame {
/**
* Description of the Field
*/
protected int frameNumber;
/**
* Description of the Field
*/
protected String label;
/**
* Description of the Field
*/
protected List placements = new Vector();
/**
* Description of the Field
*/
protected List<Placement> placements = new ArrayList();
protected boolean stop;
/**
* Description of the Field
*/
protected TimeLine timeline;
/**
* Description of the Field
*/
protected Actions actions;
/**
@ -402,19 +384,15 @@ public class Frame {
*@param definitionWriter Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void flushDefinitions(
Movie movie,
SWFTagTypes timelineWriter,
SWFTagTypes definitionWriter)
throws IOException {
for (Iterator enumerator = placements.iterator();
enumerator.hasNext();
) {
Placement placement = (Placement) enumerator.next();
placement.flushDefinitions(movie, timelineWriter, definitionWriter);
}
}
protected void flushDefinitions(
Movie movie,
SWFTagTypes timelineWriter,
SWFTagTypes definitionWriter)
throws IOException {
for (Placement placement : placements) {
placement.flushDefinitions(movie, timelineWriter, definitionWriter);
}
}
/**
* Write the frame
@ -424,38 +402,34 @@ public class Frame {
*@param timelineTagWriter Description of the Parameter
*@exception IOException Description of the Exception
*/
protected void write(
Movie movie,
SWFTagTypes movieTagWriter,
SWFTagTypes timelineTagWriter)
throws IOException {
if (actions != null) {
SWFActions acts = timelineTagWriter.tagDoAction();
acts.start(0);
acts.blob(actions.bytes);
acts.done();
}
if (stop) {
SWFActions actions = timelineTagWriter.tagDoAction();
actions.start(0);
actions.stop();
actions.end();
actions.done();
}
for (Iterator enumumerator = placements.iterator();
enumumerator.hasNext();
) {
Placement placement = (Placement) enumumerator.next();
placement.write(movie, movieTagWriter, timelineTagWriter);
}
if (label != null) {
timelineTagWriter.tagFrameLabel(label);
}
timelineTagWriter.tagShowFrame();
}
protected void write(
Movie movie,
SWFTagTypes movieTagWriter,
SWFTagTypes timelineTagWriter)
throws IOException {
if (actions != null) {
SWFActions acts = timelineTagWriter.tagDoAction();
acts.start(0);
acts.blob(actions.bytes);
acts.done();
}
if (stop) {
SWFActions actions = timelineTagWriter.tagDoAction();
actions.start(0);
actions.stop();
actions.end();
actions.done();
}
for (Placement placement : placements) {
placement.write(movie, movieTagWriter, timelineTagWriter);
}
if (label != null) {
timelineTagWriter.tagFrameLabel(label);
}
timelineTagWriter.tagShowFrame();
}
}

@ -10,7 +10,6 @@ import java.util.List;
import java.util.Map;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.Vector;
/**
* A Flash Movie
@ -19,63 +18,24 @@ import java.util.Vector;
*@created 15 de Setembro de 2002
*/
public class Movie implements TimeLine {
/**
* Description of the Field
*/
protected int width;
/**
* Description of the Field
*/
protected int height;
/**
* Description of the Field
*/
protected int frameRate;
/**
* Description of the Field
*/
protected Color backColor;
/**
* Description of the Field
*/
protected int version;
/**
* Description of the Field
*/
protected boolean isProtected;
/**
* Description of the Field
*/
protected Map importLibraries;
/**
* Description of the Field
*/
protected List exportedSymbols;
protected Map<String, List> importLibraries;
protected List<ExportedSymbol> exportedSymbols;
/**
* Description of the Field
*/
protected SortedMap frames = new TreeMap();
/**
* Description of the Field
*/
protected SortedMap<Integer, Frame> frames = new TreeMap();
protected int frameCount = 0;
//--Table of characters defined so far in the movie - while writing out
/**
* Description of the Field
*/
protected Map definedSymbols = new HashMap();
/**
* Description of the Field
*/
protected int depth = 1;
//the next available depth
/**
* Description of the Field
*/
protected int depth = 1; //the next available depth
protected int maxId = 1;
@ -357,20 +317,16 @@ public class Movie implements TimeLine {
return new ImportedSymbol[0];
}
Vector imports = new Vector();
for (Iterator iter = importLibraries.values().iterator(); iter.hasNext(); ) {
List list = (List) iter.next();
List imports = new ArrayList();
for (List list : importLibraries.values()) {
for (Iterator i2 = list.iterator(); i2.hasNext(); ) {
imports.add(i2.next());
}
}
ImportedSymbol[] imps = new ImportedSymbol[imports.size()];
imports.copyInto(imps);
return imps;
return (ImportedSymbol[])imports.toArray(imps);
}
@ -383,7 +339,7 @@ public class Movie implements TimeLine {
*/
public void exportSymbols(String[] exportNames, Symbol[] symbols) {
if (exportedSymbols == null) {
exportedSymbols = new Vector();
exportedSymbols = new ArrayList();
}
for (int i = 0; i < exportNames.length && i < symbols.length; i++) {

@ -12,23 +12,12 @@ import java.io.OutputStream;
*@created 15 de Setembro de 2002
*/
public class OutStream {
/**
* Description of the Field
*/
protected OutputStream out;
/**
* Description of the Field
*/
protected long bytesWritten = 0L;
//--Bit buffer..
/**
* Description of the Field
*/
protected int bitBuf;
/**
* Description of the Field
*/
protected int bitPos;
@ -104,6 +93,7 @@ public class OutStream {
*@exception IOException Description of the Exception
*/
public void close() throws IOException {
flushBits();
out.close();
}
@ -325,8 +315,7 @@ public class OutStream {
if (string != null) {
out.write(string);
}
out.write(0);
//terminate string
out.write(0); //terminate string
bytesWritten += string.length + 1;
}
@ -343,8 +332,7 @@ public class OutStream {
if (string == null) {
return 1;
}
return string.length + 1;
//to include the terminating null
return string.length + 1; //to include the terminating null
}
@ -361,8 +349,7 @@ public class OutStream {
}
byte[] bytes = string.getBytes();
return bytes.length + 1;
//to include the terminating null
return bytes.length + 1; //to include the terminating null
}

Loading…
Cancel
Save