Package Torello.HTML
Class InnerTags
- java.lang.Object
-
- Torello.HTML.InnerTags
-
public class InnerTags extends java.lang.Object
"Inner-Tags", a synonym for "Attributes" allows a user to do some aggregrate searches for the types of attributes in Vectorized-HTML.
This class was derived from information that is printed on the web-site "W3Schools.com" At first glance it appears to be a rather detailed amount of information, although that is contained within the data-structures are lists of HTML Element Attributes (Inner-Tags). These inner-tags are kept in an internal class for the primary reason that on occasion a user or programmer may wish to check if a web-page has any HTML Elements that have "non-standard" attributes. Many of the more modern web-sites on the internet contain HTML Elements that are proprietary and invented. This is not "against the rules" - and browsers will contain to parse and render a web-page that has non-standard HTML elements. In fact, using many implementations of Java-Script libraries will allow script to update elements after being rendered by the browser.
-
-
Field Summary
Fields Modifier and Type Field protected static TreeMap<String,
String>attributeDescriptions
protected static TreeSet<String>
attributes
protected static TreeMap<String,
String>eventAttributeDescriptions
protected static TreeMap<String,
String>eventAttributes
-
Method Summary
General Methods Modifier and Type Method static String
aDescription(String innerTag)
static String
description(String innerTag)
static boolean
has(String innerTag)
static boolean
hasAttribute(String innerTag)
static void
loadDescriptions()
Modify Internal Attribute-Table Modifier and Type Method void
addAttributes(String... attribs)
int
removeAttributes(String... attribs)
List Internal Attribute-Table Modifier and Type Method static Iterator<Map.Entry<String,
String>>attributeAndDescriptionsIterator()
static Iterator<String>
attributeIterator()
Print Internal Attribute-Table Modifier and Type Method static void
printAll(Appendable a, boolean printDescriptions)
static void
printAllToTerminal(boolean printDescriptions)
Methods: Event Attributes Modifier and Type Method static String[]
eventAttributes(Properties tnAllAV)
static Ret2<TagNodeIndex[],
String[][]>eventAttributes(Vector<? super TagNode> html)
static Ret2<TagNodeIndex[],
String[][]>eventAttributes(Vector<? super TagNode> html, int sPos, int ePos)
Methods: Non-Standard Attributes Modifier and Type Method static String[]
nonStandardAttributes(Properties tnAllAV)
static Ret2<TagNodeIndex[],
String[][]>nonStandardAttributes(Vector<? super TagNode> html)
static Ret2<TagNodeIndex[],
String[][]>nonStandardAttributes(Vector<? super TagNode> html, int sPos, int ePos)
Internal Event-Attributes Table Modifier and Type Method static String
eaDescription(String innerTag)
static Iterator<Map.Entry<String,
String>>eventAttributeAndCategoriesIterator()
static Iterator<Map.Entry<String,
String>>eventAttributeAndDescriptionsIterator()
static Iterator<String>
eventAttributeIterator()
static boolean
hasEventAttribute(String innerTag)
Modify Internal Event-Attributes Table Modifier and Type Method void
addEventAttributes(String... eventAttribs)
int
removeEventAttributes(String... eventAttribs)
-
-
-
Field Detail
-
attributes
protected static final java.util.TreeSet<java.lang.String> attributes
This is an internal data-structure that shall contain a list of all Standard HTML 5attributes
. This list was scraped from the sitew3schools.com
, and it isn't guaranteed to contain every possibly proprietary, alternate, deprecated, or (generally) "invented" HTML attribute. Instead, this is a "Best Efforts" approach, and this class offers a good API for modifying these lists to accommodate an ever changingHTML Attribute Space
.
NOTE: This internalTreeSet<String>
is loaded from the internal Java HTML JAR Distribution as soon as this class is loaded by theClass Loader
.
Java HTML Jar Distribution: The contents of the data-file which is included in theJava HTML Jar Distribution
that loads thisTreeSet
may be viewed here:Standard HTML Attributes
- Code:
- Exact Field Declaration Expression:
@SuppressWarnings("unchecked") protected static final TreeSet<String> attributes = (TreeSet<String>) d.elementAt(0);
-
eventAttributes
protected static final java.util.TreeMap<java.lang.String,java.lang.String> eventAttributes
This is an internal data-structure that shall contain a list of all Standard HTML 'Event'attributes
. This list was scraped from the sitew3schools.com
, and no guarantees that every HTML'Listener'
is contained in this data-set. This is a "Best Efforts" approach, and if a particularlistener-attribute
needs to be added or removed from the data-set, there is a good API for modifying the contents of this List.
NOTE: This list is stored as aTreeMap
, rather than aTreeSet
, because associated with each of theseJava-Script Listener Attribute Names
is a 'category' that indicates what type of'listener'
the namedattribute
is.
NOTE: This internalTreeSet<String>
is loaded from the internal Java HTML JAR Distribution as soon as this class is loaded by theClass Loader
.
Java HTML Jar Distribution: The contents of the data-file which is included in theJava HTML Jar Distribution
that loads thisTreeMap
may be viewed here:- Code:
- Exact Field Declaration Expression:
@SuppressWarnings("unchecked") protected static final TreeMap<String, String> eventAttributes = (TreeMap<String, String>) d.elementAt(1);
-
attributeDescriptions
protected static final java.util.TreeMap<java.lang.String,java.lang.String> attributeDescriptions
ThisTreeMap
contains a short, descriptive, text-String
describing each of theattributes
in theattributes TreeSet
. ThisTreeMap
is not automatically loaded by theClass Loader
. Unless the user explicitly asks for a text-description of anattribute
, thisTreeMap
shall remain empty (and the description-String's
which populate thisTreeMap
shall remain on-disk / in theJAR File
).
Java HTML Jar Distribution: The contents of the data-file which is included in theJava HTML Jar Distribution
that loads thisTreeMap
may be viewed here:Standard Attribute Descriptions
- Code:
- Exact Field Declaration Expression:
protected static final TreeMap<String, String> attributeDescriptions = new TreeMap<>();
-
eventAttributeDescriptions
protected static final java.util.TreeMap<java.lang.String,java.lang.String> eventAttributeDescriptions
ThisTreeMap
contains a short, descriptive, text-String
describing each of theevent-attributes
in theevent-attributes TreeSet
. ThisTreeMap
is not automatically loaded by theClass Loader
. Unless the user explicitly asks for a text-description of anattribute
, thisTreeMap
shall remain empty. (and the description-String's
which populate thisTreeMap
shall remain on-disk / in theJAR File
).
Java HTML Jar Distribution: The contents of the data-file which is included in theJava HTML Jar Distribution
that loads thisTreeMap
may be viewed here:Event Attribute Descriptions
- Code:
- Exact Field Declaration Expression:
protected static final TreeMap<String, String> eventAttributeDescriptions = new TreeMap<>();
-
-
Method Detail
-
addAttributes
public void addAttributes(java.lang.String... attribs)
Inserts newattributes
into the internally stored list ofattributes
.
VAR ARGS: This method will over-write theString's
passed to the Var-Args parameterattribs
to ensure that all of theString's
are, indeed, in lower case format.
Data File Contents: At the time ofClass Loading
, what the exact contents of the internal data structure lists ofAttributes
are, is provided below:- Parameters:
attribs
- This var-argsString[]
parameter accepts a list of newattributes
.- Throws:
java.lang.IllegalArgumentException
- If theattributes
provided contain duplicates in the list, itself, or if the internally stored 'attributes'TreeSet<String>
already contains one of theseattributes
.java.lang.NullPointerException
- If any of theattributes
inside the var-args parameter are null.- See Also:
removeAttributes(String[])
,attributeIterator()
,attributes
- Code:
- Exact Method Body:
// All attributes are stored in lower-case format for (int i=0; i < attribs.length; i++) attribs[i] = attribs[i].toLowerCase(); // It is always better to test input for errors. Here, check that the attributes provided // are not already members of the internal TreeMap<String, String> for (String a : attribs) if (attributes.contains(a)) throw new IllegalArgumentException( "You are attempting to insert an attribute [" + a + "] which is already a member of " + "the attributes list." ); // Insert the event-attribute. Provide a standard "Event Type", and a "Blank" Description // (Zero-Length String) for (String a : attribs) if (attributes.add(a)) throw new IllegalArgumentException( "Failed to insert an attribute: [" + a + "]. You have attempted to insert the " + "same inner-tag twice." ); // Standard Description else attributeDescriptions.put(a, "User-Provided Attribute");
-
addEventAttributes
public void addEventAttributes(java.lang.String... eventAttribs)
Inserts newattributes
into the internally stored list of"Event Attributes"
.
VAR ARGS: This method will over-write theString's
passed to the Var-Args parametereventAttribs
to ensure that all of theString's
are, indeed, in lower case format.
Data File Contents: At the time ofClass Loading
, what the exact contents of the internal data structure lists ofEvent Attributes
are, is provided below:- Parameters:
eventAttribs
- This var-argsString[]
parameter accepts a list of new listenerattributes
- Throws:
java.lang.IllegalArgumentException
- If theattributes
provided contain duplicates in the list, itself, or if the internally stored 'attributes'TreeMap<String, String>
already contains one of theseattributes
as a key element.java.lang.NullPointerException
- If any of theevent-attributes
named by the var-args parameter are null.- See Also:
removeEventAttributes(String[])
,eventAttributeIterator()
,eventAttributes
- Code:
- Exact Method Body:
// All attributes are stored in lower-case format for (int i=0; i < eventAttribs.length; i++) eventAttribs[i] = eventAttribs[i].toLowerCase(); // It is always better to test input for errors. Here, check that the attributes provided // are not already members of the internal TreeMap<String, String> for (String ea : eventAttribs) if (eventAttributes.containsKey(ea)) throw new IllegalArgumentException( "You are attempting to insert an event-attribute [" + ea + "] which is already " + "a member of the event-attributes list." ); // Insert the event-attribute. Provide a standard "Event Type", and a "Blank" Description // (Zero-Length String) for (String ea : eventAttribs) if (eventAttributes.put(ea, "User-Added") != null) // Standard "User-Added" type. throw new IllegalArgumentException( "Failed to insert an event-attribute: [" + ea + "]. You have attempted to " + "insert the same inner-tag twice." ); // Standard Description else eventAttributeDescriptions.put(ea, "User-Provided Event Attribute");
-
removeAttributes
public int removeAttributes(java.lang.String... attribs)
Removesattributes
from the internally stored list ofattributes
.
Data File Contents: At the time ofClass Loading
, what the exact contents of the internal data structure lists ofAttributes
are, is provided by below:- Parameters:
attribs
- This var-argsString[]
parameter accepts a list of already definedattributes
.- Returns:
- This simply returns a count of the number of
attributes
that were successfully removed from the internalattributes
data structures. (This is equal to the number ofattributes
passed via parameter'attribs'
that were actually already defined in the internal data structures) - See Also:
addAttributes(String[])
,attributeIterator()
,attributes
- Code:
- Exact Method Body:
int count = 0; // All attributes are stored in lower-case format for (int i=0; i < attribs.length; i++) { String attrib = attribs[i].toLowerCase(); if (attributes.remove(attrib)) { count++; attributeDescriptions.remove(attrib); } } return count;
-
removeEventAttributes
public int removeEventAttributes(java.lang.String... eventAttribs)
Removesattributes
from the internally stored list of"Event Attributes"
Data File Contents: At the time ofClass Loading
, what the exact contents of the internal data structure lists ofEvent Attributes
are, is provided below:- Parameters:
eventAttribs
- This var-argsString
parameter accepts a list of already definedlistener attributes
.- Returns:
- This simply returns a count of the number of
event attributes
that were successfully removed from the internalevent attributes
data structures. (This is equal to the number ofevent attributes
passed via parameter'eventAttribs'
that were actually already defined in the internal data structures) - See Also:
addEventAttributes(String[])
,eventAttributeIterator()
,eventAttributes
- Code:
- Exact Method Body:
int count = 0; // All attributes are stored in lower-case format for (int i=0; i < eventAttribs.length; i++) { String eventAttrib = eventAttribs[i].toLowerCase(); if (eventAttributes.remove(eventAttrib) != null) { count++; eventAttributeDescriptions.remove(eventAttrib); } } return count;
-
printAllToTerminal
public static void printAllToTerminal(boolean printDescriptions)
- Code:
- Exact Method Body:
try { printAll(System.out, printDescriptions); } catch (IOException e) { }
-
printAll
public static void printAll(java.lang.Appendable a, boolean printDescriptions) throws java.io.IOException
This simply prints all data that is stored in the JAR data-files to an instance of'Appendable'
- Parameters:
a
- This is parameter may not be a null, or aNullPointerException
will throw. This the target-receiver for the text-output of this method. This parameter expects an implementation of Java'sinterface java.lang.Appendable
which allows for a wide range of options when logging intermediate messages.Class or Interface Instance Use & Purpose 'System.out'
Sends text to the standard-out terminal Torello.Java.StorageWriter
Sends text to System.out
, and saves it, internally.FileWriter, PrintWriter, StringWriter
General purpose java text-output classes FileOutputStream, PrintStream
More general-purpose java text-output classes
IMPORTANT: Theinterface Appendable
requires that the check exceptionIOException
must be caught when using itsappend(CharSequence)
methods.printDescriptions
- When this parameter is TRUE, then (first) this method will ensure that the JAR Descriptions-Data-File is been loaded into memory. If it has not, then the description-String's
will be loaded from disk. TheseString's
contain a one-sentence-long text-description of each attribute / inner-tag listed in this class. They are not normally loaded by the Class-Loader for this class, unless specifically requested.
If this parameter is passed FALSE, then the data-file will not be visited, and the attribute-descriptions will not be sent to the output stream.- Throws:
java.io.IOException
- The general purpose interface'java.lang.Appendable'
throws anIOException
when printing information. If theAppendable
provided to this method fails, this exception shall propagate out.- See Also:
attributes
,eventAttributes
,attributeDescriptions
,eventAttributeDescriptions
- Code:
- Exact Method Body:
if (! printDescriptions) { a.append("NON-EVENT ATTRIBUTES: "); for (String attribute : attributes) a.append(attribute + ", "); a.append("\n\nEVENT ATTRIBUTES: "); for (String attribute : eventAttributes.keySet()) a.append(attribute + " (" + eventAttributes.get(attribute) + "), "); } else { loadDescriptions(); a.append("NON-EVENT ATTRIBUTES:\n"); for (String attribute : attributes) a.append( String.format("%-" + 20 + "s", attribute) + attributeDescriptions.get(attribute) + "\n" ); a.append("\nEVENT ATTRIBUTES:\n"); for (String attribute : eventAttributes.keySet()) a.append( String.format("%-" + 20 + "s", attribute) + "[" + String.format("%-" + 20 + "s", eventAttributes.get(attribute) + "] ") + eventAttributeDescriptions.get(attribute) + "\n" ); }
-
loadDescriptions
public static void loadDescriptions()
This method will visit the (small) data-file's that are included in the JAR-file distribution of the Java-HTML library. The data-file will only be loaded if the two tree data-structures have not already been loaded into memory. These are "descriptiveString
definitions" for each of the attributes stored here. The descriptions themselves were all scraped from theURL's
listed below. They were scraped on April 7th, 2020 - and the definitions have been word-for-word copied from theseURL's.
URL url1 = new URL("https://www.w3schools.com/tags/ref_attributes.asp"); URL url2 = new URL("https://www.w3schools.com/tags/ref_eventattributes.asp");
- See Also:
LFEC.readObjectFromFile_JAR(java.lang.Class<?>, java.lang.String, boolean, java.lang.Class<T>)
,attributeAndDescriptionsIterator()
,eventAttributeAndDescriptionsIterator()
,attributeDescriptions
,eventAttributeDescriptions
- Code:
- Exact Method Body:
if ((attributeDescriptions.size() == 0) || (eventAttributeDescriptions.size() == 0)) { Vector<Object> d = (Vector<Object>) LFEC.readObjectFromFile_JAR (Torello.Data.DataFileLoader.class, "data13.vdat", true, Vector.class); attributeDescriptions.putAll((TreeMap<String, String>) d.elementAt(0)); eventAttributeDescriptions.putAll((TreeMap<String, String>) d.elementAt(1)); }
-
attributeIterator
public static java.util.Iterator<java.lang.String> attributeIterator()
Internally, "Attributes" are stored in a Javajava.util.TreeSet<String>
. This method invokes theTreeSet.iterator()
.
REMOVE NOTE: In order to prevent accidental removal of the attributes via theIterator.remove()
Method, the'Iterator<String>'
class has been overloaded - "wrapped" - in a simple class that throws an exception ifremove()
is invoked. The purpose is to prevent a user from accidentally removing a member of the internal-set data-structure.- Returns:
- an
Iterator
that cycles through the list of Attribute-String's
stored in this class.
Data File Contents: The contents of thisIterator
are loaded from a (small) internal data-file stored in the JAR Distribution for this Java HTML Package. The contents of this data-file (and the list ofString's
returned by theIterator
) may be viewed, here, by clicking the link below:
Attributes
- See Also:
RemoveUnsupportedIterator
,addAttributes(String[])
,removeAttributes(String[])
,attributes
- Code:
- Exact Method Body:
return new RemoveUnsupportedIterator<String>(attributes.iterator());
-
eventAttributeIterator
public static java.util.Iterator<java.lang.String> eventAttributeIterator()
Internally, "Event-Attributes" are stored in a Javajava.util.TreeMap<String, String>
. This method invokes theTreeMap.iterator()
method. TheTreeMap
has a key-set that contains allevent-attributes
mapped to the category of events they are related to. To retrieve the "event-type" information related to any particular event-attribute returned from thisIterator
, just invoke thewhatEventType(String eventAttribute)
method.
NOTE:Event-Attributes
are also referred to as Listeners or Java-Script Listeners and have names like'onload', 'onclick', 'onmouseover'
etc...
REMOVE NOTE: In order to prevent accidental removal of the listener-attributes via theIterator.remove()
Method, theclass Iterator<String>
has been overloaded - "wrapped" - in a simple class that throws an exception ifremove()
is invoked. The purpose is to prevent a user from accidentally removing a member of the internal-set data-structure.- Returns:
- an
Iterator
that cycles through the list of Attribute-String's
stored in this class.
Data File Contents: The contents of thisIterator
are loaded from a (small) internal data-file stored in the JAR Distribution for this Java HTML Package. The contents of this data-file (and the list ofString's
returned by theIterator
) may be viewed, here, by clicking the link below:
Event Attributes
- See Also:
RemoveUnsupportedIterator
,addEventAttributes(String[])
,removeEventAttributes(String[])
,eventAttributes
- Code:
- Exact Method Body:
return new RemoveUnsupportedIterator<String>(eventAttributes.keySet().iterator());
-
attributeAndDescriptionsIterator
public static java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> attributeAndDescriptionsIterator ()
Will build an iterate that can return attributes and their text-string descriptions.
DATA-FILE LOAD: This method will attempt to load a particular data-file from the JAR-library into memory. This file contains a one-sentence description, stored asjava.lang.String's
for each of the attributes and event-attributes known to this class. Under normal operation, these text arrays remain on-disk, only.
REMOVE NOTE: In order to prevent accidental removal of the attribute-descriptions viaIterator.remove()
,class Iterator<E>
has been overloaded - "wrapped" - in a simple class that throws an exception ifremove()
is invoked. The purpose is to prevent a user from accidentally removing a member of the internal-set data-structure.- Returns:
- An
Iterator
that iterates the Attribute-Description key-value pairs as instances of"Map.Entry<String, String>"
Data File Contents: The contents of thisIterator
are loaded from a (small) internal data-file stored in the JAR Distribution for this Java HTML Package. Load is only performed on request. The contents of this data-file (and the list ofMap.Entry's
returned by theIterator
) may be viewed, here, by clicking the link below:
Attributes and Descriptions
- See Also:
RemoveUnsupportedIterator
,attributeDescriptions
,loadDescriptions()
- Code:
- Exact Method Body:
// Loads the descriptions map, ONLY IF they have not already been loaded into memory // from the JAR data-files loadDescriptions(); return new RemoveUnsupportedIterator<Map.Entry<String, String>> (attributeDescriptions.entrySet().iterator());
-
eventAttributeAndDescriptionsIterator
public static java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> eventAttributeAndDescriptionsIterator ()
Will build an iterate that can return event-attributes and their text-string descriptions.
DATA-FILE LOAD: This method will attempt to load a particular data-file from the JAR-library into memory. This file contains a one-sentence description, stored asjava.lang.String's
for each of the attributes and event-attributes known to this class. Under normal operation, these text arrays remain on-disk, only.
REMOVE NOTE: In order to prevent accidental removal of the attributes-descriptions via the Iterator's "Remove" Method, the'Iterator<...>'
class has been overloaded - "wrapped" - in a simple class that throws an exception ifremove()
is invoked. The purpose is to prevent a user from accidentally removing a member of the internal-set data-structure.- Returns:
- An
Iterator
that iterates the Event-Attribute / Description key-value pairs as instances of"Map.Entry<String, String>"
Data File Contents: The contents of thisIterator
are loaded from a (small) internal data-file stored in the JAR Distribution for this Java HTML Package. Load is only performed on request. The contents of this data-file (and the list ofMap.Entry's
returned by theIterator
) may be viewed, here, by clicking the link below:
Event Attributes and Descriptions
- See Also:
RemoveUnsupportedIterator
,loadDescriptions()
,eventAttributeDescriptions
- Code:
- Exact Method Body:
// Loads the descriptions map, ONLY IF they have not already been loaded into memory from // the JAR data-files loadDescriptions(); return new RemoveUnsupportedIterator<Map.Entry<String, String>> (eventAttributeDescriptions.entrySet().iterator());
-
eventAttributeAndCategoriesIterator
public static java.util.Iterator<java.util.Map.Entry<java.lang.String,java.lang.String>> eventAttributeAndCategoriesIterator ()
Will build an iterate that can return event-attributes and their categories.
REMOVE NOTE: In order to prevent accidental removal of the attributes-descriptions via the Iterator's "Remove" Method, the'Iterator<...>'
class has been overloaded - "wrapped" - in a simple class that throws an exception ifremove()
is invoked. The purpose is to prevent a user from accidentally removing a member of the internal-set data-structure.- Returns:
- An
Iterator
that iterates the Event-Attribute / Category key-value pairs as instances of"Map.Entry<String, String>"
Data File Contents: The contents of thisIterator
are loaded from a (small) internal data-file stored in the JAR Distribution for this Java HTML Package. The contents of this data-file (and the list ofMap.Entry's
returned by theIterator
) may be viewed, here, by clicking the link below:
Event Attributes and Categories
- See Also:
RemoveUnsupportedIterator
,eventAttributes
- Code:
- Exact Method Body:
return new RemoveUnsupportedIterator<Map.Entry<String, String>> (eventAttributes.entrySet().iterator());
-
hasAttribute
public static boolean hasAttribute(java.lang.String innerTag)
Will report whether an attribute is listed as a well-defined attribute, according to HTML standards.
The Complete list ofattributes
that are stored in this class' internal data structure are listed in the link below:
Attributes
List Modification: The list ofHTML Attributes
may, in fact, be altered. To add a newHTML Attribute
to the internal lookup table of validAttributes
, useaddAttributes(String[])
. To remove anAttribute
from the internal list, useremoveAttributes(String[])
.- Parameters:
innerTag
- Throughout this package, the keywords "Attribute" and "InnerTag" are used interchangeably as best as is possible. This method will ask the internally storedjava.util.TreeSet<String>
if there is a well-defined attribute named by this parameter present in its tree-structure.- Returns:
- Will return TRUE if the internally stored
TreeSet<String>
contains this string. The comparison that's performed is case-insensitive, and internally all inner-tagString's
are stored in lower-case format. - See Also:
attributes
- Code:
- Exact Method Body:
return attributes.contains(innerTag.toLowerCase());
-
hasEventAttribute
public static boolean hasEventAttribute(java.lang.String innerTag)
Will report whether an event-attribute is listed as a well-defined event-attribute, according to HTML standards.
The Complete list ofevent attributes
that are stored in this class' internal data structure are listed in the link below:
Event Attributes
List Modification: The list ofHTML Event Attributes
may, in fact, be altered. To add a newHTML Event Attribute
to the internal lookup table of validEvent Attributes
, useaddEventAttributes(String[])
. To remove anEvent Attribute
from the internal list, useremoveEventAttributes(String[])
.- Parameters:
innerTag
- Throughout this package, the keywords "Attribute" and "InnerTag" are used interchangeably as best as is possible. This method will ask the internally storedjava.util.TreeMap<String, String>
if there is a well-defined event-attribute named by this parameter present in its tree-structure's key-set. The key each node in the tree corresponds to an event-attribute, and the value corresponds to the type-name of the event - for instance:'window-event', 'mouse-event', keyboard-event', etc...
. These are also known as "Java-Script Listeners".- Returns:
- Will return TRUE if the internally stored
TreeSet<String>
contains this string. The comparison that's performed is case-insensitive, and internally all inner-tagString's
are stored in lower-case format. - See Also:
eventAttributes
- Code:
- Exact Method Body:
return eventAttributes.containsKey(innerTag.toLowerCase());
-
has
public static boolean has(java.lang.String innerTag)
Will report whether an attribute is either a standard, well-defined, attribute or (also) if the inner-tag is a well-defined event-inner-tag.
The Complete list ofattributes
andevent attributes
stored in this class internal data structure are listed in the two links below:- Parameters:
innerTag
- This will ask both theTreeSet<String> 'attributes'
data-structure if the inner-tag is contained, and if not, it will ask if theTreeMap<String, String> 'eventAttributes'
data-structure contains the inner-tag. Before the tests are performed, this string is converted to lower-case format. Internally, all inner-tagString's
are stored in lower-case format- Returns:
- Will return TRUE if either of the two tree data-structures contain this inner-tag.
- See Also:
attributes
,eventAttributes
- Code:
- Exact Method Body:
innerTag = innerTag.toLowerCase(); // NOTE: Short-Circuit Boolean-Evaluation is always in effect when two '||' are used // instead of one '|' return attributes.contains(innerTag) || eventAttributes.containsKey(innerTag);
-
description
public static java.lang.String description(java.lang.String innerTag)
Provides the description stored in the JAR data-file for both standard inner-tags, and event-based inner-tags.
DATA-FILE LOAD: This method will attempt to load a particular data-file from the JAR-library into memory. This file contains a one-sentence description, stored asjava.lang.String's
for each of the attributes and event-attributes known to this class. Under normal operation, these text arrays remain on-disk, only.- Parameters:
innerTag
- This is the attribute whose description is sought. This may be either an regular attribute, or an event-attribute. Both tree data-structures will be searched.- Returns:
- The one-line text-description provided for this innerTag. The comparison that's
performed is case-insensitive, and internally all inner-tag
String's
are stored in lower-case format. - See Also:
attributeDescriptions
,eventAttributeDescriptions
- Code:
- Exact Method Body:
// Loads the descriptions map, ONLY IF they have not already been loaded // into memory from the JAR data-files loadDescriptions(); innerTag = innerTag.toLowerCase(); String desc; if ((desc = attributeDescriptions.get(innerTag)) != null) return desc; if ((desc = eventAttributeDescriptions.get(innerTag)) != null) return desc; return null;
-
aDescription
public static java.lang.String aDescription(java.lang.String innerTag)
Provides the description stored in the JAR data-file for standard inner-tags.
DATA-FILE LOAD: This method will attempt to load a particular data-file from the JAR-library into memory. This file contains a one-sentence description, stored asjava.lang.String's
for each of the attributes and event-attributes known to this class. Under normal operation, these text arrays remain on-disk, only.- Parameters:
innerTag
- This is the attribute whose description is sought. This must be a regular attribute, not an event-attribute. Only the former tree data-structure will be searched.- Returns:
- The one-line text-description provided for this innerTag. The comparison that's
performed is case-insensitive, and internally all inner-tag
String's
are stored in lower-case format. - See Also:
attributeDescriptions
,loadDescriptions()
- Code:
- Exact Method Body:
// Loads the descriptions map, ONLY IF they have not already been loaded into memory from // the JAR data-files loadDescriptions(); return attributeDescriptions.get(innerTag.toLowerCase());
-
eaDescription
public static java.lang.String eaDescription(java.lang.String innerTag)
Provides the description stored in the JAR data-file for event inner-tags.
DATA-FILE LOAD: This method will attempt to load a particular data-file from the JAR-library into memory. This file contains a one-sentence description, stored asjava.lang.String's
for each of the attributes and event-attributes known to this class. Under normal operation, these text arrays remain on-disk, only.- Parameters:
innerTag
- This is the attribute whose description is sought. This must be an event attribute, not an regular / standard attribute. Only the event-attribute tree data-structure will be searched. Event-attributes are usually also called Java-Script listeners.- Returns:
- The one-line text-description provided for this innerTag. The comparison that's
performed is case-insensitive, and internally all inner-tag
String's
are stored in lower-case format. - See Also:
eventAttributeDescriptions
,loadDescriptions()
- Code:
- Exact Method Body:
// Loads the descriptions map, ONLY IF they have not already been loaded into memory from // the JAR data-files loadDescriptions(); return eventAttributeDescriptions.get(innerTag.toLowerCase());
-
eventAttributes
public static java.lang.String[] eventAttributes (java.util.Properties tnAllAV)
Retrieves allevent-attributes
that are found within aTagNode java.util.Properties
list ofattributes
.
Default List Contents: The list of standard HTMLevent attributes
contained by the internalStandard HTML Event Attributes
data-set can be viewed here:
Event HTML Attributes
This internal data-structure may be modified at runtime using the following:- Parameters:
tnAllAV
- This should be an instance ofjava.util.Properties
that is properly generated by an invocation of the methodTagNode.allAV()
. Because these properties objects are not stored internally to TagNode, they are re-computed on each and every call to the method'allAV()'
, these calls can be expensive if included within a loop. For this reason, this method accepts an instance ofjava.util.Properties
, rather than theTagNode
itself.- Returns:
- This will return a list of any and all
HTML Element Attributes
that are listed in theEvent Attributes
Tree data-structure. This should indicate that anattribute
is a Java-Script Listener of some form.
NOTE ON NULL: This method shall never return 'null'. If none of theattributes
identified areEvent / Java-Script
listeners, then this method shall return a zero-lengthString-Array
. - See Also:
hasEventAttribute(String)
,TagNode.allAV()
- Code:
- Exact Method Body:
TreeSet<String> ret = new TreeSet<>(); // Parameter 'tnAllAV' is just the list of attributes returned by a call to // TagNode.allAV() - If any of these properties are listed in the internal data structure // for "Event Attributes", then they should be returned in the return-String-array for (String property : tnAllAV.stringPropertyNames()) if (hasEventAttribute(property)) ret.add(property); // Convert the TreeSet<String> to a (sorted) String[], and return String[] sArr = new String[ret.size()]; return ret.toArray(sArr);
-
nonStandardAttributes
public static java.lang.String[] nonStandardAttributes (java.util.Properties tnAllAV)
Retrieves all NON-STANDARDattributes
that are found within aTagNode java.util.Properties
list ofattributes
. The definition of a non standard HTMLattribute
, for the purposes of this method, is simply an HTMLattribute
whose name is NIETHER found in the internal data-structure listing allevent-attributes
, NOR IS FOUND within the internal data-structure of allHTML attributes
. These two data-structures (lists) may be viewed here:
Both of these internal data-structures may be modified at runtime using the following:- Parameters:
tnAllAV
- This should be an instance ofjava.util.Properties
that is properly generated by an invocation of the methodTagNode.allAV()
. Because these properties objects are not stored internally to TagNode, they are re-computed on each and every call to the method'allAV()'
, these calls can be expensive if included within a loop. For this reason, this method accepts an instance ofjava.util.Properties
, rather than theTagNode
itself.- Returns:
- This will return a list of any and all HTML Element Attributes that are not
listed among the standard attributes in the attribute
TreeSet
internal data-structure.
NOTE ON NULL: This method shall never return 'null'. If all attributes are well-known standard inner-tags, or event-inner-tags, then this method shall return a zero-lengthString-Array
. - See Also:
has(String)
,hasEventAttribute(String)
,TagNode.allAV()
,StrCmpr.startsWithIgnoreCase(String, String)
- Code:
- Exact Method Body:
TreeSet<String> ret = new TreeSet<>(); // Parameter 'tnAllAV' is just the list of attributes returned by a call to // TagNode.allAV() - If any of these properties are **NOT** listed in the internal data // structures for either "Event Attributes" or "(Regular) Attributes", then they should // be returned in the return-String-array for (String property : tnAllAV.stringPropertyNames()) if (! StrCmpr.startsWithIgnoreCase(property, "data-")) if ((! has(property)) && (! hasEventAttribute(property))) ret.add(property); // Convert the TreeSet<String> to a (sorted) String[], and return String[] sArr = new String[ret.size()]; return ret.toArray(sArr);
-
eventAttributes
public static Ret2<TagNodeIndex[],java.lang.String[][]> eventAttributes (java.util.Vector<? super TagNode> html)
- Code:
- Exact Method Body:
return eventAttributes(html, 0, -1);
-
eventAttributes
public static Ret2<TagNodeIndex[],java.lang.String[][]> eventAttributes (java.util.Vector<? super TagNode> html, int sPos, int ePos)
This method is intended to identify allTagNode
elements on an input page that possess "HTML Event Attributes."TagNode
elements that do match this criteria will be wrapped in aTagNodeIndex
and returned in a two partRet2
return array. The inner-tag event names will also be returned, using the {code class 'Ret2'} return data-structure.
Default List Contents: The list ofattributes
contained in theEvent HTML Attributes
internal data-set can be viewed here:
Event HTML Attributes
- Parameters:
html
- This is any vectorized-html web-page, or sub-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:
- Returns an instance of
Ret2
. The two elements of theRet2
construct will contain parallel arrays. These parallel arrays will have the following:-
Ret2.a (TagNodeIndex[])
This will have an array ofTagNodeIndex
elements. Each of these contain both theTagNode
that matched, and also the index into original htmlVector
-parameter where thatTagNode
was found.
-
Ret2.b (String[]][])
This is another array. It is parallel to the array inRet2.a
, and its contents, itself, is a an array of all the attributes that were"Event Listener"
attributes found in theTagNode
.
NOTE: This method is guaranteed not return 'null' values for either of these two arrays. If no event-inner-tag matches are found, theRet2
construct will return two zero-length arrays in fieldRet2.a
, andRet2.b
;
List Modification: If the list ofevent-attributes
being returned by this method are "leaving out" certainevent-attributes
, or on the contrary the returned lists are including otherevent-attributes
that should not be returned by this method ... TheHTML Event Attributes
internal data structures can be modified by calling: -
- 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
java.lang.ClassCastException
- If'html'
contains references that do not inheritHTMLNode
.- See Also:
LV
,eventAttributes(Properties)
,TagNode.tok
,TagNode.isClosing
,NodeIndex.n
,NodeIndex.index
,eventAttributes(Vector)
- Code:
- Exact Method Body:
Stream.Builder<TagNodeIndex> tniBuilder = Stream.builder(); // Builds a Stream<TagNode> Stream.Builder<String[]> sArrSBuilder = Stream.builder(); // Builds a Stream<String[]> LV l = new LV(sPos, ePos, html); Object o; TagNode tn; String[] sArr; // Iterate through the entire Vector. Find TagNode's with Attributes. Check if they // have "Event Attributes". If so, keep them in the list to be returned. for (int i=l.start; i < l.end; i++) if ( ((tn = ((HTMLNode) html.elementAt(i)).openTagPWA()) != null) && ((sArr = eventAttributes(tn.allAV())).length > 0) ) { // Save TagNodeIndex: "TagNode" (tn) plus "index" (i) tniBuilder.add(new TagNodeIndex(i, tn)); // Save String-Array sArrSBuilder.add(sArr); } // Build the two Stream.Builders to Stream... Convert Streams to Arrays... Return return new Ret2<TagNodeIndex[], String[][]>( // Build-Stream<TagNode>, Convert Stream to Array, put in Ret2.a tniBuilder.build().toArray(TagNodeIndex[]::new), // Build-Stream<String[]>, Convert Stream to Array, put in Ret2.b sArrSBuilder.build().toArray(String[][]::new) );
-
nonStandardAttributes
public static Ret2<TagNodeIndex[],java.lang.String[][]> nonStandardAttributes (java.util.Vector<? super TagNode> html)
- Code:
- Exact Method Body:
return nonStandardAttributes(html, 0, -1);
-
nonStandardAttributes
public static Ret2<TagNodeIndex[],java.lang.String[][]> nonStandardAttributes (java.util.Vector<? super TagNode> html, int sPos, int ePos)
This method is intended to identify allTagNode
elements on an input page that possess "non-standard HTML Attributes." AnyTagNode
elements that do match this criteria will be wrapped in aTagNodeIndex
and returned in a two partRet2
return array. The inner-tag event names will also be returned, using the {code class 'Ret2'} return data-structure.
Default List Contents: The list ofattributes
contained by the internalStandard HTML Attributes
data-set and theHTML Event Attributes
data-set can be viewed here:- Parameters:
html
- This is any vectorized-html web-page, or sub-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:
- Returns an instance of
Ret2
. The two elements of theRet2
construct will contain parallel arrays. These parallel arrays will have the following:-
Ret2.a (TagNodeIndex[])
This will have an array ofTagNodeIndex
elements. Each of these contain both theTagNode
that matched, and also the index into the original htmlVector
-parameter where thatTagNode
was found.
-
Ret2.b String[][]
This is another array. It is parallel to the array inRet2.a
, and its contents, itself, is an array of all the attributes that were identified in theTagNode
as"Non-Standard Attributes"
. Such (non-standard) attributes were NIETHER FOUND in theevent attributes
internal data-structure, NOR WERE THEY FOUND in theattributes
internal data-structure.
NOTE: This method is guaranteed not return 'null' values for either of these two arrays. If no non-standard inner-tag matches are found, theRet2
construct will return two zero-length arrays in fieldRet2.a
, andRet2.b
;
List Modification: If the list ofattributes
being returned by this method are "leaving out" certainattributes
, or on the contrary the returned lists are including otherattributes
that should not be returned by this method ... Then BOTH theStandard HTML Attributes
and theHTML Event Attributes
internal data structures can be modified by calling: -
- 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
java.lang.ClassCastException
- If'html'
contains references that do not inheritHTMLNode
.- See Also:
LV
,nonStandardAttributes(Properties)
,TagNode.tok
,TagNode.isClosing
,NodeIndex.n
,NodeIndex.index
,nonStandardAttributes(Vector)
- Code:
- Exact Method Body:
// Builds a Stream<TagNode> Stream.Builder<TagNodeIndex> tniBuilder = Stream.builder(); // Builds a Stream<String[]> Stream.Builder<String[]> sArrSBuilder = Stream.builder(); // Loop Counter, and Exception Checker LV l = new LV(sPos, ePos, html); TagNode tn; String[] sArr; // Iterate through the entire Vector. Find TagNode's with Attributes. Check if they // have any Attributes with are NIETHER "Event Attributes", nor "Regular Attributes" // ... keep them in the list to be returned. for (int i=l.start; i < l.end; i++) if ( ((tn = ((HTMLNode) html.elementAt(i)).openTagPWA()) != null) && ((sArr = nonStandardAttributes(tn.allAV())).length > 0) ) { // Save TagNodeIndex: "TagNode" (tn) plus "index" (i) tniBuilder.add(new TagNodeIndex(i, tn)); // Save String-Array sArrSBuilder.add(sArr); } // Build the two Stream.Builders to Stream... Convert Streams to Arrays... Return return new Ret2<TagNodeIndex[], String[][]>( // Build-Stream<TagNode>, Convert Stream to Array, put in Ret2.a tniBuilder.build().toArray(TagNodeIndex[]::new), // Build-Stream<String[]>, Convert Stream to Array, put in Ret2.b sArrSBuilder.build().toArray(String[][]::new) );
-
-