edu.harvard.hul.ois.jhove.module.html
Class JHOpenTag

java.lang.Object
  extended by edu.harvard.hul.ois.jhove.module.html.JHElement
      extended by edu.harvard.hul.ois.jhove.module.html.JHOpenTag

public class JHOpenTag
extends JHElement

Representation of a parsed HTML open tag, including its attributes. This arguable would better be called an element, but JHElement is the name of the abstract superclass.

Author:
Gary McGath

Field Summary
 java.util.List _attributes
          List of element attributes.
 java.lang.String _name
          Element name.
 
Fields inherited from class edu.harvard.hul.ois.jhove.module.html.JHElement
_column, _line
 
Constructor Summary
JHOpenTag(java.util.List elements, java.lang.String name, java.util.List attrs, int line, int column)
          Constructor.
JHOpenTag(java.util.List elements, java.lang.String name, java.util.List attrs, int line, int column, java.lang.String message)
          Constructor with error message.
JHOpenTag(java.lang.String name)
          Constructor for a stub attribute.
 
Method Summary
protected  void advanceIndex()
          Increments the value of _contentIdx
protected  boolean allowsTag(java.lang.String tag, HtmlDocDesc doc)
          Returns true if the tag given in the parameter is allowable in our context.
protected  boolean canAdvance()
          Reports whether it's legal to advance to the next content index.
protected  boolean canGetMore()
          Checks if we can accept another element at the current content index.
protected  void countComponent()
          Counts off a component at the current index.
 java.util.List getAttributes()
          Returns the tag's attributes.
 HtmlTagDesc getElement()
          Returns the element definition which has been associated with this tag.
protected  java.lang.String getErrorMessage()
          Returns the error message associated with this element.
 java.lang.String getName()
          Returns the tag's name.
protected  void processElement(HtmlMetadata mdata)
          Process the element to extract any available metadata.
 void setElement(HtmlTagDesc element)
          Associates an the tag with an element definition.
 
Methods inherited from class edu.harvard.hul.ois.jhove.module.html.JHElement
getColumn, getEntities, getLine
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_name

public java.lang.String _name
Element name. Fields are made public to avoid overcomplicating the .jj file


_attributes

public java.util.List _attributes
List of element attributes. Each attributes is an array of two strings, the name and the value. If no explicit value was given, attribute[1] is null. If the attribute was in quotes, the quotes are still there.

Constructor Detail

JHOpenTag

public JHOpenTag(java.util.List elements,
                 java.lang.String name,
                 java.util.List attrs,
                 int line,
                 int column)
Constructor.

Parameters:
elements - The list of parsed elements, to which this gets added. May be null for a stub element not generated by the parser.
name - The name of the tag
attrs - A List of attributes, representing the parsed attributes of the tag. Each attributes is an array of two strings, the name and the value. If no explicit value was given, attribute[1] is null. If the attribute was in quotes, the quotes are still there.
line - Line number, for information reporting
column - Line number, for information reporting

JHOpenTag

public JHOpenTag(java.util.List elements,
                 java.lang.String name,
                 java.util.List attrs,
                 int line,
                 int column,
                 java.lang.String message)
Constructor with error message. This is used to allow constructs which are erroneous but common -- specifically, the closing of a tag with "/>".

Parameters:
elements - The list of parsed elements, to which this gets added. May be null for a stub element not generated by the parser.
name - The name of the tag
attrs - A List of attributes, representing the parsed attributes of the tag. Each attributes is an array of two strings, the name and the value. If no explicit value was given, attribute[1] is null. If the attribute was in quotes, the quotes are still there.
message - An error message indicating that this element isn't well-formed, but we'll take it anyway.

JHOpenTag

public JHOpenTag(java.lang.String name)
Constructor for a stub attribute. This shouldn't ever be used by the parser, but only by the module for generating implied elements.

Method Detail

setElement

public void setElement(HtmlTagDesc element)
Associates an the tag with an element definition. This is done by the HTML module, not by the parser.


getElement

public HtmlTagDesc getElement()
Returns the element definition which has been associated with this tag.


getName

public java.lang.String getName()
Returns the tag's name.


getAttributes

public java.util.List getAttributes()
Returns the tag's attributes.

Returns:
The attributes as a List. Each attributes is an array of two strings, the name and the value. If no explicit value was given, attribute[1] is null. If the attribute was in quotes, the quotes are still there.

processElement

protected void processElement(HtmlMetadata mdata)
Process the element to extract any available metadata.


allowsTag

protected boolean allowsTag(java.lang.String tag,
                            HtmlDocDesc doc)
Returns true if the tag given in the parameter is allowable in our context.


canGetMore

protected boolean canGetMore()
Checks if we can accept another element at the current content index.


countComponent

protected void countComponent()
Counts off a component at the current index.


advanceIndex

protected void advanceIndex()
Increments the value of _contentIdx


canAdvance

protected boolean canAdvance()
Reports whether it's legal to advance to the next content index. The index is assumed to be legal, but the one to which it's trying to advance may not be.


getErrorMessage

protected java.lang.String getErrorMessage()
Returns the error message associated with this element. If it returns a non-null value, the tag is not well-formed, and the error should be reported.