public virtual bool NodeMoveNext() { if (m_nodeenum != null && m_nodeenum.HasMoreNodes()) { m_node = m_nodeenum.NextNode(); return(true); } else { m_node = null; return(false); } }
/// <summary> Gets a frame by name. /// Names are checked without case sensitivity and conversion to uppercase /// is performed with the locale provided. /// </summary> /// <param name="name">The name of the frame to retrieve. /// </param> /// <param name="locale">The locale to use when converting to uppercase. /// </param> /// <returns> The specified frame or <code>null</code> if it wasn't found. /// </returns> public virtual FrameTag GetFrame(System.String name, System.Globalization.CultureInfo locale) { INode node; FrameTag ret; ret = null; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR name = name.ToUpper(); #else name = name.ToUpper(locale); #endif for (ISimpleNodeIterator e = Frames.Elements(); e.HasMoreNodes() && (null == ret);) { node = e.NextNode(); if (node is FrameTag) { ret = (FrameTag)node; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR if (!ret.FrameName.ToUpper().Equals(name)) #else if (!ret.FrameName.ToUpper(locale).Equals(name)) #endif { ret = null; } } } return(ret); }
/// <summary> Get the input tag in the form corresponding to the given name</summary> /// <param name="name">The name of the input tag to be retrieved /// </param> /// <returns> Tag The input tag corresponding to the name provided /// </returns> public virtual InputTag GetInputTag(System.String name) { InputTag inputTag; bool found; System.String inputTagName; inputTag = null; found = false; for (ISimpleNodeIterator e = FormInputs.Elements(); e.HasMoreNodes() && !found;) { inputTag = (InputTag)e.NextNode(); inputTagName = inputTag.GetAttribute("NAME"); if (inputTagName != null && inputTagName.ToUpper().Equals(name.ToUpper())) { found = true; } } if (found) { return(inputTag); } else { return(null); } }
/// <summary> Searches for all nodes whose text representation contains the search string. /// Collects all nodes containing the search string into a NodeList. /// For example, if you wish to find any textareas in a form tag containing /// "hello world", the code would be: /// <code> /// NodeList nodeList = formTag.searchFor("Hello World"); /// </code> /// </summary> /// <param name="searchString">Search criterion. /// </param> /// <param name="caseSensitive">If <code>true</code> this search should be case /// sensitive. Otherwise, the search string and the node text are converted /// to uppercase using the locale provided. /// </param> /// <param name="locale">The locale for uppercase conversion. /// </param> /// <returns> A collection of nodes whose string contents or /// representation have the <code>searchString</code> in them. /// </returns> public virtual NodeList SearchFor(System.String searchString, bool caseSensitive, System.Globalization.CultureInfo locale) { INode node; System.String text; NodeList ret; ret = new NodeList(); if (!caseSensitive) { searchString = searchString.ToUpper(locale); } for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); text = node.ToPlainTextString(); if (!caseSensitive) { text = text.ToUpper(locale); } if (-1 != text.IndexOf(searchString)) { ret.Add(node); } } return(ret); }
/// <summary> Searches all children who for a name attribute. Returns first match.</summary> /// <param name="name">Attribute to match in tag /// </param> /// <returns> Tag Tag matching the name attribute /// </returns> public virtual ITag SearchByName(System.String name) { INode node; ITag tag = null; bool found = false; for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes() && !found;) { node = e.NextNode(); if (node is ITag) { tag = (ITag)node; System.String nameAttribute = tag.GetAttribute("NAME"); if (nameAttribute != null && nameAttribute.Equals(name)) { found = true; } } } if (found) { return(tag); } else { return(null); } }
/// <summary> Return the contents of this link node as a string suitable for debugging.</summary> /// <returns> A string representation of this node. /// </returns> public override System.String ToString() { System.Text.StringBuilder sb = new System.Text.StringBuilder(); sb.Append("Link to : " + Link + "begins at : " + StartPosition + "; ends at : " + EndPosition + ", AccessKey="); if (AccessKey == null) { sb.Append("null\n"); } else { sb.Append(AccessKey + "\n"); } if (null != Children) { sb.Append(" " + "LinkData\n"); sb.Append(" " + "--------\n"); INode node; int i = 0; for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); sb.Append(" " + (i++) + " "); sb.Append(node.ToString() + "\n"); } } sb.Append(" " + "*** END of LinkData ***\n"); return(sb.ToString()); }
/// <summary> Return the textual contents of this tag and it's children.</summary> /// <returns> The 'browser' text contents of this tag. /// </returns> public override System.String ToPlainTextString() { System.Text.StringBuilder stringRepresentation = new System.Text.StringBuilder(); for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { stringRepresentation.Append(e.NextNode().ToPlainTextString()); } return(stringRepresentation.ToString()); }
/// <summary> Add the textual contents of the children of this node to the buffer.</summary> /// <param name="sb">The buffer to append to. /// </param> protected internal virtual void PutChildrenInto(System.Text.StringBuilder sb) { INode node; for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); // eliminate virtual tags // if (!(node.getStartPosition () == node.getEndPosition ())) sb.Append(node.ToHtml()); } }
/// <summary> Collect this node and its child nodes (if-applicable) into the list parameter, /// provided the node satisfies the filtering criteria. /// <p>This mechanism allows powerful filtering code to be written very easily, /// without bothering about collection of embedded tags separately. /// e.g. when we try to get all the links on a page, it is not possible to /// get it at the top-level, as many tags (like form tags), can contain /// links embedded in them. We could get the links out by checking if the /// current node is a {@link CompositeTag}, and going through its children. /// So this method provides a convenient way to do this.</p> /// <p>Using collectInto(), programs get a lot shorter. Now, the code to /// extract all links from a page would look like: /// <pre> /// NodeList list = new NodeList(); /// NodeFilter filter = new TagNameFilter ("A"); /// for (NodeIterator e = parser.elements(); e.hasMoreNodes();) /// e.nextNode().collectInto(list, filter); /// </pre> /// Thus, <code>list</code> will hold all the link nodes, irrespective of how /// deep the links are embedded.</p> /// <p>Another way to accomplish the same objective is: /// <pre> /// NodeList list = new NodeList(); /// NodeFilter filter = new TagClassFilter (LinkTag.class); /// for (NodeIterator e = parser.elements(); e.hasMoreNodes();) /// e.nextNode().collectInto(list, filter); /// </pre> /// This is slightly less specific because the LinkTag class may be /// registered for more than one node name, e.g. <LINK> tags too.</p> /// </summary> /// <param name="list">The list to add nodes to. /// </param> /// <param name="filter">The filter to apply. /// </param> public override void CollectInto(NodeList list, INodeFilter filter) { base.CollectInto(list, filter); for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { e.NextNode().CollectInto(list, filter); } if ((null != GetEndTag()) && (this != GetEndTag())) { // 2nd guard handles <tag/> GetEndTag().CollectInto(list, filter); } }
/// <summary> Returns the node number of a child node given the node object. /// This would typically be used in conjuction with digUpStringNode, /// after which the string node's parent can be used to find the /// string node's position. Faster than calling findPositionOf(text) /// again. Note that the position is at a linear level alone - there /// is no recursion in this method. /// </summary> /// <param name="searchNode">The child node to find. /// </param> /// <returns> The offset of the child tag or -1 if it was not found. /// </returns> public virtual int FindPositionOf(INode searchNode) { INode node; int loc = 0; for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); if (node == searchNode) { return(loc); } loc++; } return(-1); }
/// <summary> Returns the node number of the first node containing the given text. /// This can be useful to index into the composite tag and get other children. /// Text is compared without case sensitivity and conversion to uppercase /// uses the supplied locale. /// </summary> /// <returns> int The node index in the children list of the node containing /// the text or -1 if not found. /// </returns> /// <param name="locale">The locale to use in converting to uppercase. /// </param> /// <param name="text">The text to search for. /// </param> public virtual int FindPositionOf(System.String text, System.Globalization.CultureInfo locale) { INode node; int loc; loc = 0; text = text.ToUpper(locale); for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); if (-1 != node.ToPlainTextString().ToUpper(locale).IndexOf(text)) { return(loc); } loc++; } return(-1); }
/// <summary> Return a string representation of the contents of this tag, it's children and it's end tag suitable for debugging.</summary> /// <param name="level">The indentation level to use. /// </param> /// <param name="buffer">The buffer to append to. /// </param> public virtual void ToString(int level, System.Text.StringBuilder buffer) { INode node; for (int i = 0; i < level; i++) { buffer.Append(" "); } buffer.Append(base.ToString()); buffer.Append(System.Environment.NewLine); for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); if (node is CompositeTag) { ((CompositeTag)node).ToString(level + 1, buffer); } else { for (int i = 0; i <= level; i++) { buffer.Append(" "); } buffer.Append(node); buffer.Append(System.Environment.NewLine); } } if ((null != GetEndTag()) && (this != GetEndTag())) // 2nd guard handles <tag/> // eliminate virtual tags // if (!(getEndTag ().getStartPosition () == getEndTag ().getEndPosition ())) { for (int i = 0; i <= level; i++) { buffer.Append(" "); } buffer.Append(GetEndTag().ToString()); buffer.Append(System.Environment.NewLine); } }
/// <summary> Gets a frame by name. /// Names are checked without case sensitivity and conversion to uppercase /// is performed with the locale provided. /// </summary> /// <param name="name">The name of the frame to retrieve. /// </param> /// <param name="locale">The locale to use when converting to uppercase. /// </param> /// <returns> The specified frame or <code>null</code> if it wasn't found. /// </returns> public virtual FrameTag GetFrame(System.String name, System.Globalization.CultureInfo locale) { INode node; FrameTag ret; ret = null; name = name.ToUpper(locale); for (ISimpleNodeIterator e = Frames.Elements(); e.HasMoreNodes() && (null == ret);) { node = e.NextNode(); if (node is FrameTag) { ret = (FrameTag)node; if (!ret.FrameName.ToUpper(locale).Equals(name)) { ret = null; } } } return(ret); }
/// <summary> Find the textarea tag matching the given name</summary> /// <param name="name">Name of the textarea tag to be found within the form. /// </param> /// <returns> The <code>TEXTAREA</code> tag with the matching name. /// </returns> public virtual TextareaTag getTextAreaTag(System.String name) { TextareaTag textareaTag = null; bool found = false; for (ISimpleNodeIterator e = FormTextareas.Elements(); e.HasMoreNodes() && !found;) { textareaTag = (TextareaTag)e.NextNode(); System.String textAreaName = textareaTag.GetAttribute("NAME"); if (textAreaName != null && textAreaName.Equals(name)) { found = true; } } if (found) { return(textareaTag); } else { return(null); } }
/// <summary> Returns the node number of the first node containing the given text. /// This can be useful to index into the composite tag and get other children. /// Text is compared without case sensitivity and conversion to uppercase /// uses the supplied locale. /// </summary> /// <returns> int The node index in the children list of the node containing /// the text or -1 if not found. /// </returns> /// <param name="locale">The locale to use in converting to uppercase. /// </param> /// <param name="text">The text to search for. /// </param> public virtual int FindPositionOf(System.String text, System.Globalization.CultureInfo locale) { INode node; int loc; loc = 0; #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR text = text.ToUpper(); #else text = text.ToUpper(locale); #endif for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); #if NETFX_CORE && UNITY_METRO && !UNITY_EDITOR if (-1 != node.ToPlainTextString().ToUpper().IndexOf(text)) #else if (-1 != node.ToPlainTextString().ToUpper(locale).IndexOf(text)) #endif { return(loc); } loc++; } return(-1); }
/// <summary> Output a string representing this applet tag.</summary> /// <returns> A string showing the contents of the applet tag. /// </returns> public override System.String ToString() { System.Collections.Hashtable parameters; System.Collections.IEnumerator params_Renamed; System.String paramName; System.String paramValue; bool found; INode node; System.Text.StringBuilder ret; ret = new System.Text.StringBuilder(500); ret.Append("Applet Tag\n"); ret.Append("**********\n"); ret.Append("Class Name = "); ret.Append(AppletClass); ret.Append("\n"); ret.Append("Archive = "); ret.Append(Archive); ret.Append("\n"); ret.Append("Codebase = "); ret.Append(CodeBase); ret.Append("\n"); parameters = AppletParams; params_Renamed = parameters.Keys.GetEnumerator(); if (null == params_Renamed) { ret.Append("No Params found.\n"); } else { for (int cnt = 0; params_Renamed.MoveNext(); cnt++) { paramName = ((System.String)params_Renamed.Current); paramValue = ((System.String)parameters[paramName]); ret.Append(cnt); ret.Append(": Parameter name = "); ret.Append(paramName); ret.Append(", Parameter value = "); ret.Append(paramValue); ret.Append("\n"); } } found = false; for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); if (node is ITag) { if (((ITag)node).TagName.Equals("PARAM")) { continue; } } if (!found) { ret.Append("Miscellaneous items :\n"); } else { ret.Append(" "); } found = true; ret.Append(node.ToString()); } if (found) { ret.Append("\n"); } ret.Append("End of Applet Tag\n"); ret.Append("*****************\n"); return(ret.ToString()); }
/// <summary> Output a string representing this object tag.</summary> /// <returns> A string showing the contents of the object tag. /// </returns> public override System.String ToString() { System.Collections.Hashtable parameters; System.Collections.IEnumerator params_Renamed; System.String paramName; System.String paramValue; bool found; INode node; System.Text.StringBuilder ret; ret = new System.Text.StringBuilder(500); ret.Append("Object Tag\n"); ret.Append("**********\n"); ret.Append("ClassId = "); ret.Append(ObjectClassId); ret.Append("\n"); ret.Append("CodeBase = "); ret.Append(ObjectCodeBase); ret.Append("\n"); ret.Append("CodeType = "); ret.Append(ObjectCodeType); ret.Append("\n"); ret.Append("Data = "); ret.Append(ObjectData); ret.Append("\n"); ret.Append("Height = "); ret.Append(ObjectHeight); ret.Append("\n"); ret.Append("Standby = "); ret.Append(ObjectStandby); ret.Append("\n"); ret.Append("Type = "); ret.Append(ObjectType); ret.Append("\n"); ret.Append("Width = "); ret.Append(ObjectWidth); ret.Append("\n"); parameters = ObjectParams; params_Renamed = parameters.Keys.GetEnumerator(); if (null == params_Renamed) { ret.Append("No Params found.\n"); } else { //UPGRADE_TODO: Method 'java.util.Enumeration.hasMoreElements' was converted to 'System.Collections.IEnumerator.MoveNext' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationhasMoreElements'" for (int cnt = 0; params_Renamed.MoveNext(); cnt++) { //UPGRADE_TODO: Method 'java.util.Enumeration.nextElement' was converted to 'System.Collections.IEnumerator.Current' which has a different behavior. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1073_javautilEnumerationnextElement'" paramName = ((System.String)params_Renamed.Current); paramValue = ((System.String)parameters[paramName]); ret.Append(cnt); ret.Append(": Parameter name = "); ret.Append(paramName); ret.Append(", Parameter value = "); ret.Append(paramValue); ret.Append("\n"); } } found = false; for (ISimpleNodeIterator e = GetChildren(); e.HasMoreNodes();) { node = e.NextNode(); if (node is ITag) { if (((ITag)node).TagName.Equals("PARAM")) { continue; } } if (!found) { ret.Append("Miscellaneous items :\n"); } else { ret.Append(" "); } found = true; ret.Append(node.ToString()); } if (found) { ret.Append("\n"); } ret.Append("End of Object Tag\n"); ret.Append("*****************\n"); return(ret.ToString()); }