public class SWFReader extends Object implements ISWFReader, ITagContainer
ISWFReader
. This is a recursive-descent decoder of
a SWF file. Error handling for malformed SWFs: 1. Catch RuntimeExceptions
thrown by InputBitStream and report problems. 2. Handle errors in SWF tag
bodies by logging problems and throwing MalformedTagExceptions. 3. Recover
from #1 and #2 by throwing out the current tag and reading up to the start of
the next tag.Modifier and Type | Class and Description |
---|---|
protected static class |
SWFReader.TagHeader
Wrapper class for "type" and "length" field in a SWF tag header.
|
Modifier and Type | Field and Description |
---|---|
protected static int |
BITS_TAG_LENGTH
The lower 6 bits in the TagCodeAndLength field in the SWF tag header is
the tag length.
|
protected InputBitStream |
bitStream
SWF input bit stream.
|
static org.apache.flex.swf.io.SWFReader.InvalidTag |
INVALID_TAG |
protected static int |
MASK_TAG_LENGTH
Mask on the TagCodeAndLength field to get the lower 6 bits of tag length.
|
protected Collection<ICompilerProblem> |
problems |
protected SWF |
swf
Model of the SWF file.
|
protected List<ITag> |
tags
All the tags in the SWF file.
|
Constructor and Description |
---|
SWFReader()
Create a SWFReader and initialize field members.
|
SWFReader(boolean isBuildFrames)
Create a SWFReader and initialize field members.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Close the reader an the underlying input stream.
|
Collection<ICompilerProblem> |
getProblems() |
ISWF |
getSWF()
Get the SWF tied to this reader.
|
Iterator<ITag> |
iterator()
Get all the tags in this SWF file.
|
protected SWFReader.TagHeader |
nextTagHeader()
Read the next tag's header field and get the tag length and type.
|
DefineMorphShapeTag |
readDefineMorphShape() |
DefineMorphShape2Tag |
readDefineMorphShape2() |
protected DoABCTag |
readDoABC() |
ISWF |
readFrom(InputStream input,
String path)
Read a SWF file from the input stream.
|
protected boolean |
readHeader()
Read SWF header.
|
protected Matrix |
readMatrix() |
protected ITag |
readTag(SWFReader.TagHeader header)
Read a tag body.
|
protected ITag |
readTagBody(TagType type)
Select the tag decoding function by its type.
|
protected void |
readTags()
Read SWF tags and add each tag to the tag list.
|
public static final org.apache.flex.swf.io.SWFReader.InvalidTag INVALID_TAG
protected static final int MASK_TAG_LENGTH
protected static final int BITS_TAG_LENGTH
protected InputBitStream bitStream
protected SWF swf
protected final List<ITag> tags
protected final Collection<ICompilerProblem> problems
public SWFReader()
public SWFReader(boolean isBuildFrames)
isBuildFrames
- if true, the reader will build SWF frames from tags
readpublic ISWF readFrom(InputStream input, String path)
ISWFReader
readFrom
in interface ISWFReader
input
- source.path
- path of input source, used for error reporting. May not be
null.public ISWF getSWF()
public Collection<ICompilerProblem> getProblems()
getProblems
in interface ITagContainer
protected void readTags() throws IOException
IOException
- errorprotected SWFReader.TagHeader nextTagHeader()
protected ITag readTag(SWFReader.TagHeader header) throws IOException
header
- tag headerIOException
- errorpublic void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
IOException
protected DoABCTag readDoABC() throws IOException
IOException
protected boolean readHeader() throws IOException
IOException
protected Matrix readMatrix()
public DefineMorphShapeTag readDefineMorphShape() throws IOException, org.apache.flex.swf.io.SWFReader.MalformedTagException
IOException
org.apache.flex.swf.io.SWFReader.MalformedTagException
SWFWriter.writeDefineMorphShape(org.apache.flex.swf.tags.DefineMorphShapeTag)
public DefineMorphShape2Tag readDefineMorphShape2() throws IOException, org.apache.flex.swf.io.SWFReader.MalformedTagException
IOException
org.apache.flex.swf.io.SWFReader.MalformedTagException
SWFWriter.writeDefineMorphShape2(org.apache.flex.swf.tags.DefineMorphShape2Tag)
protected ITag readTagBody(TagType type) throws IOException, org.apache.flex.swf.io.SWFReader.MalformedTagException
type
- tag typeIOException
org.apache.flex.swf.io.SWFReader.MalformedTagException
Copyright © 2016 The Apache Software Foundation. All rights reserved.