当前位置: 首页>>代码示例>>Java>>正文


Java NodeList.getLength方法代码示例

本文整理汇总了Java中com.google.gwt.xml.client.NodeList.getLength方法的典型用法代码示例。如果您正苦于以下问题:Java NodeList.getLength方法的具体用法?Java NodeList.getLength怎么用?Java NodeList.getLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gwt.xml.client.NodeList的用法示例。


在下文中一共展示了NodeList.getLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: fixLinks

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
/**
 * Fix links relative to xml file
 *
 * @param tagName  tag name
 * @param attrName attribute name with link
 */
private void fixLinks(Document document, String baseUrl, String tagName, String attrName) {

    NodeList nodes = document.getElementsByTagName(tagName);

    for (int i = 0; i < nodes.getLength(); i++) {
        Element element = (Element) nodes.item(i);
        String link = element.getAttribute(attrName);
        if (link != null && !link.startsWith("http")) {
            element.setAttribute(attrName, baseUrl + link);
        }
        // Links open in new window
        if (tagName.compareTo("a") == 0) {
            element.setAttribute("target", "_blank");
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:23,代码来源:XmlData.java

示例2: StyleLinkDeclaration

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
public StyleLinkDeclaration(NodeList styleNodes, String pbaseUrl) {

        styles = new Vector<StyleLink>();
        baseUrl = pbaseUrl;

        if (styleNodes == null || styleNodes.getLength() == 0) {
            return;
        }

        NodeList styleLinkNodes = styleNodes.item(0).getChildNodes();

        if (styleLinkNodes != null) {
            for (int n = 0; n < styleLinkNodes.getLength(); n++) {
                Node styleLinkNode = styleLinkNodes.item(n);
                try {
                    StyleLink sd = new StyleLink(styleLinkNode.getAttributes().getNamedItem("href").getNodeValue(),
                            styleLinkNode.getAttributes().getNamedItem("userAgent").getNodeValue());
                    styles.add(sd);
                } catch (Exception e) {
                }
            }
        }

    }
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:25,代码来源:StyleLinkDeclaration.java

示例3: init

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
private void init(Element inlineChoiceElement) {
    NodeList nodes = inlineChoiceElement.getChildNodes();

    // Add no answer as first option
    if (showEmptyOption) {
        listBox.addItem(" ");
    }

    for (int i = 0; i < nodes.getLength(); i++) {
        if (nodes.item(i)
                .getNodeName()
                .compareTo("inlineChoice") == 0) {
            Element choiceElement = (Element) nodes.item(i);
            listBox.addItem(XMLUtils.getText(choiceElement), XMLUtils.getAttributeAsString(choiceElement, "identifier"));
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:18,代码来源:InlineChoiceDefaultController.java

示例4: initRandom

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
private void initRandom(Element inlineChoiceElement) {
    RandomizedSet<Element> randomizedNodes = new RandomizedSet<Element>();
    NodeList nodes = inlineChoiceElement.getChildNodes();

    // Add no answer as first option
    if (showEmptyOption) {
        listBox.addItem(" ");
    }

    // Add nodes to temporary list
    for (int i = 0; i < nodes.getLength(); i++) {
        if (nodes.item(i)
                .getNodeName()
                .compareTo("inlineChoice") == 0) {
            randomizedNodes.push((Element) nodes.item(i));
        }
    }

    while (randomizedNodes.hasMore()) {
        Element choiceElement = randomizedNodes.pull();
        listBox.addItem(XMLUtils.getText(choiceElement), XMLUtils.getAttributeAsString(choiceElement, "identifier"));
    }

}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:25,代码来源:InlineChoiceDefaultController.java

示例5: VariableManager

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
public VariableManager(NodeList responseDeclarationNodes, IVariableCreator<V> variableCreator) {
    Node node;
    String currIdentifier;

    if (responseDeclarationNodes != null) {
        for (int i = 0; i < responseDeclarationNodes.getLength(); i++) {
            node = responseDeclarationNodes.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                currIdentifier = node.getAttributes().getNamedItem("identifier").getNodeValue();
                V var = variableCreator.createVariable(node);
                if (var != null) {
                    variables.put(currIdentifier, var);
                }
            }
        }
    }
}
 
开发者ID:YoungDigitalPlanet,项目名称:empiria.player,代码行数:18,代码来源:VariableManager.java

示例6: addVariable

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
/**
 * Adds a <link match=.../> element to the <args> section of the LASRequest.
 * This will add a new dataset-variable pair to the LASRequest. Note that
 * the order in which variables appear in an LASRequest is important as
 * differencing products (as of 2007-10-24) always subtract the second
 * variable from the first.
 * 
 * @param dsID
 * @param varID
 * @param region
 *            - the region to which this variable belongs.
 */
public void addVariable(String dsID, String varID, int region_index) {
    Element link = makeLink(dsID, varID);
    NodeList l = document.getDocumentElement().getElementsByTagName("args");
    Element args = (Element) l.item(0);
    if ( args == null ) {
        args = document.createElement("args");
        document.getDocumentElement().appendChild(args);
    }
    NodeList regions = document.getElementsByTagName("region");
    if ( region_index >= 0 && region_index < regions.getLength() ) {
        Element region = (Element) regions.item(region_index);
        args.insertBefore(link, region);
    } else {
        args.appendChild(link);
    }
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:29,代码来源:LASRequest.java

示例7: getVariable

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
public String getVariable(int index) {
    Element args = getArgsElement();
    NodeList variables = args.getElementsByTagName("link");
    int counter = 0;
    for ( int i = 0; i < variables.getLength(); i++ ) {
        Element var = (Element) variables.item(i);
        // ByTagName gets children, grandchildren and below. Check that it
        // is a child of "args".
        if ( var.getParentNode().getNodeName().equals("args") ) {
            if ( counter == index ) {
                return getVariableId(var.getAttribute("match"));
            }
            counter++;
        }
    }
    return null;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:18,代码来源:LASRequest.java

示例8: getRangeHi

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
public String getRangeHi(String axis_type, int index) {
    Element args = getArgsElement();
    NodeList regions = args.getElementsByTagName("region");
    if ( regions.getLength() > index ) {
        Element region = (Element) regions.item(index);
        NodeList ranges = region.getElementsByTagName("range");
        for ( int i = 0; i < ranges.getLength(); i++ ) {
            Element range = (Element) ranges.item(i);
            if ( range.getAttribute("type").equals(axis_type) ) {
                return range.getAttribute("high");
            }
        }
        NodeList points = region.getElementsByTagName("point");
        for ( int i = 0; i < points.getLength(); i++ ) {
            Element point = (Element) points.item(i);
            if ( point.getAttribute("type").equals(axis_type) ) {
                return point.getAttribute("v");
            }
        }
    }
    return null;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:23,代码来源:LASRequest.java

示例9: getRangeLo

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
public String getRangeLo(String axis_type, int index) {
    Element args = getArgsElement();
    NodeList regions = args.getElementsByTagName("region");
    if ( regions.getLength() > index ) {
        Element region = (Element) regions.item(index);
        NodeList ranges = region.getElementsByTagName("range");
        for ( int i = 0; i < ranges.getLength(); i++ ) {
            Element range = (Element) ranges.item(i);
            if ( range.getAttribute("type").equals(axis_type) ) {
                return range.getAttribute("low");
            }
        }
        NodeList points = region.getElementsByTagName("point");
        for ( int i = 0; i < points.getLength(); i++ ) {
            Element point = (Element) points.item(i);
            if ( point.getAttribute("type").equals(axis_type) ) {
                return point.getAttribute("v");
            }
        }
    }
    return null;
}
 
开发者ID:NOAA-PMEL,项目名称:LAS,代码行数:23,代码来源:LASRequest.java

示例10: getChildrenNS

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
@Override
public List<Element> getChildrenNS(String xmlns) throws XMLException {
	final ArrayList<Element> result = new ArrayList<Element>();
	NodeList nodes = this.xmlElement.getChildNodes();
	for (int i = 0; i < nodes.getLength(); i++) {
		Node node = nodes.item(i);
		if (node instanceof com.google.gwt.xml.client.Element) {
			final String x = ((com.google.gwt.xml.client.Element) node).getAttribute("xmlns");
			GwtElement gpi = new GwtElement((com.google.gwt.xml.client.Element) node);
			if (x != null && xmlns.equals(gpi.getXMLNS())) {
				result.add(gpi);
			}
		}
	}
	return result;
}
 
开发者ID:horsefaced,项目名称:jaxmpp-android,代码行数:17,代码来源:GwtElement.java

示例11: getFirstChild

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
@Override
public Element getFirstChild() throws XMLException {
	NodeList nodes = this.xmlElement.getChildNodes();
	for (int i = 0; i < nodes.getLength(); i++) {
		Node node = nodes.item(i);
		if (node instanceof com.google.gwt.xml.client.Element) {
			return new GwtElement((com.google.gwt.xml.client.Element) node);
		}
	}

	return null;
	// first child may not be Element it can be Node only!!
	// com.google.gwt.xml.client.Element c =
	// (com.google.gwt.xml.client.Element) xmlElement.getFirstChild();
	// return c == null ? null : new GwtElement(c);
}
 
开发者ID:horsefaced,项目名称:jaxmpp-android,代码行数:17,代码来源:GwtElement.java

示例12: treatValidRequests

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
/**
 * @param validRequest
 */
private static void treatValidRequests(Node validRequest) {    
  NodeList children = validRequest.getChildNodes();
  for(int i = 0; i < children.getLength(); i++) {
    Node node = children.item(i);
    if (node.getNodeType() != Node.ELEMENT_NODE) {
      continue;
    }
    if (node.getNodeName().equals("schemaLocation")) {        
      if (node.hasChildNodes() &&            
          !schemaLocations.contains(node.getFirstChild().getNodeValue())) {
        schemaLocations.add(node.getFirstChild().getNodeValue());          
      }    
    }
    else if (node.getNodeName().equals("defaultNamespace")) {        
      if (node.hasChildNodes() &&
          !defaultNamespace.contains(node.getFirstChild().getNodeValue())) {
        defaultNamespace.add(node.getFirstChild().getNodeValue());          
      }    
    }
  }    
}
 
开发者ID:tomayac,项目名称:rest-describe-and-compile,代码行数:25,代码来源:DiscoveredItemsDialog.java

示例13: getElementByIdThenParse

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
/**
 * Runs recursively through the node hierarchy starting from the entry node and tries to find
 * the node with the given ID. When the node is found it gets parsed  
 * @param entryNode
 * @param id 
 * @param parentNode    
 */
private void getElementByIdThenParse(Node entryNode, String id, Object parentNode) {    
  if (id.startsWith("#")) {
    id = id.substring(1);
  }    
  if ((entryNode.getNodeType() == ELEMENT_NODE) && (entryNode.hasAttributes())) {      
    Node idNode = entryNode.getAttributes().getNamedItem("id");
    if ((idNode != null) && (idNode.getNodeValue().equals(id))) {          
      parseFoundNode(entryNode, parentNode);
      return;
    }      
  }
  NodeList childNodes = entryNode.getChildNodes();   
  for (int i = 0; i < childNodes.getLength(); i++) {
    getElementByIdThenParse(childNodes.item(i), id, parentNode);      
  }    
}
 
开发者ID:tomayac,项目名称:rest-describe-and-compile,代码行数:24,代码来源:WadlParser.java

示例14: buildNamedElements

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
public static <E> ArrayList<E> buildNamedElements(Element e, String name, XMLNodeFactory<E> factory) {
	ArrayList<E> list = new ArrayList<E>();
	NodeList l = e.getChildNodes();
	for(int i = 0; i < l.getLength(); i++) {
		if(l.item(i) instanceof Element) {
			Element n = (Element)l.item(i);
			if(n.getNodeName().equals(name)) {
				E fn = factory.build(n);
				if(fn != null) {
					list.add(fn);
				}
			}
		}
	}
	return list;
}
 
开发者ID:pfranza,项目名称:gwtjaxb,代码行数:17,代码来源:XMLParsingUtils.java

示例15: parseXmlDocumentAsBook

import com.google.gwt.xml.client.NodeList; //导入方法依赖的package包/类
private Book[] parseXmlDocumentAsBook(Document xml) {
    final NodeList idNodes = xml.getElementsByTagName("id");
    final NodeList titleNodes = xml.getElementsByTagName("title");
    final NodeList authorNodes = xml.getElementsByTagName("author");

    int length = idNodes.getLength();
    Book[] books = new Book[length];

    for (int i = 0; i < length; i++) {
        String id = ((Text) idNodes.item(i).getFirstChild()).getData();
        String title = ((Text) titleNodes.item(i).getFirstChild()).getData();
        String author = ((Text) authorNodes.item(i).getFirstChild()).getData();
        books[i] = new Book(Integer.valueOf(id), title, author);
    }

    return books;
}
 
开发者ID:growbit,项目名称:turbogwt-http,代码行数:18,代码来源:BookXmlSerdes.java


注:本文中的com.google.gwt.xml.client.NodeList.getLength方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。