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


Java Attribute.getValue方法代码示例

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


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

示例1: setLink

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Basic setter
 */
protected void setLink(final RssElement element) {
	if (!actualElement.isEmpty() && actualElement.lastElement().equals(TAG_ENTRY)) {
		final Attribute relAttr = element.attributes.get(ATTR_REL);
		final Attribute hrefAttr = element.attributes.get(ATTR_HREF);
		if(relAttr != null && hrefAttr != null) {
			switch (relAttr.getValue()) {
				case REL_ALTERNATE:
					parsingElement.getLastItem().setLink(hrefAttr.getValue());
					break;

				// TODO get image
			}
		}
	}
}
 
开发者ID:XMBomb,项目名称:InComb,代码行数:19,代码来源:AtomParser.java

示例2: readText

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Returns the text contents of the current element being parsed.
 *
 * @return The text contents of the current element being parsed.
 */
public String readText() throws XMLStreamException {
    if (isInsideResponseHeader()) {
        return getHeader(currentHeader);
    }
    if (currentEvent.isAttribute()) {
        Attribute attribute = (Attribute) currentEvent;
        return attribute.getValue();
    }

    StringBuilder sb = new StringBuilder();
    while (true) {
        XMLEvent event = eventReader.peek();
        if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
            eventReader.nextEvent();
            sb.append(event.asCharacters().getData());
        } else if (event.getEventType() == XMLStreamConstants.END_ELEMENT) {
            return sb.toString();
        } else {
            throw new RuntimeException("Encountered unexpected event: " + event.toString());
        }
    }
}
 
开发者ID:aws,项目名称:aws-sdk-java-v2,代码行数:28,代码来源:StaxUnmarshallerContext.java

示例3: readText

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Returns the text contents of the current element being parsed.
 *
 * @return The text contents of the current element being parsed.
 * @throws XMLStreamException
 */
public String readText() throws XMLStreamException {
    if (isInsideResponseHeader()) {
        return getHeader(currentHeader);
    }
    if (currentEvent.isAttribute()) {
        Attribute attribute = (Attribute)currentEvent;
        return attribute.getValue();
    }

    StringBuilder sb = new StringBuilder();
    while (true) {
        XMLEvent event = eventReader.peek();
        if (event.getEventType() == XMLStreamConstants.CHARACTERS) {
            eventReader.nextEvent();
            sb.append(event.asCharacters().getData());
        } else if (event.getEventType() == XMLStreamConstants.END_ELEMENT) {
            return sb.toString();
        } else {
            throw new RuntimeException("Encountered unexpected event: " + event.toString());
        }
    }
}
 
开发者ID:IBM,项目名称:ibm-cos-sdk-java,代码行数:29,代码来源:StaxUnmarshallerContext.java

示例4: getImageCoverage

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
private String getImageCoverage(XMLEventReader reader) throws XMLStreamException {
    while (reader.hasNext()) {
        XMLEvent event = reader.nextEvent();
        if (event.isStartElement()) {
            StartElement element = event.asStartElement();
            String localPart = element.getName().getLocalPart();
            if ("image".equals(localPart)) {
                QName hrefQName = new QName("http://www.w3.org/1999/xlink", "href");
                Attribute href = element.getAttributeByName(hrefQName);
                return href.getValue();
            }
        }
        if (event.isEndElement() && "coverage".equals(event.asEndElement().getName().getLocalPart())) {
            return null;
        }
    }
    return null;
}
 
开发者ID:patexoid,项目名称:ZombieLib2,代码行数:19,代码来源:Fb2FileParser.java

示例5: writeAttributeEvent

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
private static void writeAttributeEvent(XMLEvent event, XMLStreamWriter writer) 
    throws XMLStreamException {
    
    Attribute attr = (Attribute)event;
    QName name = attr.getName();
    String nsURI = name.getNamespaceURI();
    String localName = name.getLocalPart();
    String prefix = name.getPrefix();
    String value = attr.getValue();

    if (prefix != null) {
        writer.writeAttribute(prefix, nsURI, localName, value);
    } else if (nsURI != null) {
        writer.writeAttribute(nsURI, localName, value);
    } else {
        writer.writeAttribute(localName, value);
    }
}
 
开发者ID:beemsoft,项目名称:techytax-zk,代码行数:19,代码来源:StaxUtils.java

示例6: processModuleTag

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Parses single "module" tag.
 *
 * @param reader
 *        StAX parser interface.
 * @param startElement
 *        start element of the tag.
 * @param parent
 *        parent module instance.
 * @throws XMLStreamException
 *         on internal StAX failure.
 */
private static void processModuleTag(XMLEventReader reader, StartElement startElement,
        ConfigurationModule parent) throws XMLStreamException {
    String childModuleName = null;
    final Iterator<Attribute> attributes = startElement
            .getAttributes();
    while (attributes.hasNext()) {
        final Attribute attribute = attributes.next();
        if (attribute.getName().toString()
                .equals(NAME_ATTR)) {
            childModuleName = attribute.getValue();
        }
    }
    final ConfigurationModule childModule =
            new ConfigurationModule(childModuleName);
    parseModule(reader, childModule);
    parent.addChild(childModule);
}
 
开发者ID:checkstyle,项目名称:contribution,代码行数:30,代码来源:CheckstyleConfigurationsParser.java

示例7: processPropertyTag

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Parses single "property" tag.
 *
 * @param startElement
 *        start element of the tag.
 * @param parent
 *        parent module instance.
 */
private static void processPropertyTag(StartElement startElement,
        ConfigurationModule parent) {
    String propertyName = null;
    String propertyValue = null;
    final Iterator<Attribute> attributes = startElement
            .getAttributes();
    while (attributes.hasNext()) {
        final Attribute attribute = attributes.next();
        final String attributeName = attribute.getName().toString();
        if (attributeName.equals(NAME_ATTR)) {
            propertyName = attribute.getValue();
        }
        else if (attributeName.equals(VALUE_ATTR)) {
            propertyValue = attribute.getValue();
        }
    }
    parent.addProperty(propertyName, propertyValue);
}
 
开发者ID:checkstyle,项目名称:contribution,代码行数:27,代码来源:CheckstyleConfigurationsParser.java

示例8: processMessageTag

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Parses single "message" tag.
 *
 * @param startElement
 *        start element of the tag.
 * @param parent
 *        parent module instance.
 */
private static void processMessageTag(StartElement startElement,
        ConfigurationModule parent) {
    String propertyName = null;
    String propertyValue = null;
    final Iterator<Attribute> attributes = startElement
            .getAttributes();
    while (attributes.hasNext()) {
        final Attribute attribute = attributes.next();
        final String attributeName = attribute.getName().toString();
        if (attributeName.equals(KEY_ATTR)) {
            propertyName = attribute.getValue();
        }
        else if (attributeName.equals(VALUE_ATTR)) {
            propertyValue = attribute.getValue();
        }
    }
    parent.addProperty(propertyName, propertyValue);
}
 
开发者ID:checkstyle,项目名称:contribution,代码行数:27,代码来源:CheckstyleConfigurationsParser.java

示例9: readWayDefinition

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * reads a key/value pair for a certain way type.
 *
 * @param element way definition element
 */
private void readWayDefinition(final StartElement element) {
    currentElementType = ElementType.WAY_DEFINITION;

    currentKey = null;
    currentValue = null;

    for (Iterator<?> attributes = element.getAttributes(); attributes.hasNext();) {
        Attribute attribute = (Attribute) attributes.next();
        if (attribute.getName().toString().equals("key")) {
           currentKey = attribute.getValue();
        } else if (attribute.getName().toString().equals("value")) {
            currentValue = attribute.getValue();
        }
    }
}
 
开发者ID:xafero,项目名称:travelingsales,代码行数:21,代码来源:ODRVisualizationDataReader.java

示例10: readAttributeValue

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Read attribute value from QName.
 *
 * @param qName QName of the attribute
 * @return Attribute Value
 * @throws Exception thrown if attribute value can not be read
 */
private String readAttributeValue(QName qName) throws Exception {
  if (this.presentEvent.isStartElement()) {
    StartElement startElement = this.presentEvent.asStartElement();
    Attribute attr = startElement.getAttributeByName(qName);
    if (null != attr) {
      return attr.getValue();
    } else {
      return null;
    }
  } else {
    String errMsg = String.format("Could not fetch attribute %s", qName
        .toString());
    throw new Exception(errMsg);
  }
}
 
开发者ID:OfficeDev,项目名称:ews-java-api,代码行数:23,代码来源:EwsXmlReader.java

示例11: readAttributeValue

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * * Read attribute value from QName.
 * 
 * @param qName
 *            QName of the attribute
 * @return Attribute Value
 * @throws Exception
 *             thrown if attribute value can not be read
 */
private String readAttributeValue(QName qName) throws Exception {
	if (this.presentEvent.isStartElement()) {
		StartElement startElement = this.presentEvent.asStartElement();
		Attribute attr = startElement.getAttributeByName(qName);
		if (null != attr) {
			return attr.getValue();
		} else {
			return null;
		}
	} else {
		String errMsg = String.format("Could not fetch attribute %s", qName
				.toString());
		throw new Exception(errMsg);
	}
}
 
开发者ID:sheymans,项目名称:todopl,代码行数:25,代码来源:EwsXmlReader.java

示例12: setFormatString

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Read the numeric format string out of the styles table for this cell. Stores
 * the result in the Cell.
 *
 * @param startElement
 * @param cell
 */
void setFormatString(StartElement startElement, StreamingCell cell) {
  Attribute cellStyle = startElement.getAttributeByName(new QName("s"));
  String cellStyleString = (cellStyle != null) ? cellStyle.getValue() : null;
  XSSFCellStyle style = null;

  if(cellStyleString != null) {
    style = stylesTable.getStyleAt(Integer.parseInt(cellStyleString));
  } else if(stylesTable.getNumCellStyles() > 0) {
    style = stylesTable.getStyleAt(0);
  }

  if(style != null) {
    cell.setNumericFormatIndex(style.getDataFormat());
    String formatString = style.getDataFormatString();

    if(formatString != null) {
      cell.setNumericFormat(formatString);
    } else {
      cell.setNumericFormat(BuiltinFormats.getBuiltinFormat(cell.getNumericFormatIndex()));
    }
  } else {
    cell.setNumericFormatIndex(null);
    cell.setNumericFormat(null);
  }
}
 
开发者ID:monitorjbl,项目名称:excel-streaming-reader,代码行数:33,代码来源:StreamingSheetReader.java

示例13: parseValue

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
private static AttributeValue parseValue(Attribute attribute) {
    int hashTagPos = attribute.getValue().indexOf('#');
    String nsUri;
    String value;
    if (hashTagPos != -1) {
        nsUri = attribute.getValue().substring(0, hashTagPos);
        value = attribute.getValue().substring(hashTagPos + 1);
    } else {
        nsUri = null;
        value = attribute.getValue();
    }
    return new AttributeValue(nsUri, value);
}
 
开发者ID:powsybl,项目名称:powsybl-core,代码行数:14,代码来源:CimAnonymizer.java

示例14: read

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
private XmlDocument read(XMLEventReader staxEventReader, Origin origin) {
	XMLEvent event;
	try {
		event = staxEventReader.peek();
		while ( event != null && !event.isStartElement() ) {
			staxEventReader.nextEvent();
			event = staxEventReader.peek();
		}
	}
	catch ( Exception e ) {
		throw new InvalidMappingException( "Error accessing stax stream", origin, e );
	}

	if ( event == null ) {
		throw new InvalidMappingException( "Could not locate root element", origin );
	}

	final String rootElementName = event.asStartElement().getName().getLocalPart();

	if ( "entity-mappings".equals( rootElementName ) ) {
		final Attribute attribute = event.asStartElement().getAttributeByName( ORM_VERSION_ATTRIBUTE_QNAME );
		final String explicitVersion = attribute == null ? null : attribute.getValue();
		validateMapping(
				SupportedOrmXsdVersion.parse( explicitVersion, origin ),
				staxEventReader,
				origin
		);
	}

	return new XmlDocumentImpl( toDom4jDocument( staxEventReader, origin ), origin );
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:32,代码来源:MappingReader.java

示例15: getAttributes

import javax.xml.stream.events.Attribute; //导入方法依赖的package包/类
/**
 * Get the attributes associated with the given START_ELEMENT StAXevent.
 *
 * @return the StAX attributes converted to an org.xml.sax.Attributes
 */
private Attributes getAttributes(StartElement event) {
    attrs.clear();

    // in SAX, namespace declarations are not part of attributes by default.
    // (there's a property to control that, but as far as we are concerned
    // we don't use it.) So don't add xmlns:* to attributes.

    // gather non-namespace attrs
    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;
        if (prefix == null || prefix.length() == 0)
            qName = localName;
        else
            qName = prefix + ':' + localName;
        String type = staxAttr.getDTDType();
        String value = staxAttr.getValue();

        attrs.addAttribute(uri, localName, qName, type, value);
    }

    return attrs;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:34,代码来源:StAXEventConnector.java


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