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


Java Attr.getLocalName方法代码示例

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


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

示例1: parseAttributes

import org.w3c.dom.Attr; //导入方法依赖的package包/类
public void parseAttributes(Element element, ParserContext parserContext, BeanDefinitionBuilder builder) {
    NamedNodeMap attributes = element.getAttributes();
    for (int x = 0; x < attributes.getLength(); x++) {
        Attr attribute = (Attr) attributes.item(x);
        if (isEligibleAttribute(attribute)) {
            String propertyName
                    = attribute.getLocalName().endsWith(REF_SUFFIX)
                            ? attribute.getLocalName()
                                    .substring(0, attribute.getLocalName()
                                            .length() - REF_SUFFIX.length())
                            : attribute.getLocalName();
            propertyName = Conventions
                    .attributeNameToPropertyName(propertyName);
            Assert.state(StringUtils.hasText(propertyName),
                    "Illegal property name returned from"
                            + " 'extractPropertyName(String)': cannot be"
                            + " null or empty.");
            if (attribute.getLocalName().endsWith(REF_SUFFIX)) {
                builder.addPropertyReference(propertyName,
                        attribute.getValue());
            } else {
                builder.addPropertyValue(propertyName, attribute.getValue());
            }
        }
    }
}
 
开发者ID:qq1588518,项目名称:JRediClients,代码行数:27,代码来源:RedissonNamespaceParserSupport.java

示例2: getPrefixForAttr

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
 * If the given attribute is a namespace declaration for the given namespace URI,
 * return its prefix. Otherwise null.
 */
