本文整理了Java中com.google.gwt.xml.client.Node
类的一些代码示例,展示了Node
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node
类的具体详情如下:
包路径:com.google.gwt.xml.client.Node
类名称:Node
[英]This is the base interface for DOM nodes, as obtained from using XMLParser
methods. Methods for iterating over and accessing values from nodes are supplied here.
[中]这是DOM节点的基本接口,可以通过使用XMLParser
方法获得。这里提供了迭代和访问节点值的方法。
代码示例来源:origin: pentaho/data-access
private String getNodeValueByTagName( Node node, String tagName ) {
if ( node != null && node.getFirstChild() != null ) {
return node.getFirstChild().getNodeValue();
} else {
return null;
}
}
代码示例来源:origin: com.googlecode.gwtupload/gwtupload
public static String getXmlNodeValue(Node node) {
if (node.getNodeType() != Node.ELEMENT_NODE) {
return null;
}
String ret = "";
NodeList textNodes = node.getChildNodes();
for (int i = 0; i < textNodes.getLength(); i++) {
Node n = textNodes.item(i);
if (n.getNodeType() == Node.TEXT_NODE
&& n.getNodeValue().replaceAll("[ \\n\\t\\r]", "").length() > 0) {
ret += n.getNodeValue();
} else if (n.getNodeType() == Node.CDATA_SECTION_NODE) {
ret += n.getNodeValue();
}
}
return ret.length() == 0 ? null : ret.replaceAll("^\\s+", "").replaceAll("\\s+$", "");
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient
private boolean isQueryable(Node layerNode) {
NamedNodeMap attributes = layerNode.getAttributes();
Node q = attributes.getNamedItem("queryable");
if (q != null) {
return "1".equals(q.getNodeValue());
}
return false;
}
代码示例来源:origin: com.google.gwt/gwt-servlet
private static void removeWhitespaceInner(Node n, Node parent) {
// This n is removed from the parent if n is a whitespace node
if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
Text t = (Text) n;
if (t.getData().matches("[ \t\n]*")) {
parent.removeChild(t);
}
}
if (n.hasChildNodes()) {
int length = n.getChildNodes().getLength();
List<Node> toBeProcessed = new ArrayList<Node>();
// We collect all the nodes to iterate as the child nodes will change
// upon removal
for (int i = 0; i < length; i++) {
toBeProcessed.add(n.getChildNodes().item(i));
}
// This changes the child nodes, but the iterator of nodes never changes
// meaning that this is safe
for (Node childNode : toBeProcessed) {
removeWhitespaceInner(childNode, n);
}
}
}
代码示例来源:origin: org.apache.cxf/cxf-rt-management-web
@Nullable
private String getTextValue(@Nonnull final Node node) {
Node child = node.getFirstChild();
if (child != null && child.getNodeType() == TEXT_NODE) {
return child.getNodeValue();
}
return null;
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient
protected void parse(Node node) {
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
String nodeName = child.getNodeName();
if ("Name".equalsIgnoreCase(nodeName)) {
name = getValueRecursive(child);
} else if ("Title".equalsIgnoreCase(nodeName)) {
title = getValueRecursive(child);
} else if ("Abstract".equalsIgnoreCase(nodeName)) {
abstractt = getValueRecursive(child);
} else if ("LegendURL".equalsIgnoreCase(nodeName)) {
legendUrl = createLegendInfo(child);
}
}
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient
protected void parse(Node node) {
NamedNodeMap attributes = node.getAttributes();
type = getValueRecursive(attributes.getNamedItem("type"));
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
String nodeName = child.getNodeName();
if ("Format".equalsIgnoreCase(nodeName)) {
format = getValueRecursive(child);
} else if ("OnlineResource".equalsIgnoreCase(nodeName)) {
onlineResource = createOnlineResource(child);
}
}
}
代码示例来源:origin: org.metawidget.modules/metawidget-all
@Override
@SuppressWarnings( { "cast", "unchecked" } )
protected Map<String, String> getAttributesAsMap( Element element ) {
NamedNodeMap nodes = element.getAttributes();
int length = nodes.getLength();
if ( length == 0 ) {
return (Map<String, String>) Collections.EMPTY_MAP;
}
Map<String, String> attributes = new HashMap<String, String>( length );
for ( int loop = 0; loop < length; loop++ ) {
Node node = nodes.item( loop );
attributes.put( node.getNodeName(), node.getNodeValue() );
}
return attributes;
}
}
代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl
protected double getAttributeAsDouble(Node node, String name) {
Node attr = node.getAttributes().getNamedItem(name);
return getValueRecursiveAsDouble(attr);
}
代码示例来源:origin: EmiteGWT/emite
@Override
public String getText() {
final StringBuilder result = new StringBuilder();
final NodeList nodes = element.getChildNodes();
for (int i = 0; i < nodes.getLength(); i++) {
final Node child = nodes.item(i);
if (child.getNodeType() == Node.TEXT_NODE)
result.append(child.getNodeValue());
}
return result.toString();
}
代码示例来源:origin: org.apache.cxf/cxf-rt-management-web
LazyXmlParser(@Nonnull final Node entryNode) {
assert "entry".equals(entryNode.getNodeName());
assert entryNode.getNodeType() == ELEMENT_NODE;
this.entryNode = entryNode;
}
代码示例来源:origin: org.geomajas/geomajas-client-gwt2-impl
protected boolean hasAttribute(Node node, String name) {
return node.hasAttributes() && node.getAttributes().getNamedItem(name) != null;
}
代码示例来源:origin: pentaho/data-access
private List<Node> getNodesByTagName( Element element, String tagName ) {
List<Node> nodes = new ArrayList<Node>();
NodeList list = element.getChildNodes();
for ( int i = 0; i < list.getLength(); i++ ) {
Node node = list.item( i );
if ( node != null && node.getNodeName().equals( tagName ) ) {
nodes.add( node );
}
}
return nodes;
}
代码示例来源:origin: org.apache.cxf/cxf-rt-management-web
private boolean isLinkBelongToFeed(@Nonnull final Node node) {
return node.getParentNode() != null && FEED_TAG.equals(node.getParentNode().getNodeName());
}
代码示例来源:origin: org.apache.cxf/cxf-rt-management-web
private void parseEntries(@Nonnull final Document document) {
NodeList entryNodes = document.getElementsByTagName(ENTRY_TAG);
if (entryNodes != null) {
Node entryNode;
for (int i = 0; i < entryNodes.getLength(); i++) {
entryNode = entryNodes.item(i);
assert entryNode != null;
if (entryNode.getNodeType() == ELEMENT_NODE) {
entries.add(new Entry(entryNodes.item(i)));
}
}
Collections.reverse(entries);
}
}
}
代码示例来源:origin: org.n52.sensorweb/sensorwebclient-ui
public ArrayList<String> getParameters(String name) {
ArrayList<String> array = new ArrayList<String>();
if (hasProperty(name)) {
NodeList nodes = this.properties.getElementsByTagName(name);
for (int i = 0; i < nodes.getLength(); i++) {
array.add(nodes.item(i).getFirstChild().toString());
}
}
return array;
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient
private void addLatLonBoundingBox(Node bboxNode) {
NodeList childNodes = bboxNode.getChildNodes();
double x = 0, y = 0, maxx = 0, maxy = 0;
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
String nodeName = child.getNodeName();
if ("westBoundLongitude".equalsIgnoreCase(nodeName)) {
x = getValueRecursiveAsDouble(child);
} else if ("eastBoundLongitude".equalsIgnoreCase(nodeName)) {
maxx = getValueRecursiveAsDouble(child);
} else if ("southBoundLatitude".equalsIgnoreCase(nodeName)) {
y = getValueRecursiveAsDouble(child);
} else if ("northBoundLatitude".equalsIgnoreCase(nodeName)) {
maxy = getValueRecursiveAsDouble(child);
}
}
latlonBoundingBox = new Bbox(x, y, maxx - x, maxy - y);
}
}
代码示例来源:origin: org.geomajas.plugin/geomajas-plugin-wmsclient
protected void parse(Node node) {
NamedNodeMap attributes = node.getAttributes();
width = getValueRecursiveAsInteger(attributes.getNamedItem("width"));
height = getValueRecursiveAsInteger(attributes.getNamedItem("height"));
NodeList childNodes = node.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
String nodeName = child.getNodeName();
if ("Format".equalsIgnoreCase(nodeName)) {
format = getValueRecursive(child);
} else if ("OnlineResource".equalsIgnoreCase(nodeName)) {
onlineResource = createOnlineResource(child);
}
}
}
代码示例来源:origin: net.wetheinter/gwt-user
private static void removeWhitespaceInner(Node n, Node parent) {
// This n is removed from the parent if n is a whitespace node
if (parent != null && n instanceof Text && (!(n instanceof CDATASection))) {
Text t = (Text) n;
if (t.getData().matches("[ \t\n]*")) {
parent.removeChild(t);
}
}
if (n.hasChildNodes()) {
int length = n.getChildNodes().getLength();
List<Node> toBeProcessed = new ArrayList<Node>();
// We collect all the nodes to iterate as the child nodes will change
// upon removal
for (int i = 0; i < length; i++) {
toBeProcessed.add(n.getChildNodes().item(i));
}
// This changes the child nodes, but the iterator of nodes never changes
// meaning that this is safe
for (Node childNode : toBeProcessed) {
removeWhitespaceInner(childNode, n);
}
}
}
代码示例来源:origin: pentaho/data-access
public IDatabaseConnection convertToObject( String xml ) {
Document document = XMLParser.parse( xml );
Element element = document.getDocumentElement();
IDatabaseConnection databaseConnection = new DatabaseConnection();
databaseConnection.setDatabaseName( getNodeValueByTagName( element, DATABASE_NAME ) );
databaseConnection.setHostname( getNodeValueByTagName( element, HOSTNAME ) );
databaseConnection.setIndexTablespace( getNodeValueByTagName( element, INDEX_TABLESPACE ) );
databaseConnection.setDataTablespace( getNodeValueByTagName( element, DATA_TABLESPACE ) );
databaseConnection.setName( getNodeValueByTagName( element, NAME ) );
databaseConnection.setUsername( getNodeValueByTagName( element, USERNAME ) );
databaseConnection.setPassword( getNodeValueByTagName( element, PASSWORD ) );
databaseConnection.setDatabasePort( getNodeValueByTagName( element, DATABASE_PORT ) );
databaseConnection
.setAccessType( DatabaseAccessType.getAccessTypeByName( getNodeValueByTagName( element, ACCESS_TYPE ) ) );
databaseConnection.setDatabaseType(
(DatabaseType) databaseTypeHelper.getDatabaseTypeByShortName( getNodeValueByTagName( element, DATABASE_TYPE ) ) );
databaseConnection.setPassword( getNodeValueByTagName( element, PASSWORD ) );
databaseConnection.setInformixServername( getNodeValueByTagName( element, SERVER_NAME ) );
for ( Node node : getNodesByTagName( element, ATTRIBUTES ) ) {
databaseConnection.getAttributes().put( node.getNodeName(), node.getNodeValue() );
}
return databaseConnection;
}
内容来源于网络,如有侵权,请联系作者删除!