本文整理匯總了Java中javax.xml.stream.XMLStreamReader.getName方法的典型用法代碼示例。如果您正苦於以下問題:Java XMLStreamReader.getName方法的具體用法?Java XMLStreamReader.getName怎麽用?Java XMLStreamReader.getName使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類javax.xml.stream.XMLStreamReader
的用法示例。
在下文中一共展示了XMLStreamReader.getName方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: readResponse
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
final Object readResponse(Object[] args, XMLStreamReader r, AttachmentSet att) throws JAXBException {
Object obj;
AttachmentUnmarshallerImpl au = (att != null)?new AttachmentUnmarshallerImpl(att):null;
if (bridge instanceof RepeatedElementBridge) {
RepeatedElementBridge rbridge = (RepeatedElementBridge)bridge;
ArrayList list = new ArrayList();
QName name = r.getName();
while (r.getEventType()==XMLStreamReader.START_ELEMENT && name.equals(r.getName())) {
list.add(rbridge.unmarshal(r, au));
XMLStreamReaderUtil.toNextTag(r, name);
}
obj = rbridge.collectionHandler().convert(list);
} else {
obj = bridge.unmarshal(r, au);
}
return setter.put(obj,args);
}
示例2: readRequest
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
void readRequest( Object[] args, XMLStreamReader r, AttachmentSet att) throws JAXBException {
Object obj = null;
AttachmentUnmarshallerImpl au = (att != null)?new AttachmentUnmarshallerImpl(att):null;
if (bridge instanceof RepeatedElementBridge) {
RepeatedElementBridge rbridge = (RepeatedElementBridge)bridge;
ArrayList list = new ArrayList();
QName name = r.getName();
while (r.getEventType()==XMLStreamReader.START_ELEMENT && name.equals(r.getName())) {
list.add(rbridge.unmarshal(r, au));
XMLStreamReaderUtil.toNextTag(r, name);
}
obj = rbridge.collectionHandler().convert(list);
} else {
obj = bridge.unmarshal(r, au);
}
setter.put(obj,args);
}
示例3: readWrappedRequest
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
protected void readWrappedRequest(Message msg, Object[] args) throws JAXBException, XMLStreamException {
if (!msg.hasPayload()) {
throw new WebServiceException("No payload. Expecting payload with "+wrapperName+" element");
}
XMLStreamReader reader = msg.readPayload();
XMLStreamReaderUtil.verifyTag(reader,wrapperName);
reader.nextTag();
while(reader.getEventType()==XMLStreamReader.START_ELEMENT) {
// TODO: QName has a performance issue
QName name = reader.getName();
WrappedPartBuilder part = wrappedParts.get(name);
if(part==null) {
// no corresponding part found. ignore
XMLStreamReaderUtil.skipElement(reader);
reader.nextTag();
} else {
part.readRequest(args,reader, msg.getAttachments());
}
XMLStreamReaderUtil.toNextTag(reader, name);
}
// we are done with the body
reader.close();
XMLStreamReaderFactory.recycle(reader);
}
示例4: testStartElement
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Test
public void testStartElement() {
try {
XMLInputFactory xif = XMLInputFactory.newInstance();
// File file = new File("./tests/XMLStreamReader/sgml.xml");
// FileInputStream inputStream = new FileInputStream(file);
XMLStreamReader xsr = xif.createXMLStreamReader(this.getClass().getResourceAsStream("sgml.xml"));
xsr.getName();
} catch (IllegalStateException ise) {
// expected
System.out.println(ise.getMessage());
} catch (Exception e) {
e.printStackTrace();
Assert.fail("Exception occured: " + e.getMessage());
}
}
示例5: testChildElementNamespace
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Test
public void testChildElementNamespace() {
try {
XMLInputFactory xif = XMLInputFactory.newInstance();
xif.setProperty(XMLInputFactory.IS_NAMESPACE_AWARE, Boolean.TRUE);
InputStream is = new java.io.ByteArrayInputStream(getXML().getBytes());
XMLStreamReader sr = xif.createXMLStreamReader(is);
while (sr.hasNext()) {
int eventType = sr.next();
if (eventType == XMLStreamConstants.START_ELEMENT) {
if (sr.getLocalName().equals(childElement)) {
QName qname = sr.getName();
Assert.assertTrue(qname.getPrefix().equals(prefix) && qname.getNamespaceURI().equals(namespaceURI)
&& qname.getLocalPart().equals(childElement));
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例6: testChildElementNamespace
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Test
public void testChildElementNamespace() {
is = new java.io.ByteArrayInputStream(getXML().getBytes());
try {
XMLStreamReader sr = factory.createFilteredReader(factory.createXMLStreamReader(is), (StreamFilter) filter);
while (sr.hasNext()) {
int eventType = sr.next();
if (eventType == XMLStreamConstants.START_ELEMENT) {
if (sr.getLocalName().equals(childElement)) {
QName qname = sr.getName();
Assert.assertTrue(qname.getPrefix().equals(prefixApple) && qname.getNamespaceURI().equals(namespaceURIApple)
&& qname.getLocalPart().equals(childElement));
}
}
}
} catch (Exception ex) {
Assert.fail("Exception: " + ex.getMessage());
}
}
示例7: addressibleElement
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
QName ua = reader.getName();
if (ua.equals(AddressingVersion.W3C.wsdlExtensionTag)) {
String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
binding.addFeature(new AddressingFeature(true, Boolean.parseBoolean(required)));
XMLStreamReaderUtil.skipElement(reader);
return true; // UsingAddressing is consumed
}
return false;
}
示例8: bindingOperationElements
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
@Override
public boolean bindingOperationElements(EditableWSDLBoundOperation operation, XMLStreamReader reader) {
EditableWSDLBoundOperation edit = (EditableWSDLBoundOperation) operation;
QName anon = reader.getName();
if (anon.equals(AddressingVersion.W3C.wsdlAnonymousTag)) {
try {
String value = reader.getElementText();
if (value == null || value.trim().equals("")) {
throw new WebServiceException("Null values not permitted in wsaw:Anonymous.");
// TODO: throw exception only if wsdl:required=true
// TODO: is this the right exception ?
} else if (value.equals("optional")) {
edit.setAnonymous(ANONYMOUS.optional);
} else if (value.equals("required")) {
edit.setAnonymous(ANONYMOUS.required);
} else if (value.equals("prohibited")) {
edit.setAnonymous(ANONYMOUS.prohibited);
} else {
throw new WebServiceException("wsaw:Anonymous value \"" + value + "\" not understood.");
// TODO: throw exception only if wsdl:required=true
// TODO: is this the right exception ?
}
} catch (XMLStreamException e) {
throw new WebServiceException(e); // TODO: is this the correct behavior ?
}
return true; // consumed the element
}
return false;
}
示例9: addressibleElement
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private boolean addressibleElement(XMLStreamReader reader, WSDLFeaturedObject binding) {
QName ua = reader.getName();
if (ua.equals(AddressingVersion.MEMBER.wsdlExtensionTag)) {
String required = reader.getAttributeValue(WSDLConstants.NS_WSDL, "required");
binding.addFeature(new MemberSubmissionAddressingFeature(Boolean.parseBoolean(required)));
XMLStreamReaderUtil.skipElement(reader);
return true; // UsingAddressing is consumed
}
return false;
}
示例10: failWithFullName
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
protected static void failWithFullName(String key, XMLStreamReader reader) {
throw new ServerRtException(
key,
reader.getLocation().getLineNumber(),
reader.getName());
}
示例11: pre
import javax.xml.stream.XMLStreamReader; //導入方法依賴的package包/類
private QName pre(XMLStreamReader xsr) {
return xsr.getName();
}