[Htmlparser-cvs] htmlparser/src/org/htmlparser/tags Tag.java,1.26,1.27
Brought to you by:
derrickoswald
|
From: <po...@us...> - 2003-05-22 00:36:18
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags
In directory sc8-pr-cvs1:/tmp/cvs-serv7363/src/org/htmlparser/tags
Modified Files:
Tag.java
Log Message:
- Tag now remembers (in tagLines) *all* the lines spanned by the tag (not just the last one).
- Tag now remembers line number on which tag starts (from TagData).
- Tag now has new public methods:
int getTagStartLine()
int getTagEndLine()
String[] getTagLines()
- TagParser now gives Tag (via constructor and setTagLine) sufficient info to support the above.
Index: Tag.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tags/Tag.java,v
retrieving revision 1.26
retrieving revision 1.27
diff -C2 -d -r1.26 -r1.27
*** Tag.java 19 May 2003 02:49:58 -0000 1.26
--- Tag.java 22 May 2003 00:36:15 -0000 1.27
***************
*** 53,65 ****
{
public static final String TYPE = "TAG";
! /**
! * Constant used as value for the value of the tag name
! * in parseParameters (Kaarle Kaila 3.8.2001)
! */
! public final static String TAGNAME = "$<TAGNAME>$";
! public final static String EMPTYTAG = "$<EMPTYTAG>$";
private final static int TAG_BEFORE_PARSING_STATE=1;
! private final static int TAG_BEGIN_PARSING_STATE=2;
! private final static int TAG_FINISHED_PARSING_STATE=3;
private final static int TAG_ILLEGAL_STATE=4;
private final static int TAG_IGNORE_DATA_STATE=5;
--- 53,65 ----
{
public static final String TYPE = "TAG";
! /**
! * Constant used as value for the value of the tag name
! * in parseParameters (Kaarle Kaila 3.8.2001)
! */
! public final static String TAGNAME = "$<TAGNAME>$";
! public final static String EMPTYTAG = "$<EMPTYTAG>$";
private final static int TAG_BEFORE_PARSING_STATE=1;
! private final static int TAG_BEGIN_PARSING_STATE=2;
! private final static int TAG_FINISHED_PARSING_STATE=3;
private final static int TAG_ILLEGAL_STATE=4;
private final static int TAG_IGNORE_DATA_STATE=5;
***************
*** 71,82 ****
/**
* Tag contents will have the contents of the comment tag.
! */
protected StringBuffer tagContents;
private boolean emptyXmlTag = false;
/**
! * tag parameters parsed into this hashtable
! * not implemented yet
! * added by Kaarle Kaila 23.10.2001
! */
protected Hashtable attributes=null;
--- 71,82 ----
/**
* Tag contents will have the contents of the comment tag.
! */
protected StringBuffer tagContents;
private boolean emptyXmlTag = false;
/**
! * tag parameters parsed into this hashtable
! * not implemented yet
! * added by Kaarle Kaila 23.10.2001
! */
protected Hashtable attributes=null;
***************
*** 88,91 ****
--- 88,101 ----
private java.lang.String tagLine;
+ /**
+ * The combined text of all the lines spanned by this tag
+ */
+ private String[] tagLines;
+
+ /**
+ * The line number on which this tag starts
+ */
+ private int startLine;
+
/**
* Set of tags that breaks the flow.
***************
*** 135,141 ****
--- 145,153 ----
{
super(tagData.getTagBegin(),tagData.getTagEnd());
+ this.startLine = tagData.getStartLine();
this.tagContents = new StringBuffer();
this.tagContents.append(tagData.getTagContents());
this.tagLine = tagData.getTagLine();
+ this.tagLines = new String[] {tagData.getTagLine()};
this.emptyXmlTag = tagData.isEmptyXmlTag();
}
***************
*** 224,227 ****
--- 236,247 ----
/**
+ * Returns the combined text of all the lines spanned by this tag
+ * @return java.lang.String
+ */
+ public String[] getTagLines() {
+ return tagLines;
+ }
+
+ /**
* Return the text contained in this tag
*/
***************
*** 265,269 ****
return (ret.toString ());
}
!
/**
* Scan the tag to see using the registered scanners, and attempt identification.
--- 285,289 ----
return (ret.toString ());
}
!
/**
* Scan the tag to see using the registered scanners, and attempt identification.
***************
*** 341,345 ****
this.nodeEnd = tagEnd;
}
!
/**
* Gets the nodeEnd.
--- 361,365 ----
this.nodeEnd = tagEnd;
}
!
/**
* Gets the nodeEnd.
***************
*** 350,356 ****
}
! public void setTagLine(java.lang.String newTagLine) {
! tagLine = newTagLine;
! }
public void setText(String text) {
--- 370,401 ----
}
! /**
! * Gets the line number on which this tag starts.
! * @return the start line number
! */
! public int getTagStartLine() {
! return startLine;
! }
!
! /**
! * Gets the line number on which this tag ends.
! * @return the end line number
! */
! public int getTagEndLine() {
! return startLine + tagLines.length - 1;
! }
!
! public void setTagLine(java.lang.String newTagLine) {
! tagLine = newTagLine;
!
! // Note: Incur the overhead of resizing each time (versus
! // preallocating a larger array), since the average tag
! // generally doesn't span multiple lines
! String[] newTagLines = new String[tagLines.length + 1];
! for (int i = 0; i < tagLines.length; i++)
! newTagLines[i] = tagLines[i];
! newTagLines[tagLines.length] = newTagLine;
! tagLines = newTagLines;
! }
public void setText(String text) {
|