📄 deckelement.java
字号:
/*
* j2wap is distributed under the terms of the GNU Public License
*
* j2wap was written by:
*
* Scott Campbell
* Michael Nordling
* Karl Maftoum
* Julian Bright
*
* This was a final project for Comp.Engineering at the University of Canberra, Australia
*
* Now released as Open Source software. 28 November 2000
*
* Email: k_maftoum@hotmail.com for more info
*
* Use entirely at your own risk.
*/
package wae;
import java.lang.ArrayIndexOutOfBoundsException;
/**
* Title: DeckElement
* Description: DeckElement is a class that encapsulates a WML deck's bytecode
* and functionality required to manage and manipulate that
* bytecode during parsing of a deck element.
* Company: J2wap.com
* @author Scott Campbell
* @version 1.1
*/
public class DeckElement
{
/** Index of the next byte to be read from the deck's bytecode array. */
private int c_intNextPos = 0;
/** Index of the <code>wml</code> tag in the deck's bytecode array. */
private int c_intWmlStartPos = 0;
/**
* Index of the <code>template</code> tag in the deck's bytecode array. if it
* exists at all.
*/
private int c_intTemplateStartPos = 0;
/** A copy of the deck's bytecode as a byte array. */
private byte c_arrDeckBytecode[];
/**
* Constructor: Sets the decks bytecode array.
*/
public DeckElement (byte in_arrDeckBytecode[])
{
c_arrDeckBytecode = in_arrDeckBytecode;
} // constructor DeckElement
/**
* Gets the next byte in the <code>c_arrDeckBytecode</code> array.
* If there are no more bytes in the array, return Wbxml.INVALID_BYTE.
* @return The next byte in the bytecode array or Wbxml.INVALID_BYTE if there
* are no more bytes in the array, i.e. already at the last byte.
*/
public byte nextByte()
{
// Check if we have read the last byte in the array.
if (c_intNextPos >= c_arrDeckBytecode.length)
return Wbxml.INVALID_BYTE;
else
return c_arrDeckBytecode[c_intNextPos++];
} // nextByte
/**
* Gets the position of the next byte to be read from the bytecode array.
* @return The value of <code>c_intNextPos</code>
*/
public int nextPos ()
{
return c_intNextPos;
} // nextPos
/**
* Sets the <code>c_intWmlStartPos</code> attribute to flag the position of
* the <code>WML</code> content in the bytecode array.
*/
public void setWmlStartPos ()
{
c_intWmlStartPos = c_intNextPos;
} // setWmlStartPos
/**
* Sets the <code>c_intTemplateStartPos</code> attribute to flag the position
* of the <code>template</code> content in the bytecode array.
*/
// public void setTemplateStartPos (int in_intNextPos)
public void setTemplateStartPos ()
{
c_intTemplateStartPos = c_intNextPos;
} // setTemplateStartPos
/**
* Sets the <code>c_intNextPos</code> attribute to the value passed in as a
* parameter. This method facilitates random setting of the next byte to be
* read by the <code>nextByte ()</code> method.
* @param in_intNextPos The index of the byte that will be return by a call
* to <code>nextByte()</code>
*/
public void setNextPos (int in_intNextPos)
{
c_intNextPos = in_intNextPos;
} // setNextPos
/**
* Sets the <code>c_intNextPos</code> attribute to the value of the
* <code>c_intWmlStartPos</code> attribute. A call to <code>nextByte ()</code>
* will return the bytecode for the <code>WML</code> tag.
*/
public void ResetToWmlStartPos ()
{
c_intNextPos = c_intWmlStartPos;
} // ResetToWmlStartPos
/**
* Sets the <code>c_intNextPos</code> attribute to the value of the
* <code>c_intWmlStartPos</code> attribute. A call to <code>nextByte ()</code>
* will return the bytecode for the <code>template</code> tag.
*/
public void ResetToTemplateStartPos ()
{
c_intNextPos = c_intTemplateStartPos;
} // ResetToTemplateStartPos
} // class DeckElement
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -