Package Torello.HTML
Class Util.Count
- java.lang.Object
-
- Torello.HTML.Util.Count
-
- Enclosing class:
- Util
public static class Util.Count extends java.lang.Object
Hi-Lited Source-Code:- View Here: Torello/HTML/Util.java
- Open New Browser-Tab: Torello/HTML/Util.java
File Size: 8,905 Bytes Line Count: 221 '\n' Characters Found
Stateless Class:This class neither contains any program-state, nor can it be instantiated. The@StaticFunctional
Annotation may also be called 'The Spaghetti Report'.Static-Functional
classes are, essentially, C-Styled Files, without any constructors or non-static member fields. It is a concept very similar to the Java-Bean's@Stateless
Annotation.
- 1 Constructor(s), 1 declared private, zero-argument constructor
- 12 Method(s), 12 declared static
- 0 Field(s)
-
-
Method Summary
Count CommentNode instances Modifier and Type Method static int
commentNodes(Vector<HTMLNode> page)
static int
commentNodes(Vector<HTMLNode> page, int sPos, int ePos)
static int
commentNodes(Vector<HTMLNode> page, DotPair dp)
Count TagNode instances Modifier and Type Method static int
tagNodes(Vector<HTMLNode> page)
static int
tagNodes(Vector<HTMLNode> page, int sPos, int ePos)
static int
tagNodes(Vector<HTMLNode> page, DotPair dp)
Count TextNode intances Modifier and Type Method static int
textNodes(Vector<HTMLNode> page)
static int
textNodes(Vector<HTMLNode> page, int sPos, int ePos)
static int
textNodes(Vector<HTMLNode> page, DotPair dp)
Count all New-Lines Modifier and Type Method static int
newLines(Vector<? extends HTMLNode> html)
static int
newLines(Vector<? extends HTMLNode> html, int sPos, int ePos)
static int
newLines(Vector<? extends HTMLNode> html, DotPair dp)
-
-
-
Method Detail
-
textNodes
public static int textNodes(java.util.Vector<HTMLNode> page, int sPos, int ePos)
Counts the number ofTextNode's
in aVector<HTMLNode>
between the demarcated array /Vector
positions,'sPos'
and'ePos'
- Parameters:
page
- Any HTML page.sPos
- This is the (integer)Vector
-index that sets a limit for the left-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'inclusive' meaning that theHTMLNode
at thisVector
-index will be visited by this method.
NOTE: If this value is negative, or larger than the length of the input-Vector
, an exception will be thrown.ePos
- This is the (integer)Vector
-index that sets a limit for the right-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'exclusive' meaning that the'HTMLNode'
at thisVector
-index will not be visited by this method.
NOTE: If this value is larger than the size of input theVector
-parameter, an exception will throw.
ALSO: Passing a negative value to this parameter,'ePos'
, will cause its value to be reset to the size of the inputVector
-parameter.- Returns:
- The number of
TextNode's
in theVector
between the demarcated indices. - Throws:
java.lang.IndexOutOfBoundsException
- This exception shall be thrown if any of the following are true:- If
'sPos'
is negative, or ifsPos
is greater-than-or-equal-to thesize
of theVector
- If
'ePos'
is zero, or greater than the size of theVector
- If the value of
'sPos'
is a larger integer than'ePos'
. If'ePos'
was negative, it is first reset toVector.size()
, before this check is done.
- If
- Code:
- Exact Method Body:
int counter = 0; LV l = new LV(page, sPos, ePos); // Iterates the entire page between sPos and ePos, incrementing the count for every // instance of text-node. for (int i=l.start; i < l.end; i++) if (page.elementAt(i).isTextNode()) counter++; return counter;
-
commentNodes
public static int commentNodes(java.util.Vector<HTMLNode> page)
-
commentNodes
public static int commentNodes(java.util.Vector<HTMLNode> page, DotPair dp)
-
commentNodes
public static int commentNodes(java.util.Vector<HTMLNode> page, int sPos, int ePos)
Counts the number ofCommentNode's
in anVector<HTMLNode>
between the demarcated array /Vector
positions.- Parameters:
page
- Any HTML page.sPos
- This is the (integer)Vector
-index that sets a limit for the left-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'inclusive' meaning that theHTMLNode
at thisVector
-index will be visited by this method.
NOTE: If this value is negative, or larger than the length of the input-Vector
, an exception will be thrown.ePos
- This is the (integer)Vector
-index that sets a limit for the right-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'exclusive' meaning that the'HTMLNode'
at thisVector
-index will not be visited by this method.
NOTE: If this value is larger than the size of input theVector
-parameter, an exception will throw.
ALSO: Passing a negative value to this parameter,'ePos'
, will cause its value to be reset to the size of the inputVector
-parameter.- Returns:
- The number of
CommentNode's
in theVector
between the demarcated indices. - Throws:
java.lang.IndexOutOfBoundsException
- This exception shall be thrown if any of the following are true:- If
'sPos'
is negative, or ifsPos
is greater-than-or-equal-to thesize
of theVector
- If
'ePos'
is zero, or greater than the size of theVector
- If the value of
'sPos'
is a larger integer than'ePos'
. If'ePos'
was negative, it is first reset toVector.size()
, before this check is done.
- If
- Code:
- Exact Method Body:
int counter = 0; LV l = new LV(page, sPos, ePos); // Iterates the entire page between sPos and ePos, incrementing the count for every // instance of comment-node. for (int i=l.start; i < l.end; i++) if (page.elementAt(i).isCommentNode()) counter++; return counter;
-
tagNodes
public static int tagNodes(java.util.Vector<HTMLNode> page, int sPos, int ePos)
Counts the number ofTagNode's
in aVector<HTMLNode>
between the demarcated array /Vector
positions.- Parameters:
page
- Any HTML page.sPos
- This is the (integer)Vector
-index that sets a limit for the left-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'inclusive' meaning that theHTMLNode
at thisVector
-index will be visited by this method.
NOTE: If this value is negative, or larger than the length of the input-Vector
, an exception will be thrown.ePos
- This is the (integer)Vector
-index that sets a limit for the right-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'exclusive' meaning that the'HTMLNode'
at thisVector
-index will not be visited by this method.
NOTE: If this value is larger than the size of input theVector
-parameter, an exception will throw.
ALSO: Passing a negative value to this parameter,'ePos'
, will cause its value to be reset to the size of the inputVector
-parameter.- Returns:
- The number of
TagNode's
in theVector
. - Throws:
java.lang.IndexOutOfBoundsException
- This exception shall be thrown if any of the following are true:- If
'sPos'
is negative, or ifsPos
is greater-than-or-equal-to thesize
of theVector
- If
'ePos'
is zero, or greater than the size of theVector
- If the value of
'sPos'
is a larger integer than'ePos'
. If'ePos'
was negative, it is first reset toVector.size()
, before this check is done.
- If
- Code:
- Exact Method Body:
int counter = 0; LV l = new LV(page, sPos, ePos); // Iterates the entire page between sPos and ePos, incrementing the count for every // instance of TagNode. for (int i=l.start; i < l.end; i++) if (page.elementAt(i).isTagNode()) counter++; return counter;
-
newLines
public static int newLines(java.util.Vector<? extends HTMLNode> html, int sPos, int ePos)
This will count the number of new-line symbols present - on the partial HTML page. The count will include a sum of everyHTMLNode.str
that contains the standard new-line symbols:\r\n, \r, \n
, meaning that UNIX, MSFT, Apple, etc. forms of text-line rendering should all be treated equally.- Parameters:
html
- This may be any Vectorized-HTML Web-Page (or sub-page).
The Variable-Type Wild-Card Expression'? extends HTMLNode'
means that aVector<TagNode>, Vector<TextNode>
orVector<CommentNode>
will all be accepted by this paramter without causing an exception throw.
These 'sub-type' Vectors are often returned as search results from the classes in the'NodeSearch'
vpackage.sPos
- This is the (integer)Vector
-index that sets a limit for the left-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'inclusive' meaning that theHTMLNode
at thisVector
-index will be visited by this method.
NOTE: If this value is negative, or larger than the length of the input-Vector
, an exception will be thrown.ePos
- This is the (integer)Vector
-index that sets a limit for the right-mostVector
-position to inspect/search inside the inputVector
-parameter.
This value is considered 'exclusive' meaning that the'HTMLNode'
at thisVector
-index will not be visited by this method.
NOTE: If this value is larger than the size of input theVector
-parameter, an exception will throw.
ALSO: Passing a negative value to this parameter,'ePos'
, will cause its value to be reset to the size of the inputVector
-parameter.- Returns:
- The number of new-line characters in all of the
HTMLNode's
that occur between vectorized-page positions'sPos'
and'ePos.'
NOTE: The regular-expression used here 'NEWLINEP' is as follows:
private static final Pattern NEWLINEP = Pattern.compile("\\r\\n|\\r|\\n");
- Throws:
java.lang.IndexOutOfBoundsException
- This exception shall be thrown if any of the following are true:- If
'sPos'
is negative, or ifsPos
is greater-than-or-equal-to thesize
of theVector
- If
'ePos'
is zero, or greater than the size of theVector
- If the value of
'sPos'
is a larger integer than'ePos'
. If'ePos'
was negative, it is first reset toVector.size()
, before this check is done.
- If
- See Also:
StringParse.NEWLINEP
- Code:
- Exact Method Body:
int newLineCount = 0; LV l = new LV(html, sPos, ePos); for (int i=l.start; i < l.end; i++) // Uses the Torello.Java.StringParse "New Line RegEx" for ( Matcher m = StringParse.NEWLINEP.matcher(html.elementAt(i).str); m.find(); newLineCount++); return newLineCount;
-
-