本文整理匯總了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
}
}
}
}
示例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());
}
}
}
示例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());
}
}
}
示例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;
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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 );
}
示例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;
}