本文整理汇总了Java中mf.org.w3c.dom.NodeList类的典型用法代码示例。如果您正苦于以下问题:Java NodeList类的具体用法?Java NodeList怎么用?Java NodeList使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NodeList类属于mf.org.w3c.dom包,在下文中一共展示了NodeList类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getChildNodesUnoptimized
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
/**
* Create a NodeList to access children that is use by subclass elements
* that have methods named getLength() or item(int). ChildAndParentNode
* optimizes getChildNodes() by implementing NodeList itself. However if
* a subclass Element implements methods with the same name as the NodeList
* methods, they will override the actually methods in this class.
* <p>
* To use this method, the subclass should implement getChildNodes() and
* have it call this method. The resulting NodeList instance maybe
* shared and cached in a transient field, but the cached value must be
* cleared if the node is cloned.
*/
protected final NodeList getChildNodesUnoptimized() {
if (needsSyncChildren()) {
synchronizeChildren();
}
return new NodeList() {
/**
* @see NodeList.getLength()
*/
public int getLength() {
return nodeListGetLength();
} // getLength():int
/**
* @see NodeList.item(int)
*/
public Node item(int index) {
return nodeListItem(index);
} // item(int):Node
};
}
示例2: getTitle
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public synchronized String getTitle()
{
HTMLElement head;
NodeList list;
Node title;
// Get the HEAD element and look for the TITLE element within.
// When found, make sure the TITLE is a direct child of HEAD,
// and return the title's text (the Text node contained within).
head = getHead();
list = head.getElementsByTagName( "TITLE" );
if ( list.getLength() > 0 ) {
title = list.item( 0 );
return ( (HTMLTitleElement) title ).getText();
}
// No TITLE found, return an empty string.
return "";
}
示例3: setTitle
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public synchronized void setTitle( String newTitle )
{
HTMLElement head;
NodeList list;
Node title;
// Get the HEAD element and look for the TITLE element within.
// When found, make sure the TITLE is a direct child of HEAD,
// and set the title's text (the Text node contained within).
head = getHead();
list = head.getElementsByTagName( "TITLE" );
if ( list.getLength() > 0 ) {
title = list.item( 0 );
if ( title.getParentNode() != head )
head.appendChild( title );
( (HTMLTitleElement) title ).setText( newTitle );
}
else
{
// No TITLE found, create a new element and place it at the end
// of the HEAD element.
title = new HTMLTitleElementImpl( this, "TITLE" );
( (HTMLTitleElement) title ).setText( newTitle );
head.appendChild( title );
}
}
示例4: getIndex
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public int getIndex()
{
Node parent;
NodeList options;
int i;
// Locate the parent SELECT. Note that this OPTION might be inside a
// OPTGROUP inside the SELECT. Or it might not have a parent SELECT.
// Everything is possible. If no parent is found, return -1.
parent = getParentNode();
while ( parent != null && ! ( parent instanceof HTMLSelectElement ) )
parent = parent.getParentNode();
if ( parent != null )
{
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under the SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
options = ( (HTMLElement) parent ).getElementsByTagName( "OPTION" );
for ( i = 0 ; i < options.getLength() ; ++i )
if ( options.item( i ) == this )
return i;
}
return -1;
}
示例5: getSelectedIndex
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public int getSelectedIndex()
{
NodeList options;
int i;
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under this SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Locate the first selected OPTION and return its index. Note that
// the OPTION might be under an OPTGROUP.
options = getElementsByTagName( "OPTION" );
for ( i = 0 ; i < options.getLength() ; ++i )
if ( ( (HTMLOptionElement) options.item( i ) ).getSelected() )
return i;
return -1;
}
示例6: getRowIndex
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
int getRowIndex( Node parent )
{
NodeList rows;
int i;
// Use getElementsByTagName() which creates a snapshot of all the
// TR elements under the TABLE/section. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
rows = ( (HTMLElement) parent ).getElementsByTagName( "TR" );
for ( i = 0 ; i < rows.getLength() ; ++i ) {
if ( rows.item( i ) == this ) {
return i;
}
}
return -1;
}
示例7: toReturnType
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
/**
* Returns the native type based on XPathConstants qname and an optional cast-to type, if provided.
* @param resultType qname
* @param optionalCastToType null or cast-to type
* @return return type
*/
public static Class toReturnType(QName resultType, Class optionalCastToType)
{
if (optionalCastToType != null)
{
return optionalCastToType;
}
if (resultType.equals(XPathConstants.NODESET))
return NodeList.class;
if (resultType.equals(XPathConstants.NODE))
return Node.class;
if (resultType.equals(XPathConstants.BOOLEAN))
return Boolean.class;
if (resultType.equals(XPathConstants.NUMBER))
return Double.class;
if (resultType.equals(XPathConstants.STRING))
return String.class;
return String.class;
}
示例8: getElementsByTagNameNS
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public final NodeList getElementsByTagNameNS( String namespaceURI,
String localName )
{
if ( namespaceURI != null && namespaceURI.length() > 0 ) {
return super.getElementsByTagNameNS( namespaceURI, localName.toUpperCase(Locale.ENGLISH) );
}
return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
}
示例9: setIndex
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public void setIndex( int index )
{
Node parent;
NodeList options;
Node item;
// Locate the parent SELECT. Note that this OPTION might be inside a
// OPTGROUP inside the SELECT. Or it might not have a parent SELECT.
// Everything is possible. If no parent is found, just return.
parent = getParentNode();
while ( parent != null && ! ( parent instanceof HTMLSelectElement ) )
parent = parent.getParentNode();
if ( parent != null )
{
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under the SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Make sure this OPTION is not replacing itself.
options = ( (HTMLElement) parent ).getElementsByTagName( "OPTION" );
if ( options.item( index ) != this )
{
// Remove this OPTION from its parent. Place this OPTION right
// before indexed OPTION underneath it's direct parent (might
// be an OPTGROUP).
getParentNode().removeChild( this );
item = options.item( index );
item.getParentNode().insertBefore( this, item );
}
}
}
示例10: setSelectedIndex
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public void setSelectedIndex( int selectedIndex )
{
NodeList options;
int i;
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under this SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Change the select so all OPTIONs are off, except for the
// selectIndex-th one.
options = getElementsByTagName( "OPTION" );
for ( i = 0 ; i < options.getLength() ; ++i )
( (HTMLOptionElementImpl) options.item( i ) ).setSelected( i == selectedIndex );
}
示例11: remove
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public void remove( int index )
{
NodeList options;
Node removed;
// Use getElementsByTagName() which creates a snapshot of all the
// OPTION elements under this SELECT. Access to the returned NodeList
// is very fast and the snapshot solves many synchronization problems.
// Remove the indexed OPTION from it's parent, this might be this
// SELECT or an OPTGROUP.
options = getElementsByTagName( "OPTION" );
removed = options.item( index );
if ( removed != null )
removed.getParentNode().removeChild ( removed );
}
示例12: getElementsByTagNameNS
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public final NodeList getElementsByTagNameNS( String namespaceURI,
String localName ) {
if ( namespaceURI != null && namespaceURI.length() > 0 ) {
return super.getElementsByTagNameNS( namespaceURI, localName.toUpperCase(Locale.ENGLISH) );
}
return super.getElementsByTagName( localName.toUpperCase(Locale.ENGLISH) );
}
示例13: isAttrValueWF
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
/** NON-DOM: check if attribute value is well-formed
* @param attributes
* @param a
* @param value
*/
public static final void isAttrValueWF(DOMErrorHandler errorHandler, DOMErrorImpl error,
DOMLocatorImpl locator, NamedNodeMap attributes, Attr a, String value, boolean xml11Version) {
if (a instanceof AttrImpl && ((AttrImpl)a).hasStringValue()) {
isXMLCharWF(errorHandler, error, locator, value, xml11Version);
} else {
NodeList children = a.getChildNodes();
//check each child node of the attribute's value
for (int j = 0; j < children.getLength(); j++) {
Node child = children.item(j);
//If the attribute's child is an entity refernce
if (child.getNodeType() == Node.ENTITY_REFERENCE_NODE) {
Document owner = a.getOwnerDocument();
Entity ent = null;
//search for the entity in the docType
//of the attribute's ownerDocument
if (owner != null) {
DocumentType docType = owner.getDoctype();
if (docType != null) {
NamedNodeMap entities = docType.getEntities();
ent = (Entity) entities.getNamedItemNS(
"*",
child.getNodeName());
}
}
//If the entity was not found issue a fatal error
if (ent == null) {
String msg = DOMMessageFormatter.formatMessage(
DOMMessageFormatter.DOM_DOMAIN, "UndeclaredEntRefInAttrValue",
new Object[]{a.getNodeName()});
reportDOMError(errorHandler, error, locator, msg, DOMError.SEVERITY_ERROR,
"UndeclaredEntRefInAttrValue");
}
}
else {
// Text node
isXMLCharWF(errorHandler, error, locator, child.getNodeValue(), xml11Version);
}
}
}
}
示例14: getChildNodes
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
/** Returns an empty node list. */
public NodeList getChildNodes() {
return singletonNodeList;
}
示例15: getElementsByTagName
import mf.org.w3c.dom.NodeList; //导入依赖的package包/类
public NodeList getElementsByTagName(String tagname) {
return null;
}