當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。