private static String getPrefixForAttr(Attr attr, String nsUri) {
    String attrName = attr.getNodeName();
    if (!attrName.startsWith("xmlns:") && !attrName.equals("xmlns"))
        return null;    // not nsdecl

    if(attr.getValue().equals(nsUri)) {
        if(attrName.equals("xmlns"))
            return "";
        String localName = attr.getLocalName();
        return (localName != null) ? localName :
            QName.valueOf(attrName).getLocalPart();
    }

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:DOMStreamReader.java

示例3: visitAttr

import org.w3c.dom.Attr; //导入方法依赖的package包/类
protected void visitAttr(Attr node)
    throws XMLStreamException {
    String name = node.getLocalName();
    if (name.equals("xmlns")) {
        out.writeDefaultNamespace(node.getNamespaceURI());
    } else {
        String prefix = node.getPrefix();
        if (prefix != null && prefix.equals("xmlns")) {
            out.writeNamespace(prefix, node.getNamespaceURI());
        } else if (prefix != null) {
            out.writeAttribute(prefix
                , node.getNamespaceURI()
                , name
                , node.getNodeValue()
            );
        } else {
            out.writeAttribute(node.getNamespaceURI()
                    , name
                    , node.getNodeValue());
        }
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:23,代码来源:DOMPrinter.java

示例4: process

import org.w3c.dom.Attr; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();

	if (BeanDefinitionParserDelegate.ID_ATTRIBUTE.equals(name)) {
		return false;
	}

	if (BeanDefinitionParserDelegate.DEPENDS_ON_ATTRIBUTE.equals(name)) {
		builder.getBeanDefinition().setDependsOn(
			(StringUtils.tokenizeToStringArray(attribute.getValue(),
				BeanDefinitionParserDelegate.MULTI_VALUE_ATTRIBUTE_DELIMITERS)));
		return false;
	}
	if (BeanDefinitionParserDelegate.LAZY_INIT_ATTRIBUTE.equals(name)) {
		builder.setLazyInit(Boolean.valueOf(attribute.getValue()));
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:20,代码来源:StandardAttributeCallback.java

示例5: serializeAttributes

import org.w3c.dom.Attr; //导入方法依赖的package包/类
public void serializeAttributes(Object element, XMLSerializer target) throws SAXException {
    NamedNodeMap al = ((Element)element).getAttributes();
    int len = al.getLength();
    for( int i=0; i<len; i++ ) {
        Attr a = (Attr)al.item(i);
        // work defensively
        String uri = a.getNamespaceURI();
        if(uri==null)   uri="";
        String local = a.getLocalName();
        String name = a.getName();
        if(local==null) local = name;
        if (uri.equals(WellKnownNamespace.XML_SCHEMA_INSTANCE) && ("nil".equals(local))) {
            isNilIncluded = true;
        }
        if(name.startsWith("xmlns")) continue;// DOM reports ns decls as attributes

        target.attribute(uri,local,a.getValue());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:20,代码来源:AnyTypeBeanInfo.java

示例6: getNamespacePrefix

import org.w3c.dom.Attr; //导入方法依赖的package包/类
String getNamespacePrefix(int index) {
    int sz = currentNamespaces.size();
    if(index< sz) {
        Attr attr = currentNamespaces.get(index);
        String result = attr.getLocalName();
        if (result == null) {
            result = QName.valueOf(attr.getNodeName()).getLocalPart();
        }
        return result.equals("xmlns") ? null : result;
    } else {
        return additionalNamespaces.get((index-sz)*2);
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:DOMStreamReader.java

示例7: process

import org.w3c.dom.Attr; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder bldr) {
	String name = attribute.getLocalName();

	if (INTERFACE.equals(name)) {
		bldr.addPropertyValue(INTERFACES_PROP, attribute.getValue());
		return false;
	} else if (REF.equals(name)) {
		return false;
	}

	else if (AUTOEXPORT.equals(name)) {
		// convert constant to upper case to let Spring do the
		// conversion
		String label = attribute.getValue().toUpperCase(Locale.ENGLISH).replace('-', '_');
		bldr.addPropertyValue(AUTOEXPORT_PROP, Enum.valueOf(DefaultInterfaceDetector.class, label));
		return false;
	}

	else if (CONTEXT_CLASSLOADER.equals(name)) {
		// convert constant to upper case to let Spring do the
		// conversion

		String value = attribute.getValue().toUpperCase(Locale.ENGLISH).replace('-', '_');
		bldr.addPropertyValue(CCL_PROP, value);
		return false;
	}

	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:30,代码来源:ServiceBeanDefinitionParser.java

示例8: process

import org.w3c.dom.Attr; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();
	if (MEMBER_TYPE.equals(name)) {
		builder.addPropertyValue(MEMBER_TYPE_PROPERTY, MemberType.valueOf(attribute.getValue().toUpperCase(Locale.ENGLISH)
				.replace('-', '_')));
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:CollectionBeanDefinitionParser.java

示例9: process

import org.w3c.dom.Attr; //导入方法依赖的package包/类
public boolean process(Element parent, Attr attribute, BeanDefinitionBuilder builder) {
	String name = attribute.getLocalName();
	if (name.endsWith(PROPERTY_REF)) {
		String propertyName = name.substring(0, name.length() - PROPERTY_REF.length());
		builder.addPropertyReference(propertyName, attribute.getValue());
		return false;
	}
	return true;
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:10,代码来源:PropertyRefAttributeCallback.java

示例10: processAttribute

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject samlObject, Attr attribute) throws UnmarshallingException {
    Delegate delegate = (Delegate) samlObject;
    
    String attrName = attribute.getLocalName();
    if (Delegate.CONFIRMATION_METHOD_ATTRIB_NAME.equals(attrName)) {
        delegate.setConfirmationMethod(attribute.getValue());
    } else if (Delegate.DELEGATION_INSTANT_ATTRIB_NAME.equals(attrName)) {
        delegate.setDelegationInstant(new DateTime(attribute.getValue(), ISOChronology.getInstanceUTC()));
    } else {
        super.processAttribute(samlObject, attribute);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:DelegateUnmarshaller.java

示例11: processAttribute

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/** {@inheritDoc} */
protected void processAttribute(XMLObject xmlObject, Attr attribute) throws UnmarshallingException {
    BinaryExchange binaryExchange = (BinaryExchange) xmlObject;
    
    String attrName = attribute.getLocalName();
    if (BinaryExchange.VALUE_TYPE_ATTRIB_NAME.equals(attrName)) {
        binaryExchange.setValueType(attribute.getValue());
    } else if (BinaryExchange.ENCODING_TYPE_ATTRIB_NAME.equals(attrName)) {
        binaryExchange.setEncodingType(attribute.getValue());
    } else {
        XMLHelper.unmarshallToAttributeMap(binaryExchange.getUnknownAttributes(), attribute);
    }
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:14,代码来源:BinaryExchangeUnmarshaller.java

示例12: parseListener

import org.w3c.dom.Attr; //导入方法依赖的package包/类
protected BeanDefinition parseListener(ParserContext context, Element element, BeanDefinitionBuilder builder) {

		// filter elements
		NodeList nl = element.getChildNodes();

		// wrapped object
		Object target = null;
		// target bean name (used for cycles)
		String targetName = null;

		// discover if we have listener with ref and nested bean declaration
		for (int i = 0; i < nl.getLength(); i++) {
			Node node = nl.item(i);
			if (node instanceof Element) {
				Element nestedDefinition = (Element) node;
				// check shortcut on the parent
				if (element.hasAttribute(REF))
					context.getReaderContext().error(
							"nested bean declaration is not allowed if 'ref' attribute has been specified",
							nestedDefinition);

				target = parsePropertySubElement(context, nestedDefinition, builder.getBeanDefinition());
				// if this is a bean reference (nested <ref>), extract the name
				if (target instanceof RuntimeBeanReference) {
					targetName = ((RuntimeBeanReference) target).getBeanName();
				}
			}
		}

		// extract registration/unregistration attributes from
		// <osgi:registration-listener>
		MutablePropertyValues vals = new MutablePropertyValues();

		NamedNodeMap attrs = element.getAttributes();
		for (int x = 0; x < attrs.getLength(); x++) {
			Attr attribute = (Attr) attrs.item(x);
			String name = attribute.getLocalName();

			if (REF.equals(name))
				targetName = attribute.getValue();
			else {
				vals.addPropertyValue(Conventions.attributeNameToPropertyName(name), attribute.getValue());
			}

		}

		// create serviceListener wrapper
		RootBeanDefinition wrapperDef = new RootBeanDefinition(OsgiServiceRegistrationListenerAdapter.class);

		// set the target name (if we have one)
		if (targetName != null) {
			vals.addPropertyValue(TARGET_BEAN_NAME_PROP, targetName);
		}
		// else set the actual target
		else {
			vals.addPropertyValue(TARGET_PROP, target);
		}

		wrapperDef.setPropertyValues(vals);

		return wrapperDef;

	}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:64,代码来源:ServiceBeanDefinitionParser.java

示例13: compare

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
 * Compares two attributes based on the C14n specification.
 *
 * <UL>
 * <LI>Namespace nodes have a lesser document order position than
 *   attribute nodes.
 * <LI> An element's namespace nodes are sorted lexicographically by
 *   local name (the default namespace node, if one exists, has no
 *   local name and is therefore lexicographically least).
 * <LI> An element's attribute nodes are sorted lexicographically with
 *   namespace URI as the primary key and local name as the secondary
 *   key (an empty namespace URI is lexicographically least).
 * </UL>
 *
 * @param attr0
 * @param attr1
 * @return returns a negative integer, zero, or a positive integer as
 *   obj0 is less than, equal to, or greater than obj1
 *
 */
public int compare(Attr attr0, Attr attr1) {
    String namespaceURI0 = attr0.getNamespaceURI();
    String namespaceURI1 = attr1.getNamespaceURI();

    boolean isNamespaceAttr0 = XMLNS.equals(namespaceURI0);
    boolean isNamespaceAttr1 = XMLNS.equals(namespaceURI1);

    if (isNamespaceAttr0) {
        if (isNamespaceAttr1) {
            // both are namespaces
            String localname0 = attr0.getLocalName();
            String localname1 = attr1.getLocalName();

            if ("xmlns".equals(localname0)) {
                localname0 = "";
            }

            if ("xmlns".equals(localname1)) {
                localname1 = "";
            }

            return localname0.compareTo(localname1);
        }
        // attr0 is a namespace, attr1 is not
        return ATTR0_BEFORE_ATTR1;
    } else if (isNamespaceAttr1) {
        // attr1 is a namespace, attr0 is not
        return ATTR1_BEFORE_ATTR0;
    }

    // none is a namespace
    if (namespaceURI0 == null) {
        if (namespaceURI1 == null) {
            String name0 = attr0.getName();
            String name1 = attr1.getName();
            return name0.compareTo(name1);
        }
        return ATTR0_BEFORE_ATTR1;
    } else if (namespaceURI1 == null) {
        return ATTR1_BEFORE_ATTR0;
    }

    int a = namespaceURI0.compareTo(namespaceURI1);
    if (a != 0) {
        return a;
    }

    return (attr0.getLocalName()).compareTo(attr1.getLocalName());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:70,代码来源:AttrCompare.java

示例14: handleAttributesSubtree

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
 * Returns the Attr[]s to be output for the given element.
 * <br>
 * The code of this method is a copy of {@link #handleAttributes(Element,
 * NameSpaceSymbTable)},
 * whereas it takes into account that subtree-c14n is -- well --
 * subtree-based.
 * So if the element in question isRoot of c14n, it's parent is not in the
 * node set, as well as all other ancestors.
 *
 * @param element
 * @param ns
 * @return the Attr[]s to be output
 * @throws CanonicalizationException
 */
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
    throws CanonicalizationException {
    if (!element.hasAttributes() && !firstCall) {
        return null;
    }
    // result will contain the attrs which have to be output
    final SortedSet<Attr> result = this.result;
    result.clear();

    if (element.hasAttributes()) {
        NamedNodeMap attrs = element.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr attribute = (Attr) attrs.item(i);
            String NUri = attribute.getNamespaceURI();
            String NName = attribute.getLocalName();
            String NValue = attribute.getValue();

            if (!XMLNS_URI.equals(NUri)) {
                // It's not a namespace attr node. Add to the result and continue.
                result.add(attribute);
            } else if (!(XML.equals(NName) && XML_LANG_URI.equals(NValue))) {
                // The default mapping for xml must not be output.
                Node n = ns.addMappingAndRender(NName, NValue, attribute);

                if (n != null) {
                    // Render the ns definition
                    result.add((Attr)n);
                    if (C14nHelper.namespaceIsRelative(attribute)) {
                        Object exArgs[] = {element.getTagName(), NName, attribute.getNodeValue()};
                        throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs
                        );
                    }
                }
            }
        }
    }

    if (firstCall) {
        // It is the first node of the subtree
        // Obtain all the namespaces defined in the parents, and added to the output.
        ns.getUnrenderedNodes(result);
        // output the attributes in the xml namespace.
        xmlattrStack.getXmlnsAttr(result);
        firstCall = false;
    }

    return result.iterator();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:68,代码来源:Canonicalizer11.java

示例15: handleAttributesSubtree

import org.w3c.dom.Attr; //导入方法依赖的package包/类
/**
 * Returns the Attr[]s to be output for the given element.
 * <br>
 * The code of this method is a copy of {@link #handleAttributes(Element,
 * NameSpaceSymbTable)},
 * whereas it takes into account that subtree-c14n is -- well -- subtree-based.
 * So if the element in question isRoot of c14n, it's parent is not in the
 * node set, as well as all other ancestors.
 *
 * @param element
 * @param ns
 * @return the Attr[]s to be output
 * @throws CanonicalizationException
 */
@Override
protected Iterator<Attr> handleAttributesSubtree(Element element, NameSpaceSymbTable ns)
    throws CanonicalizationException {
    if (!element.hasAttributes() && !firstCall) {
        return null;
    }
    // result will contain the attrs which have to be output
    final SortedSet<Attr> result = this.result;
    result.clear();

    if (element.hasAttributes()) {
        NamedNodeMap attrs = element.getAttributes();
        int attrsLength = attrs.getLength();

        for (int i = 0; i < attrsLength; i++) {
            Attr attribute = (Attr) attrs.item(i);
            String NUri = attribute.getNamespaceURI();
            String NName = attribute.getLocalName();
            String NValue = attribute.getValue();

            if (!XMLNS_URI.equals(NUri)) {
                //It's not a namespace attr node. Add to the result and continue.
                result.add(attribute);
            } else if (!(XML.equals(NName) && XML_LANG_URI.equals(NValue))) {
                //The default mapping for xml must not be output.
                Node n = ns.addMappingAndRender(NName, NValue, attribute);

                if (n != null) {
                    //Render the ns definition
                    result.add((Attr)n);
                    if (C14nHelper.namespaceIsRelative(attribute)) {
                        Object exArgs[] = { element.getTagName(), NName, attribute.getNodeValue() };
                        throw new CanonicalizationException(
                            "c14n.Canonicalizer.RelativeNamespace", exArgs
                        );
                    }
                }
            }
        }
    }

    if (firstCall) {
        //It is the first node of the subtree
        //Obtain all the namespaces defined in the parents, and added to the output.
        ns.getUnrenderedNodes(result);
        //output the attributes in the xml namespace.
        xmlattrStack.getXmlnsAttr(result);
        firstCall = false;
    }

    return result.iterator();
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:67,代码来源:Canonicalizer20010315.java


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