本文整理匯總了Java中org.w3c.dom.NamedNodeMap類的典型用法代碼示例。如果您正苦於以下問題:Java NamedNodeMap類的具體用法?Java NamedNodeMap怎麽用?Java NamedNodeMap使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
NamedNodeMap類屬於org.w3c.dom包,在下文中一共展示了NamedNodeMap類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: collectElementProperties
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
private UiElementProperties collectElementProperties( Element elementNode, String mapId ) {
UiElementProperties elementProperties = new UiElementProperties();
NamedNodeMap nodeAttributes = (elementNode).getAttributes();
for (int i = 0; i < nodeAttributes.getLength(); i++) {
Node node = nodeAttributes.item(i);
if (StringUtils.isNullOrEmpty(node.getNodeValue())) {
throw new ElementsMapException("Error loading '" + mapId + "' element from map. '"
+ node.getNodeName() + "' contains an empty value");
}
if (StringUtils.isNullOrEmpty(node.getNodeName())) {
throw new ElementsMapException("Error loading '" + mapId + "' element from map. '"
+ node.getNodeValue() + "' contains an empty key");
}
elementProperties.addProperty(node.getNodeName(), node.getNodeValue());
}
return elementProperties;
}
示例2: parse
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
public Resource[] parse(Node rootNode, ParserContext parserContext) {
NamedNodeMap nodeMap=rootNode.getAttributes();
String locations=getAttributeValue("locations",nodeMap);
if(StringUtils.isNotEmpty(locations)){
String[] locationsArray=locations.split(LOCATION_SEPARATOR);
List<Resource> resources=new ArrayList<Resource>();
for(int i=0;i<locationsArray.length;i++){
String location=locationsArray[i];
if(StringUtils.isNotEmpty(location)){
resources.add(resourcePatternResolver.getResource(location));
}
}
return resources.toArray(new Resource[resources.size()]);
}else{
return null;
}
}
示例3: parseXml
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
@Override
public void parseXml(Node node) {
super.parseXml(node);
NamedNodeMap map=node.getAttributes();
Node lockmodeNode=map.getNamedItem("lockmode");
if(lockmodeNode!=null){
LockModeType type=null;
for(LockModeType mode:LockModeType.values()){
if(mode.toString().equals(lockmodeNode.getNodeValue())){
type=mode;
}
}
this.lockmode=type;
}
Node multiplicityNode=map.getNamedItem("multiplicity");
if(multiplicityNode!=null){
this.multiplicity=multiplicityNode.getNodeValue();
}
}
示例4: displayMetadata
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
static void displayMetadata(Node node, int level) {
for (int i = 0; i < level; i++) System.out.print(" ");
System.out.print("<" + node.getNodeName());
NamedNodeMap map = node.getAttributes();
if (map != null) { // print attribute values
int length = map.getLength();
for (int i = 0; i < length; i++) {
Node attr = map.item(i);
System.out.print(" " + attr.getNodeName() +
"=\"" + attr.getNodeValue() + "\"");
}
}
Node child = node.getFirstChild();
if (child != null) {
System.out.println(">"); // close current tag
while (child != null) { // emit child tags recursively
displayMetadata(child, level + 1);
child = child.getNextSibling();
}
for (int i = 0; i < level; i++) System.out.print(" ");
System.out.println("</" + node.getNodeName() + ">");
} else {
System.out.println("/>");
}
}
示例5: parse
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
@Override
public void parse(Consumer<MnoInfo> consumer) throws Exception {
File fXmlFile = config.toFile();
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
Document doc = dBuilder.parse(fXmlFile);
doc.getDocumentElement().normalize();
XPathExpression xpathMno = XPathFactory.newInstance().newXPath().compile("//*[local-name()='mno']");
XPathExpression xpathMasksMno = XPathFactory.newInstance().newXPath().compile("//*[local-name()='mask']");
NodeList mnoNodes = (NodeList) xpathMno.evaluate(doc, XPathConstants.NODESET);
for (int i=0; i<mnoNodes.getLength(); i++) {
Node node = mnoNodes.item(i);
NamedNodeMap attributes = node.getAttributes();
String country = getValue(attributes.getNamedItem("country"));
String title = getValue(attributes.getNamedItem("title"));
String area = getValue(attributes.getNamedItem("area"));
Set<Mask> masks = new HashSet<>();
NodeList maskNodes = (NodeList) xpathMasksMno.evaluate(doc, XPathConstants.NODESET);
for (int j=0; j<maskNodes.getLength(); j++) {
masks.add(Mask.parse(getValue(maskNodes.item(j))));
}
consumer.accept(new MnoInfo(title, area, country, masks));
}
}
示例6: examineNode
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
/**
* A single node is read, the namespace attributes are extracted and stored.
*
* @param node
* to examine
* @param attributesOnly,
* if true no recursion happens
*/
private void examineNode(Node node, boolean attributesOnly) {
while(node != null && node.getNodeType() == Node.COMMENT_NODE) {
node = node.getNextSibling();
}
if(node != null) {
NamedNodeMap attributes = node.getAttributes();
if(attributes != null) {
for (int i = 0; i < attributes.getLength(); i++) {
Node attribute = attributes.item(i);
storeAttribute((Attr) attribute);
}
}
if (!attributesOnly) {
NodeList chields = node.getChildNodes();
for (int i = 0; i < chields.getLength(); i++) {
Node chield = chields.item(i);
if (chield.getNodeType() == Node.ELEMENT_NODE)
examineNode(chield, false);
}
}
}
}
示例7: parseDropListItem
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
private void parseDropListItem(Node drop_list_item, DropListScope dropListScope, List<IDropItem> drops)
{
final NamedNodeMap attrs = drop_list_item.getAttributes();
switch (drop_list_item.getNodeName().toLowerCase())
{
case "item":
{
final IDropItem dropItem = dropListScope.newDropItem(parseInteger(attrs, "id"), parseLong(attrs, "min"), parseLong(attrs, "max"), parseDouble(attrs, "chance"));
if (dropItem != null)
{
drops.add(dropItem);
}
break;
}
}
}
示例8: compareElementAttrs
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
private static boolean compareElementAttrs(Element e1, Element e2) {
NamedNodeMap at1 = e1.getAttributes();
NamedNodeMap at2 = e2.getAttributes();
if (at1.getLength() != at2.getLength()) {
System.out.println("Different number of attributes");
}
for (int i = 0; i < at1.getLength(); i++) {
Attr attr1 = (Attr)at1.item(i);
Attr attr2 = (Attr)at2.getNamedItemNS(attr1.getNamespaceURI(), attr1.getLocalName());
if (attr2 == null) {
System.out.println("Attribute " + attr1.getNodeName() + " not found");
return false;
}
if (!compareStrings(attr1.getNodeValue(), attr2.getNodeValue())) {
System.out.println("Different attributes " + attr1.getNodeName() + " and " + attr2.getNodeName());
return false;
}
}
return true;
}
示例9: parseXml
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
@Override
public void parseXml(Node node) {
super.parseXml(node);
NamedNodeMap nodeMap=node.getAttributes();
Node expr=nodeMap.getNamedItem("expr");
if(expr!=null){
this.type=DecisionType.expression;
this.expression=expr.getNodeValue();
}else{
NodeList list=node.getChildNodes();
for(int i=0;i<list.getLength();i++){
Node cnode=list.item(i);
if(cnode.getNodeName().equals("handler")){
this.type=DecisionType.handlerClass;
NamedNodeMap map=cnode.getAttributes();
this.handlerClass=map.getNamedItem("class").getNodeValue();
break;
}
}
}
}
示例10: parseHuntingBonus
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
private void parseHuntingBonus(Node node)
{
forEach(node, IXmlReader::isNode, memberNode ->
{
if ("hunting".equalsIgnoreCase(memberNode.getNodeName()))
{
final NamedNodeMap attrs = memberNode.getAttributes();
final int requiredAmount = parseInteger(attrs, "points");
final int level = parseInteger(attrs, "level");
final ClanRewardBonus bonus = new ClanRewardBonus(ClanRewardType.HUNTING_MONSTERS, level, requiredAmount);
forEach(memberNode, IXmlReader::isNode, itemsNode ->
{
if ("item".equalsIgnoreCase(itemsNode.getNodeName()))
{
final NamedNodeMap itemsAttr = itemsNode.getAttributes();
final int id = parseInteger(itemsAttr, "id");
final int count = parseInteger(itemsAttr, "count");
bonus.setItemReward(new ItemHolder(id, count));
}
});
_clanRewards.computeIfAbsent(bonus.getType(), key -> new ArrayList<>()).add(bonus);
}
});
}
示例11: checkAttributesEqual
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
protected boolean checkAttributesEqual(final Element p1, final Element p2) {
if (p1 == null || p2 == null) return false;
NamedNodeMap nm1 = p1.getAttributes();
NamedNodeMap nm2 = p2.getAttributes();
if( nm1.getLength() != nm2.getLength() ) return false;
for ( int i = 0; i < nm1.getLength(); i++ ) {
Node attr2 = (Node) nm2.getNamedItem(nm1.item(i).getNodeName());
if ( attr2 == null ) return false;
if(nm2.item(i) != attr2) return false;
List<Token> t1List = ((NodeImpl)nm1.item(i)).getTokens();
List<Token> t2List = ( (NodeImpl) attr2 ).getTokens();
boolean status = compareTokenEquals( t1List, t2List );
if ( !status ) return false;
}
return true;
}
示例12: consolidateAttributePrefix
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
private void consolidateAttributePrefix(List<Node> parentAndAncestors, Element newNode) {
NamedNodeMap nnm = newNode.getAttributes();
for (int i=0; i<nnm.getLength(); i++) {
if (! (nnm.item(i) instanceof Attribute)) continue;
Attribute attr = (Attribute) nnm.item(i);
String prefix = attr.getPrefix();
if (prefix != null && ! attr.isXmlnsAttribute()) {
String namespace = newNode.lookupNamespaceURI(prefix);
if (namespace == null) continue;
prefix = NodeImpl.lookupPrefix(namespace, parentAndAncestors);
if (prefix != null) {
attr.setPrefix(prefix);
}
}
}
}
示例13: mergeStandardTextNode
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
private void mergeStandardTextNode(Node node)
throws IIOInvalidTreeException {
// Convert to comments. For the moment ignore the encoding issue.
// Ignore keywords, language, and encoding (for the moment).
// If compression tag is present, use only entries with "none".
NodeList children = node.getChildNodes();
for (int i = 0; i < children.getLength(); i++) {
Node child = children.item(i);
NamedNodeMap attrs = child.getAttributes();
Node comp = attrs.getNamedItem("compression");
boolean copyIt = true;
if (comp != null) {
String compString = comp.getNodeValue();
if (!compString.equals("none")) {
copyIt = false;
}
}
if (copyIt) {
String value = attrs.getNamedItem("value").getNodeValue();
COMMarkerSegment com = new COMMarkerSegment(value);
insertCOMMarkerSegment(com);
}
}
}
示例14: toNodeSet
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
/**
* Converts an Iterator to a Set of Nodes, according to the XPath
* Data Model.
*
* @param i the Iterator
* @return the Set of Nodes
*/
static Set<Node> toNodeSet(Iterator<Node> i) {
Set<Node> nodeSet = new HashSet<Node>();
while (i.hasNext()) {
Node n = i.next();
nodeSet.add(n);
// insert attributes nodes to comply with XPath
if (n.getNodeType() == Node.ELEMENT_NODE) {
NamedNodeMap nnm = n.getAttributes();
for (int j = 0, length = nnm.getLength(); j < length; j++) {
nodeSet.add(nnm.item(j));
}
}
}
return nodeSet;
}
示例15: fromNode
import org.w3c.dom.NamedNodeMap; //導入依賴的package包/類
@Override
public Account fromNode(Node node) {
NamedNodeMap attributes = node.getAttributes();
float initialAmount = 0;
if (attributes.getNamedItem("initial") != null) {
initialAmount = Float.parseFloat(attributes.getNamedItem("initial").getNodeValue());
}
Account account = new Account(
Integer.parseInt(attributes.getNamedItem("key").getNodeValue()),
attributes.getNamedItem("name").getNodeValue(),
Integer.parseInt(attributes.getNamedItem("curr").getNodeValue()),
initialAmount
);
Node flags = attributes.getNamedItem("flags");
if (flags != null) {
account.setFlags(Integer.parseInt(flags.getNodeValue()));
}
return account;
}