本文整理匯總了Java中org.w3c.dom.Node.ELEMENT_NODE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Node.ELEMENT_NODE屬性的具體用法?Java Node.ELEMENT_NODE怎麽用?Java Node.ELEMENT_NODE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類org.w3c.dom.Node
的用法示例。
在下文中一共展示了Node.ELEMENT_NODE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: makeIdMap
/**
* Method removed when ref removed from configuration, only used for menu... separator, languages
*/
@Deprecated
public static void makeIdMap(Node pElement, Map<String, CwfDataIf> pIdMap) {
if (pElement.getNodeType() == Node.ELEMENT_NODE) {
String tTagName = ((Element) pElement).getTagName();
String tId = ((Element) pElement).getAttribute("id");
if (!tId.isEmpty() && tTagName.equals(TAG_MENUITEM)) {
CwfDataIf tData = CwfDataFactory.create();
tData.setProperty(ATTR_TAG_NAME, TAG_MENUITEM);
for (int i = 0; i < pElement.getAttributes().getLength(); i++) {
Attr tAttr = (Attr) pElement.getAttributes().item(i);
tData.setProperty(tAttr.getName(), tAttr.getValue());
}
pIdMap.put(tId, tData);
}
NodeList tNodes = pElement.getChildNodes();
for (int i = 0; i < tNodes.getLength(); i++) {
makeIdMap(tNodes.item(i), pIdMap);
}
}
}
示例2: parseIgnoreColumnByRegex
private void parseIgnoreColumnByRegex(TableConfiguration tc, Node node) {
Properties attributes = parseAttributes(node);
String pattern = attributes.getProperty("pattern"); //$NON-NLS-1$
IgnoredColumnPattern icPattern = new IgnoredColumnPattern(pattern);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("except".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseException(icPattern, childNode);
}
}
tc.addIgnoredColumnPattern(icPattern);
}
示例3: dispatchingEventToSubtree
/**
* Dispatches event to the target node's descendents recursively
*
* @param n node to dispatch to
* @param e event to be sent to that node and its subtree
*/
protected void dispatchingEventToSubtree(Node n, Event e) {
if (n==null)
return;
// ***** Recursive implementation. This is excessively expensive,
// and should be replaced in conjunction with optimization
// mentioned above.
((NodeImpl) n).dispatchEvent(e);
if (n.getNodeType() == Node.ELEMENT_NODE) {
NamedNodeMap a = n.getAttributes();
for (int i = a.getLength() - 1; i >= 0; --i)
dispatchingEventToSubtree(a.item(i), e);
}
dispatchingEventToSubtree(n.getFirstChild(), e);
dispatchingEventToSubtree(n.getNextSibling(), e);
}
示例4: parseCartList
private void parseCartList(String xml){
cartList = new ArrayList<String>();
//get the factory
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
try {
DocumentBuilder db = dbf.newDocumentBuilder();
domCL = db.parse(new InputSource(new StringReader(xml)));
domCL.getDocumentElement().normalize();
NodeList nList = domCL.getElementsByTagName("item");
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
//put cart items in list
String accum = ""+eElement.getElementsByTagName("type").item(0).getTextContent() + " / " +
eElement.getElementsByTagName("make").item(0).getTextContent() + " / " +
eElement.getElementsByTagName("model").item(0).getTextContent()+ " / " +
eElement.getElementsByTagName("price").item(0).getTextContent();
cartList.add(accum);
}
}
//catch total price and item returned from server
totalPrice=domCL.getElementsByTagName("totalcost").item(0).getTextContent();
totalItem=domCL.getElementsByTagName("totalitem").item(0).getTextContent();
}catch(ParserConfigurationException pce) { pce.printStackTrace();
}catch(SAXException se) { se.printStackTrace();
}catch(IOException ioe) { ioe.printStackTrace();
}catch (Exception e){ e.printStackTrace();
}
}
示例5: parseIbatorConfiguration
public Configuration parseIbatorConfiguration(Element rootNode)
throws XMLParserException {
Configuration configuration = new Configuration();
NodeList nodeList = rootNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("properties".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperties(configuration, childNode);
} else if ("classPathEntry".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseClassPathEntry(configuration, childNode);
} else if ("ibatorContext".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseIbatorContext(configuration, childNode);
}
}
return configuration;
}
示例6: parsePropertyNode
/**
* Parse a property node
* @param rule the rule being constructed
* @param propertyNode must be a property element node
*/
private void parsePropertyNode(Rule rule, Node propertyNode) {
Element propertyElement = (Element) propertyNode;
String name = propertyElement.getAttribute("name");
String value = propertyElement.getAttribute("value");
if (value.trim().length() == 0) {
NodeList nodeList = propertyNode.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node node = nodeList.item(i);
if ((node.getNodeType() == Node.ELEMENT_NODE) && (node.getNodeName().equals("value"))) {
value = parseValueNode(node);
}
}
}
if (propertyElement.hasAttribute("pluginname")) {
rule.addProperty("pluginname", propertyElement.getAttributeNode("pluginname").getNodeValue());
}
rule.addProperty(name, value);
}
示例7: findNode
/**
* Find the named subnode in a node's sublist.
* <ul>
* <li>Ignores comments and processing instructions.
* <li>Ignores TEXT nodes (likely to exist and contain ignorable whitespace, if not validating.
* <li>Ignores CDATA nodes and EntityRef nodes.
* <li>Examines element nodes to find one with the specified name.
* </ul>
*
* @param name the tag name for the element to find
* @param node the element node to start searching from
* @return the Node found
*/
public static Node findNode(String name, Node node) {
// get all child nodes
NodeList list = node.getChildNodes();
for (int i = 0; i < list.getLength(); i++) {
// get child node
Node childNode = list.item(i);
if (childNode.getNodeType() == Node.ELEMENT_NODE) {
Element element = (Element) childNode;
if (element.hasAttributes()) {
if (element.hasAttribute("id") && element.getAttribute("id") != null
&& !element.getAttribute("id").isEmpty() && element.getAttribute("id").equals(name)) {
return element;
} else if (element.hasAttribute("name") && element.getAttribute("name") != null
&& !element.getAttribute("name").isEmpty()
&& element.getAttribute("name").equals(name)) {
return element;
}
}
}
// visit child node
Node temp = findNode(name, childNode);
if (temp != null)
return temp;
}
return null;
}
示例8: parseJavaClientGenerator
private void parseJavaClientGenerator(Context context, Node node) {
JavaClientGeneratorConfiguration javaClientGeneratorConfiguration = new JavaClientGeneratorConfiguration();
context.setJavaClientGeneratorConfiguration(javaClientGeneratorConfiguration);
Properties attributes = parseAttributes(node);
String type = attributes.getProperty("type"); //$NON-NLS-1$
String targetPackage = attributes.getProperty("targetPackage"); //$NON-NLS-1$
String targetProject = attributes.getProperty("targetProject"); //$NON-NLS-1$
String implementationPackage = attributes
.getProperty("implementationPackage"); //$NON-NLS-1$
javaClientGeneratorConfiguration.setConfigurationType(type);
javaClientGeneratorConfiguration.setTargetPackage(targetPackage);
javaClientGeneratorConfiguration.setTargetProject(targetProject);
javaClientGeneratorConfiguration
.setImplementationPackage(implementationPackage);
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(javaClientGeneratorConfiguration, childNode);
}
}
}
示例9: getElements
private static List<Node> getElements(Node node, String elementName) {
List<Node> list = new LinkedList<Node>();
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++)
if (nodeList.item(i).getNodeName().equals(elementName)
&& nodeList.item(i).getNodeType() == Node.ELEMENT_NODE)
list.add(nodeList.item(i));
return list;
}
示例10: getPublicKeyFromInternalResolvers
/**
* Searches the per-KeyInfo KeyResolvers for public keys
*
* @return The public key contained in this Node.
* @throws KeyResolverException
*/
PublicKey getPublicKeyFromInternalResolvers() throws KeyResolverException {
for (KeyResolverSpi keyResolver : internalKeyResolvers) {
if (log.isLoggable(java.util.logging.Level.FINE)) {
log.log(java.util.logging.Level.FINE, "Try " + keyResolver.getClass().getName());
}
keyResolver.setSecureValidation(secureValidation);
Node currentChild = this.constructionElement.getFirstChild();
String uri = this.getBaseURI();
while (currentChild != null) {
if (currentChild.getNodeType() == Node.ELEMENT_NODE) {
for (StorageResolver storage : storageResolvers) {
PublicKey pk =
keyResolver.engineLookupAndResolvePublicKey(
(Element) currentChild, uri, storage
);
if (pk != null) {
return pk;
}
}
}
currentChild = currentChild.getNextSibling();
}
}
return null;
}
示例11: checkManagerPassword
/**
* 檢測tomcat後台管理員角色密碼是否安全
*/
private void checkManagerPassword(String tomcatBaseDir, List<EventInfo> infos) {
File userFile = new File(tomcatBaseDir + File.separator + "conf/tomcat-users.xml");
if (!(userFile.exists() && userFile.canRead())) {
LOGGER.warn(getJsonFormattedMessage(TOMCAT_CHECK_ERROR_LOG_CHANNEL,
"can not load file conf/tomcat-users.xml"));
return;
}
Element userElement = getXmlFileRootElement(userFile);
if (userElement != null) {
NodeList userNodeList = userElement.getElementsByTagName("user");
if (userNodeList != null) {
for (int i = 0; i < userNodeList.getLength(); i++) {
Node userNode = userNodeList.item(i);
if (userNode.getNodeType() == Node.ELEMENT_NODE) {
Element user = (Element) userNode;
String rolesAttribute = user.getAttribute("roles");
String[] roles = rolesAttribute == null ? null : rolesAttribute.split(",");
if (roles != null && roles.length > 0) {
List<String> managerList = Arrays.asList(TOMCAT_MANAGER_ROLES);
for (int j = 0; j < roles.length; j++) {
if (managerList.contains(roles[j].trim())) {
List<String> weakWords = Arrays.asList(WEAK_WORDS);
String userName = user.getAttribute("username");
String password = user.getAttribute("password");
if (weakWords.contains(userName) && weakWords.contains(password)) {
infos.add(new SecurityPolicyInfo(Type.MANAGER_PASSWORD, "tomcat後台管理角色存在弱用戶名和弱密碼.", true));
}
}
}
}
}
}
}
}
}
示例12: parseJdbcConnection
protected void parseJdbcConnection(Context context, Node node) {
JDBCConnectionConfiguration jdbcConnectionConfiguration = new JDBCConnectionConfiguration();
context.setJdbcConnectionConfiguration(jdbcConnectionConfiguration);
Properties attributes = parseAttributes(node);
String driverClass = attributes.getProperty("driverClass"); //$NON-NLS-1$
String connectionURL = attributes.getProperty("connectionURL"); //$NON-NLS-1$
String userId = attributes.getProperty("userId"); //$NON-NLS-1$
String password = attributes.getProperty("password"); //$NON-NLS-1$
jdbcConnectionConfiguration.setDriverClass(driverClass);
jdbcConnectionConfiguration.setConnectionURL(connectionURL);
if (stringHasValue(userId)) {
jdbcConnectionConfiguration.setUserId(userId);
}
if (stringHasValue(password)) {
jdbcConnectionConfiguration.setPassword(password);
}
NodeList nodeList = node.getChildNodes();
for (int i = 0; i < nodeList.getLength(); i++) {
Node childNode = nodeList.item(i);
if (childNode.getNodeType() != Node.ELEMENT_NODE) {
continue;
}
if ("property".equals(childNode.getNodeName())) { //$NON-NLS-1$
parseProperty(jdbcConnectionConfiguration, childNode);
}
}
}
示例13: getRobotCoordinateZ
private String getRobotCoordinateZ(Element info, String tagcoordinate, String tagdimension){
String valuez = "";
NodeList coordinateNmElmntLst = info.getElementsByTagName(tagcoordinate);
Node coordinateNode = coordinateNmElmntLst.item(0);
if (coordinateNode.getNodeType() == Node.ELEMENT_NODE){
Element coorInfo = (Element) coordinateNode;
//Obtain information about z coordinate for the current robot
NodeList zNmElmntLst = coorInfo.getElementsByTagName(tagdimension);
Element zNmElmnt = (Element) zNmElmntLst.item(0);
NodeList zNm = zNmElmnt.getChildNodes();
valuez = ((Node)zNm.item(0)).getNodeValue();
}
return valuez;
}
示例14: next
@Override
public Document next() {
Node reviewNode = reviewList.item(reviewPosition);
if (reviewNode.getNodeType() == Node.ELEMENT_NODE) {
Element elem = (Element) reviewNode;
return buildDocument(elem);
} else {
return null;
}
}
示例15: lookupNode
@SuppressWarnings("null")
private Node lookupNode(final Node parent, String nodeName, final int index, final boolean create)
{
Node foundNode = null;
int nNumFound = 0;
final Document doc = parent.getOwnerDocument();
final boolean isAttribute = nodeName.startsWith(ATTR);
nodeName = DOMHelper.stripAttribute(nodeName);
if( isAttribute )
{
foundNode = ((Element) parent).getAttributeNode(nodeName);
}
else
{
nodeName = DOMHelper.stripNamespace(nodeName);
final boolean matchAny = nodeName.equals(WILD);
final NodeList children = parent.getChildNodes();
for( int i = 0; i < children.getLength() && foundNode == null; i++ )
{
final Node child = children.item(i);
if( child.getNodeType() == Node.ELEMENT_NODE )
{
final String childName = DOMHelper.stripNamespace(child.getNodeName());
if( matchAny || nodeName.equals(childName) )
{
if( nNumFound != index )
{
nNumFound++;
}
else
{
foundNode = child;
break;
}
}
}
}
}
if( foundNode == null && create == true )
{
// If the Index is 0 and we didn't find a node or if the number
// found (which is not zero based) equals the index (which is)
// then this is the same as saying index is one more that the
// number of nodes that exist then add a new child node.
if( index == 0 || nNumFound == index )
{
if( isAttribute )
{
((Element) parent).setAttribute(nodeName, BLANK);
foundNode = ((Element) parent).getAttributeNode(nodeName);
}
else
{
foundNode = doc.createElement(nodeName);
parent.appendChild(foundNode);
}
}
else
{
// An illegal index has been used - throw an error
String szError = new String("Error creating node ");
szError += nodeName;
szError += " with an index of ";
szError += index;
throw new RuntimeException(szError);
}
}
return foundNode;
}