📄 fsunknownobject.java
字号:
/*
* FSUnknownObject.java
* Transform
*
* Copyright (c) 2001-2006 Flagstone Software Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Flagstone Software Ltd. nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.flagstone.transform;
/**
FSUnknownObject is used to represent any data structure decoded from a Flash file that
is currently not supported by the framework.
<p>This allows Flash files to be parsed, processed and encoded without affecting any of the data structures not directly supported.</p>
<table class="datasheet">
<tr><th align="left" colspan="2">Attributes</th></tr>
<tr>
<td><a name="FSUnknownObject_0">type</a></td>
<td>Identifies the data structure when it is encoded. Read-only.</td>
</tr>
<tr>
<td><a name="FSUnknownObject_1">data</a></td>
<td>The encoded bytes that make up the body of the data structure.</td>
</tr>
</table>
<p>The object provides direct access to the encoded data of the data structure offering the possibility for Transform to encode and decode tags that are not directly supported in the current release of the package. However a detailed knowledge of how the data structure is encoded and decoded is required.</p>
*/
public class FSUnknownObject extends FSMovieObject
{
private byte[] data = null;
/**
* Construct an FSUnknownObject object, initalizing it with values decoded
* from an encoded object.
*
* @param coder an FSCoder containing the binary data.
*/
public FSUnknownObject(FSCoder coder)
{
super(0);
decode(coder);
}
/** Constructs an FSUnknownObject object of the specified type with the encoded Flash data.
@param aType the code identifying the tag type.
@param bytes the encoded data for the tag.
*/
public FSUnknownObject(int aType, byte[] bytes)
{
super(aType);
setData(bytes);
}
/**
* Constructs an FSUnknownObject object by copying values from an existing
* object.
*
* @param obj an FSUnknownObject object.
*/
public FSUnknownObject(FSUnknownObject obj)
{
super(obj);
if (obj.data != null)
data = Transform.clone(obj.data);
}
/** Gets the encoded data for the tag.
@return an array of bytes representing the tag data when encoded to a Flash file.
*/
public byte[] getData()
{
return data;
}
/** Sets the encoded data for the tag.
@param bytes the encoded data for the tag.
*/
public void setData(byte[] bytes)
{
data = bytes;
}
public Object clone()
{
FSUnknownObject anObject = (FSUnknownObject)super.clone();
anObject.data = Transform.clone(data);
return anObject;
}
public boolean equals(Object anObject)
{
boolean result = false;
if (super.equals(anObject))
{
FSUnknownObject typedObject = (FSUnknownObject)anObject;
result = Transform.equals(data, typedObject.data);
}
return result;
}
public void appendDescription(StringBuffer buffer, int depth)
{
buffer.append(name());
}
public int length(FSCoder coder)
{
super.length(coder);
length += data.length;
return length;
}
public void encode(FSCoder coder)
{
super.encode(coder);
coder.writeBytes(data);
coder.endObject(name());
}
public void decode(FSCoder coder)
{
super.decode(coder);
data = new byte[length];
coder.readBytes(data);
coder.endObject(name());
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -