xjavadoc
Class DefaultXTag

java.lang.Object
  extended byxjavadoc.DefaultXTag
All Implemented Interfaces:
XTag

public class DefaultXTag
extends java.lang.Object
implements XTag

Author:
Aslak Helles�y

Field Summary
private  java.util.List _attributeNames
          Ordered List of attribute names
private  java.util.Map _attributes
          attribute map
private  XDoc _doc
           
private  int _hash
           
private  boolean _isDirty
          indicate dirty state
private  boolean _isParsed
          tag parse status
private  int _lineNumber
           
private  java.lang.String _name
          tag name
private  java.util.Set _tagListeners
          tag listeners interested in changes.
private  java.lang.String _value
          string representation of tag
private  XJavaDoc _xJavaDoc
           
static int instanceCount
           
 
Constructor Summary
DefaultXTag()
           
 
Method Summary
 void addTagListener(XTagListener tagListener)
          add doc listener interested in chages
private  void ensureTagListenersInitialised()
           
 boolean equals(java.lang.Object o)
           
protected  void fail(java.lang.String message)
          Utility method that should be called from validate() in case ov a validation failure.
private  void fireTagChanged()
          fire tagChanged event
 java.util.Collection getAttributeNames()
          Returns all tag parameters with the given name, or an empty List if none exist;
 java.lang.String getAttributeValue(java.lang.String attributeName)
          Returns the first tag parameter with the given name, or null if none exist;
 XDoc getDoc()
          Returns the XDoc object we belong to.
 java.lang.String getInfo()
           
 int getLineNumber()
           
 java.lang.String getName()
          Returns the full name of the tag, excluding the @
 java.lang.String getValue()
          Returns the full value of the tag.
 int hashCode()
           
(package private)  void init(java.lang.String name, java.lang.String value, XDoc doc, int lineNumber)
          Sets the name and value.
private  void parse()
          Given the raw javadoc tag content as the value parameter parses it and sets the parameter.
 java.lang.String removeAttribute(java.lang.String attributeName)
          Removes an attribute
 void removeTagListener(XTagListener tagListener)
          remove doc listener
private  void resetValue()
           
private  void setAttribute_Impl(java.lang.String attributeName, java.lang.String attributeValue)
           
 void setAttribute(java.lang.String attributeName, java.lang.String attributeValue)
          Adds a parameter
private static int skipWhitespace(java.lang.String s, int i)
          Skips whitespaces, starting from index i till the first non-whitespace character or end of s and returns the new index.
 void validate()
          Validates the tag
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

instanceCount

public static int instanceCount

_name

private java.lang.String _name
tag name


_value

private java.lang.String _value
string representation of tag


_attributes

private java.util.Map _attributes
attribute map


_attributeNames

private java.util.List _attributeNames
Ordered List of attribute names


_isParsed

private boolean _isParsed
tag parse status


_hash

private int _hash

_isDirty

private boolean _isDirty
indicate dirty state


_doc

private XDoc _doc

_tagListeners

private java.util.Set _tagListeners
tag listeners interested in changes. This would be parent xdoc


_lineNumber

private int _lineNumber

_xJavaDoc

private XJavaDoc _xJavaDoc
Constructor Detail

DefaultXTag

public DefaultXTag()
Method Detail

skipWhitespace

private static int skipWhitespace(java.lang.String s,
                                  int i)
Skips whitespaces, starting from index i till the first non-whitespace character or end of s and returns the new index.

Parameters:
s - Describe what the parameter does
i - Describe what the parameter does
Returns:
Describe the return value

getDoc

public final XDoc getDoc()
Description copied from interface: XTag
Returns the XDoc object we belong to.

Specified by:
getDoc in interface XTag
Returns:
the XDoc object we belong to.

getAttributeValue

public final java.lang.String getAttributeValue(java.lang.String attributeName)
Returns the first tag parameter with the given name, or null if none exist;

Specified by:
getAttributeValue in interface XTag
Parameters:
attributeName - Describe what the parameter does
Returns:
The Parameter value

getAttributeNames

public final java.util.Collection getAttributeNames()
Returns all tag parameters with the given name, or an empty List if none exist;

Specified by:
getAttributeNames in interface XTag
Returns:
The Parameters value

getName

public final java.lang.String getName()
Returns the full name of the tag, excluding the @

Specified by:
getName in interface XTag
Returns:
tag name

getValue

public final java.lang.String getValue()
Returns the full value of the tag.

Specified by:
getValue in interface XTag
Returns:
full value of the tag

getLineNumber

public final int getLineNumber()
Specified by:
getLineNumber in interface XTag

getInfo

public final java.lang.String getInfo()
Specified by:
getInfo in interface XTag

setAttribute

public final void setAttribute(java.lang.String attributeName,
                               java.lang.String attributeValue)
Adds a parameter

Specified by:
setAttribute in interface XTag
Parameters:
attributeName - The new Attribute value
attributeValue - The new Attribute value

addTagListener

public final void addTagListener(XTagListener tagListener)
add doc listener interested in chages

Specified by:
addTagListener in interface XTag
Parameters:
tagListener - The feature to be added to the TagListener attribute

removeTagListener

public final void removeTagListener(XTagListener tagListener)
remove doc listener

Specified by:
removeTagListener in interface XTag
Parameters:
tagListener -

removeAttribute

public final java.lang.String removeAttribute(java.lang.String attributeName)
Removes an attribute

Specified by:
removeAttribute in interface XTag
Parameters:
attributeName - atribute to remove
Returns:
the removed attribute value or null if it didn't exist

equals

public final boolean equals(java.lang.Object o)
Specified by:
equals in interface XTag

hashCode

public final int hashCode()
Specified by:
hashCode in interface XTag

validate

public void validate()
              throws TagValidationException
Validates the tag

Specified by:
validate in interface XTag
Throws:
TagValidationException

fail

protected final void fail(java.lang.String message)
                   throws TagValidationException
Utility method that should be called from validate() in case ov a validation failure. Throws a new TagValidationException with

Parameters:
message - the message to include
Throws:
TagValidationException - always thrown.

init

final void init(java.lang.String name,
                java.lang.String value,
                XDoc doc,
                int lineNumber)
Sets the name and value. Called immediately after initialisation by XTagFactory. Don't call this method from anywhere else.

Parameters:
name -
value -
doc -
lineNumber -

setAttribute_Impl

private final void setAttribute_Impl(java.lang.String attributeName,
                                     java.lang.String attributeValue)

ensureTagListenersInitialised

private final void ensureTagListenersInitialised()

fireTagChanged

private void fireTagChanged()
fire tagChanged event


parse

private final void parse()
Given the raw javadoc tag content as the value parameter parses it and sets the parameter. If anything is malformed (not (foo="xxx")+), then nothing is set.


resetValue

private final void resetValue()