热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

javax.xml.stream.events.Attribute.getName()方法的使用及代码示例

本文整理了Java中javax.xml.stream.events.Attribute.getName()方法的一些代码示例,展示了Attribute.ge

本文整理了Java中javax.xml.stream.events.Attribute.getName()方法的一些代码示例,展示了Attribute.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Attribute.getName()方法的具体详情如下:
包路径:javax.xml.stream.events.Attribute
类名称:Attribute
方法名:getName

Attribute.getName介绍

[英]Returns the QName for this attribute
[中]返回此属性的QName

代码示例

代码示例来源:origin: pentaho/pentaho-kettle

/**
* Returns the qualified name of the attribute
*
* @param a
* an attribute event
* @param enabledNamespaces
* indicates if namespaces should be added or not
* @return the qualified name of the attribute
*/
private String getAttributeName( Attribute a, boolean enabledNamespaces ) {
if ( !enabledNamespaces ) {
return a.getName().getLocalPart();
} else {
return getName( a.getName().getPrefix(), a.getName().getLocalPart() );
}
}

代码示例来源:origin: hibernate/hibernate-orm

private List updateElementAttributes(StartElement startElement) {
// adjust the version attribute
List newElementAttributeList = new ArrayList();
Iterator existingAttributesIterator = startElement.getAttributes();
while ( existingAttributesIterator.hasNext() ) {
Attribute attribute = (Attribute) existingAttributesIterator.next();
if ( VERSION_ATTRIBUTE_NAME.equals( attribute.getName().getLocalPart() ) ) {
if ( !DEFAULT_VERSION.equals( attribute.getName().getPrefix() ) ) {
newElementAttributeList.add(
xmlEventFactory.createAttribute(
attribute.getName(),
DEFAULT_VERSION
)
);
}
}
else {
newElementAttributeList.add( attribute );
}
}
return newElementAttributeList;
}
}

代码示例来源:origin: hibernate/hibernate-orm

private Attribute mapAttribute(StartElement startElement, Attribute originalAttribute) {
// Here we look to see if this attribute is the JPA version attribute, and if so do 2 things:
// 1) validate its version attribute is valid
// 2) update its version attribute to the default version if not already
//
// NOTE : atm this is a very simple check using just the attribute's local name
// rather than checking its qualified name. It is possibly (though unlikely)
// that this could match on "other" version attributes in the same element
if ( ROOT_ELEMENT_NAME.equals( startElement.getName().getLocalPart() ) ) {
if ( VERSION_ATTRIBUTE_NAME.equals( originalAttribute.getName().getLocalPart() ) ) {
final String specifiedVersion = originalAttribute.getValue();
if ( !LocalXsdResolver.isValidJpaVersion( specifiedVersion ) ) {
throw new BadVersionException( specifiedVersion );
}
return xmlEventFactory.createAttribute( VERSION_ATTRIBUTE_NAME, LocalXsdResolver.latestJpaVerison() );
}
}
return originalAttribute;
}

代码示例来源:origin: org.codehaus.woodstox/woodstox-core-asl

