javax.swing.text

Class DefaultStyledDocument.ElementSpec

public static class DefaultStyledDocument.ElementSpec extends Object

Carries specification information for new {@link Element}s that should be created in {@link ElementBuffer}. This allows the parsing process to be decoupled from the Element creation process.
Field Summary
static shortContentType
This indicates a content element.
static shortEndTagType
This indicates an end tag.
static shortJoinFractureDirection
This indicates that the data associated with this spec should be joined to the fractured element.
static shortJoinNextDirection
This indicates that the data associated with this spec should be joined with what follows it.
static shortJoinPreviousDirection
This indicates that the data associated with this spec should be joined with what precedes it.
static shortOriginateDirection
This indicates that the data associated with this spec should be used to create a new element.
static shortStartTagType
This indicates a start tag.
Constructor Summary
ElementSpec(AttributeSet a, short type)
Creates a new ElementSpec with no content, length or offset.
ElementSpec(AttributeSet a, short type, int len)
Creates a new ElementSpec that specifies the length but not the offset of an element.
ElementSpec(AttributeSet a, short type, char[] txt, int offs, int len)
Creates a new ElementSpec with document content.
Method Summary
char[]getArray()
Returns the actual content of the element.
AttributeSetgetAttributes()
Returns the attributes of the element.
shortgetDirection()
Returns the direction of the element.
intgetLength()
Returns the length of the content.
intgetOffset()
Returns the offset of the content.
shortgetType()
Returns the type of the element.
voidsetDirection(short dir)
Sets the direction of the element.
voidsetType(short type)
Sets the type of the element.
StringtoString()
Returns a String representation of this ElementSpec describing the type, direction and length of this ElementSpec.

Field Detail

ContentType

public static final short ContentType
This indicates a content element. This is a possible value for {@link #getType}.

EndTagType

public static final short EndTagType
This indicates an end tag. This is a possible value for {@link #getType}.

JoinFractureDirection

public static final short JoinFractureDirection
This indicates that the data associated with this spec should be joined to the fractured element. This is a possible value for {@link #getDirection}.

JoinNextDirection

public static final short JoinNextDirection
This indicates that the data associated with this spec should be joined with what follows it. This is a possible value for {@link #getDirection}.

JoinPreviousDirection

public static final short JoinPreviousDirection
This indicates that the data associated with this spec should be joined with what precedes it. This is a possible value for {@link #getDirection}.

OriginateDirection

public static final short OriginateDirection
This indicates that the data associated with this spec should be used to create a new element. This is a possible value for {@link #getDirection}.

StartTagType

public static final short StartTagType
This indicates a start tag. This is a possible value for {@link #getType}.

Constructor Detail

ElementSpec

public ElementSpec(AttributeSet a, short type)
Creates a new ElementSpec with no content, length or offset. This is most useful for start and end tags.

Parameters: a the attributes for the element to be created type the type of the tag

ElementSpec

public ElementSpec(AttributeSet a, short type, int len)
Creates a new ElementSpec that specifies the length but not the offset of an element. Such ElementSpecs are processed sequentially from a known starting point.

Parameters: a the attributes for the element to be created type the type of the tag len the length of the element

ElementSpec

public ElementSpec(AttributeSet a, short type, char[] txt, int offs, int len)
Creates a new ElementSpec with document content.

Parameters: a the attributes for the element to be created type the type of the tag txt the actual content offs the offset into the txt array len the length of the element

Method Detail

getArray

public char[] getArray()
Returns the actual content of the element.

Returns: the actual content of the element

getAttributes

public AttributeSet getAttributes()
Returns the attributes of the element.

Returns: the attributes of the element

getDirection

public short getDirection()
Returns the direction of the element.

Returns: the direction of the element

getLength

public int getLength()
Returns the length of the content.

Returns: the length of the content

getOffset

public int getOffset()
Returns the offset of the content.

Returns: the offset of the content

getType

public short getType()
Returns the type of the element.

Returns: the type of the element

setDirection

public void setDirection(short dir)
Sets the direction of the element.

Parameters: dir the direction of the element to be set

setType

public void setType(short type)
Sets the type of the element.

Parameters: type the type of the element to be set

toString

public String toString()
Returns a String representation of this ElementSpec describing the type, direction and length of this ElementSpec.

Returns: a String representation of this ElementSpec