if (attrs == null || !attrs.hasNext()) {
attrMap = null;
} else {
attrMap = new LinkedHashMap();
do {
Attribute attr = (Attribute) attrs.next();
attrMap.put(attr.getName(), attr);
} while (attrs.hasNext());
if (ns != null && ns.hasNext()) {
ArrayList l = new ArrayList();
do {
l.add((Namespace) ns.next()); // cast to catch type problems early
} while (ns.hasNext());
myCtxt = MergedNsContext.construct(nsCtxt, l);

代码示例来源:origin: org.leapframework/leap-lang

@Override
public String next() {
Attribute a = it.next();
return a.getName().getLocalPart();
}
};

代码示例来源:origin: com.googlecode.totallylazy/totallylazy

private Element copyAttributes(StartElement source, Element destination) {
for (Attribute attribute : forwardOnly(Unchecked.>cast(source.getAttributes()))) {
destination.setAttribute(attribute.getName().getLocalPart(), attribute.getValue());
}
return destination;
}

代码示例来源:origin: spring-projects/spring-framework

private Attributes getAttributes(StartElement event) {
AttributesImpl attributes = new AttributesImpl();
for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute attribute = (Attribute) i.next();
QName qName = attribute.getName();
String namespace = qName.getNamespaceURI();
if (namespace == null || !hasNamespacesFeature()) {
type = "CDATA";
attributes.addAttribute(namespace, qName.getLocalPart(), toQualifiedName(qName), type, attribute.getValue());
for (Iterator i = event.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
String prefix = namespace.getPrefix();
String namespaceUri = namespace.getNamespaceURI();

代码示例来源:origin: com.sun.xml.stream/sjsxp

void addAttributes(Iterator attrs){
if(attrs == null)
return;
while(attrs.hasNext()){
Attribute attr = (Attribute)attrs.next();
fAttributes.put(attr.getName(),attr);
}
}

代码示例来源:origin: stax/stax

private void writeAttribute(Attribute a)
throws XMLStreamException
{
writer.writeAttribute(a.getName().getNamespaceURI(),
a.getName().getLocalPart(),
a.getValue());
}
public void addAttribute(Attribute a)

代码示例来源:origin: aws/aws-sdk-java

private void updateContext(XMLEvent event) {
if (event == null) return;
if (event.isEndElement()) {
stack.pop();
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
} else if (event.isStartElement()) {
stack.push(event.asStartElement().getName().getLocalPart());
stackString += "/" + event.asStartElement().getName().getLocalPart();
} else if (event.isAttribute()) {
Attribute attribute = (Attribute)event;
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
stackString += "/@" + attribute.getName().getLocalPart();
}
}

代码示例来源:origin: spring-projects/spring-framework

private void handleStartElement(StartElement startElement) throws SAXException {
if (getContentHandler() != null) {
QName qName = startElement.getName();
if (hasNamespacesFeature()) {
for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
}
for (Iterator i = startElement.getAttributes(); i.hasNext();){
Attribute attribute = (Attribute) i.next();
QName attributeName = attribute.getName();
startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
}
getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
getAttributes(startElement));
}
else {
getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
}
}
}

代码示例来源:origin: stax/stax

private static void printAttribute(Attribute a) {
printName(a.getName().getPrefix(),a.getName().getNamespaceURI(),
a.getName().getLocalPart());
System.out.print("='"+a.getValue()+"'");
}

代码示例来源:origin: camunda/camunda-bpm-platform

Attribute getAttributeByName(String name) {
if(attributes == null)
return null;
for(Attribute attr: attributes) {
if(name.equals(attr.getName().getLocalPart()))
return attr;
}
return null;
}

代码示例来源:origin: com.sun.xml.bind/jaxb-impl

for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute staxAttr = (Attribute)i.next();
QName name = staxAttr.getName();
String uri = fixNull(name.getNamespaceURI());
String localName = name.getLocalPart();
String prefix = name.getPrefix();
String qName;
qName = prefix + ':' + localName;
String type = staxAttr.getDTDType();
String value = staxAttr.getValue();

代码示例来源:origin: stax/stax

private static void printAttribute(Attribute a) {
System.out.println("PREFIX: " + a.getName().getPrefix());
System.out.println("NAMESP: " + a.getName().getNamespaceURI());
System.out.println("NAME: " + a.getName().getLocalPart());
System.out.println("VALUE: " + a.getValue());
System.out.println("TYPE: " + a.getDTDType());
}

代码示例来源:origin: com.amazonaws/aws-java-sdk-core

private void updateContext(XMLEvent event) {
if (event == null) return;
if (event.isEndElement()) {
stack.pop();
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
} else if (event.isStartElement()) {
stack.push(event.asStartElement().getName().getLocalPart());
stackString += "/" + event.asStartElement().getName().getLocalPart();
} else if (event.isAttribute()) {
Attribute attribute = (Attribute)event;
stackString = "";
for (String s : stack) {
stackString += "/" + s;
}
stackString += "/@" + attribute.getName().getLocalPart();
}
}

代码示例来源:origin: org.springframework/spring-core

private Attributes getAttributes(StartElement event) {
AttributesImpl attributes = new AttributesImpl();
for (Iterator i = event.getAttributes(); i.hasNext();) {
Attribute attribute = (Attribute) i.next();
QName qName = attribute.getName();
String namespace = qName.getNamespaceURI();
if (namespace == null || !hasNamespacesFeature()) {
type = "CDATA";
attributes.addAttribute(namespace, qName.getLocalPart(), toQualifiedName(qName), type, attribute.getValue());
for (Iterator i = event.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
String prefix = namespace.getPrefix();
String namespaceUri = namespace.getNamespaceURI();

代码示例来源:origin: org.metatype.sxc/sxc-jaxb

public String getAttributeValue(String namespaceURI, String localName) {
for (Attribute attribute : getAttributes()) {
if (attribute.getName().getNamespaceURI().equals(namespaceURI) && attribute.getName().getLocalPart().equals(localName)) {
return attribute.getValue();
}
}
return null;
}

代码示例来源:origin: apache/cxf

public String getAttributeLocalName(int arg0) {
String ret = null;
List currentAttributes = eventProducer.getAttributes();
if (currentAttributes != null) {
Attribute a = currentAttributes.get(arg0);
if (a != null) {
ret = a.getName().getLocalPart();
}
}
return ret;
}

代码示例来源:origin: org.springframework/spring-core

private void handleStartElement(StartElement startElement) throws SAXException {
if (getContentHandler() != null) {
QName qName = startElement.getName();
if (hasNamespacesFeature()) {
for (Iterator i = startElement.getNamespaces(); i.hasNext();) {
Namespace namespace = (Namespace) i.next();
startPrefixMapping(namespace.getPrefix(), namespace.getNamespaceURI());
}
for (Iterator i = startElement.getAttributes(); i.hasNext();){
Attribute attribute = (Attribute) i.next();
QName attributeName = attribute.getName();
startPrefixMapping(attributeName.getPrefix(), attributeName.getNamespaceURI());
}
getContentHandler().startElement(qName.getNamespaceURI(), qName.getLocalPart(), toQualifiedName(qName),
getAttributes(startElement));
}
else {
getContentHandler().startElement("", "", toQualifiedName(qName), getAttributes(startElement));
}
}
}

推荐阅读
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • VScode格式化文档换行或不换行的设置方法
    本文介绍了在VScode中设置格式化文档换行或不换行的方法,包括使用插件和修改settings.json文件的内容。详细步骤为:找到settings.json文件,将其中的代码替换为指定的代码。 ... [详细]
  • SpringBoot uri统一权限管理的实现方法及步骤详解
    本文详细介绍了SpringBoot中实现uri统一权限管理的方法,包括表结构定义、自动统计URI并自动删除脏数据、程序启动加载等步骤。通过该方法可以提高系统的安全性,实现对系统任意接口的权限拦截验证。 ... [详细]
  • 本文介绍了Java工具类库Hutool,该工具包封装了对文件、流、加密解密、转码、正则、线程、XML等JDK方法的封装,并提供了各种Util工具类。同时,还介绍了Hutool的组件,包括动态代理、布隆过滤、缓存、定时任务等功能。该工具包可以简化Java代码,提高开发效率。 ... [详细]
  • Java容器中的compareto方法排序原理解析
    本文从源码解析Java容器中的compareto方法的排序原理,讲解了在使用数组存储数据时的限制以及存储效率的问题。同时提到了Redis的五大数据结构和list、set等知识点,回忆了作者大学时代的Java学习经历。文章以作者做的思维导图作为目录,展示了整个讲解过程。 ... [详细]
  • eclipse学习(第三章:ssh中的Hibernate)——11.Hibernate的缓存(2级缓存,get和load)
    本文介绍了eclipse学习中的第三章内容,主要讲解了ssh中的Hibernate的缓存,包括2级缓存和get方法、load方法的区别。文章还涉及了项目实践和相关知识点的讲解。 ... [详细]
  • 本文讨论了一个关于cuowu类的问题,作者在使用cuowu类时遇到了错误提示和使用AdjustmentListener的问题。文章提供了16个解决方案,并给出了两个可能导致错误的原因。 ... [详细]
  • XML介绍与使用的概述及标签规则
    本文介绍了XML的基本概念和用途,包括XML的可扩展性和标签的自定义特性。同时还详细解释了XML标签的规则,包括标签的尖括号和合法标识符的组成,标签必须成对出现的原则以及特殊标签的使用方法。通过本文的阅读,读者可以对XML的基本知识有一个全面的了解。 ... [详细]
  • 开发笔记:实验7的文件读写操作
    本文介绍了使用C++的ofstream和ifstream类进行文件读写操作的方法,包括创建文件、写入文件和读取文件的过程。同时还介绍了如何判断文件是否成功打开和关闭文件的方法。通过本文的学习,读者可以了解如何在C++中进行文件读写操作。 ... [详细]
  • Java程序设计第4周学习总结及注释应用的开发笔记
    本文由编程笔记#小编为大家整理,主要介绍了201521123087《Java程序设计》第4周学习总结相关的知识,包括注释的应用和使用类的注释与方法的注释进行注释的方法,并在Eclipse中查看。摘要内容大约为150字,提供了一定的参考价值。 ... [详细]
  • 本文介绍了Swing组件的用法,重点讲解了图标接口的定义和创建方法。图标接口用来将图标与各种组件相关联,可以是简单的绘画或使用磁盘上的GIF格式图像。文章详细介绍了图标接口的属性和绘制方法,并给出了一个菱形图标的实现示例。该示例可以配置图标的尺寸、颜色和填充状态。 ... [详细]
  • Android工程师面试准备及设计模式使用场景
    本文介绍了Android工程师面试准备的经验,包括面试流程和重点准备内容。同时,还介绍了建造者模式的使用场景,以及在Android开发中的具体应用。 ... [详细]
  • 本文介绍了Android中的assets目录和raw目录的共同点和区别,包括获取资源的方法、目录结构的限制以及列出资源的能力。同时,还解释了raw目录中资源文件生成的ID,并说明了这些目录的使用方法。 ... [详细]
  • ***byte(字节)根据长度转成kb(千字节)和mb(兆字节)**parambytes*return*publicstaticStringbytes2kb(longbytes){ ... [详细]
  • Hibernate延迟加载深入分析-集合属性的延迟加载策略
    本文深入分析了Hibernate延迟加载的机制,特别是集合属性的延迟加载策略。通过延迟加载,可以降低系统的内存开销,提高Hibernate的运行性能。对于集合属性,推荐使用延迟加载策略,即在系统需要使用集合属性时才从数据库装载关联的数据,避免一次加载所有集合属性导致性能下降。 ... [详细]
author-avatar
mobiledu2502912043
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有