Java Code Examples for javax.xml.namespace.QName
The following code examples are extracted from open source projects. You can click to
vote up the examples that are useful to you.
Example 1
From project arquillian-showcase, under directory /jaxws/src/test/java/com/acme/jaxws/.
Source file: EchoWebServiceEndpointTestCase.java

@Test public void testSimpleStatelessWebServiceEndpoint(@ArquillianResource URL deploymentUrl) throws Exception { final QName serviceName=new QName("com.acme.jaxws",ECHO_SERVICE_NAME); final URL wsdlURL=new URL(deploymentUrl,ECHO_SERVICE_NAME + "?wsdl"); final Service service=Service.create(wsdlURL,serviceName); final EchoWebServiceEndpoint port=service.getPort(EchoWebServiceEndpoint.class); final String result=port.echo("hello"); Assert.assertEquals("hello",result); }
Example 2
From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/bpmn20/model/.
Source file: Definitions.java

/** * The {@link Marshaller} invokes this method right before marshaling to XML. The namespace are added as attributes to the definitions element. * @param marshaller The marshaling context */ public void beforeMarshal(Marshaller marshaller){ for ( String prefix : this.getNamespaces().keySet()) { QName namespacePrefix=new QName("xmlns:" + prefix); this.getOtherAttributes().put(namespacePrefix,this.getNamespaces().get(prefix)); } }
Example 3
From project bpelunit, under directory /net.bpelunit.framework/src/main/java/net/bpelunit/framework/.
Source file: SpecificationLoader.java

private QName getService(Activity parentActivity,XMLSoapActivity xmlActivity) throws SpecificationException { QName service=null; try { service=xmlActivity.getService(); } catch ( Exception e) { } if (service == null) { throw new SpecificationException("Could not find service for activity " + parentActivity.getName() + ": not specified or wrong prefix."); } return service; }
Example 4
From project bpelunit, under directory /net.bpelunit.framework/src/test/java/net/bpelunit/test/unit/.
Source file: TestWSDLReader.java

private String getEncoding(String name) throws Exception { Definition d=SpecificationLoader.loadWsdlDefinition(ABS_PATH,name,"TEST"); Partner p=new Partner("MyPartner",d,null,""); QName service=new QName("http://www.example.org/MyPartner/","MyPartner"); SOAPOperationCallIdentifier operation=p.getOperation(service,"MyPartnerSOAP","NewOperation",SOAPOperationDirectionIdentifier.INPUT); return operation.getEncodingStyle(); }
Example 5
From project commons-j, under directory /src/main/java/nerds/antelax/commons/xml/saxbp/.
Source file: ParseInterest.java

static Pair<QName,Class<?>> checkQName(final Method method) throws SAXBPException { final XmlElement element=method.getAnnotation(JAXBHandler.class).value(); if (element.name() == null || element.name().trim().isEmpty()) throw new SAXBPException("Null or empty element name in [embedded] XmlElement annotation"); final QName qName=new QName(element.namespace(),element.name()); return new Pair<QName,Class<?>>(qName,checkAndGetJaxbClass(method)); }
Example 6
From project apb, under directory /modules/apb-base/src/apb/utils/.
Source file: SchemaUtils.java

private static void collectFiles(XMLStreamReader sr,URL doc,Queue<File> pending) throws XMLStreamException { while (sr.hasNext()) { final int eventCode=sr.next(); if (eventCode == XMLStreamConstants.START_ELEMENT) { final QName srName=sr.getName(); if (IMPORT_TAG.equals(srName) || INCLUDE_TAG.equals(srName) || JAXB_TAG.equals(srName)) { final String location=findAttribute(sr,"schemaLocation"); if (location != null) { processLocation(doc,pending,location); } } } } }
Example 7
From project bpm-console, under directory /server/war/src/main/java/org/jboss/bpm/console/server/util/.
Source file: DOMUtils.java

/** * Get the qname value from the given attribute */ public static QName getAttributeValueAsQName(Element el,QName attrName){ QName qname=null; String qualifiedName=getAttributeValue(el,attrName); if (qualifiedName != null) { qname=resolveQName(el,qualifiedName); } return qname; }
Example 8
From project bpm-console, under directory /server/war/src/main/java/org/jboss/bpm/console/server/util/.
Source file: DOMUtils.java

/** * Get the attributes as Map<QName, String> */ public static Map getAttributes(Element el){ Map attmap=new HashMap(); NamedNodeMap attribs=el.getAttributes(); for (int i=0; i < attribs.getLength(); i++) { Attr attr=(Attr)attribs.item(i); String name=attr.getName(); QName qname=resolveQName(el,name); String value=attr.getNodeValue(); attmap.put(qname,value); } return attmap; }
Example 9
From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/templatecompiler/model/.
Source file: ElementsHandler.java

@Override public ModelElement getElement(DOMResult rt){ Element domElement=getDomElement(rt); AnyElement element=JAXB.unmarshal(new DOMSource(domElement),AnyElement.class); String prefix=domElement.getPrefix(); QName name=new QName(domElement.getNamespaceURI(),domElement.getLocalName(),null != prefix ? prefix : XMLConstants.DEFAULT_NS_PREFIX); element.setName(name); return element; }
Example 10
From project cdk, under directory /generator/src/main/java/org/richfaces/cdk/templatecompiler/.
Source file: RendererClassVisitor.java

@Override public void startElement(AnyElement anyElement) throws CdkException { QName elementName=anyElement.getName(); if (Template.isDirectiveNamespace(elementName)) { log.error("Unknown directive element " + elementName); } else { StartElementStatement startElementStatement=addStatement(StartElementStatement.class); startElementStatement.setElementName(elementName); AttributesStatement attributesStatement=addStatement(AttributesStatement.class); attributesStatement.processAttributes(anyElement,attributes); } }
Example 11
From project codjo-webservices, under directory /codjo-webservices-common/src/main/java/com/tilab/wsig/wsdl/.
Source file: WSDLGeneratorUtils.java

public static Part createPart(String name,String className,String tns){ Part part=new PartImpl(); String namespaceURI; if (WSDLConstants.jade2xsd.values().contains(className)) { namespaceURI=WSDLConstants.XSD; } else { namespaceURI=tns; } QName qNameType=new QName(namespaceURI,className); part.setTypeName(qNameType); part.setName(name); return part; }
Example 12
From project com.cedarsoft.serialization, under directory /stax/src/main/java/com/cedarsoft/serialization/stax/.
Source file: AbstractStaxBasedSerializer.java

/** * Ensures that the current tag equals the given tag name and namespace * @param streamReader the stream reader * @param tagName the tag name * @param namespace the (optional) namespace (if the ns is null, no check will be performed) */ protected void ensureTag(@Nonnull XMLStreamReader streamReader,@Nonnull String tagName,@Nullable String namespace) throws XMLStreamException { QName qName=streamReader.getName(); if (!doesNamespaceFit(streamReader,namespace)) { throw new XMLStreamException("Invalid namespace for <" + qName.getLocalPart() + ">. Was <"+ qName.getNamespaceURI()+ "> but expected <"+ namespace+ "> @ "+ streamReader.getLocation()); } String current=qName.getLocalPart(); if (!current.equals(tagName)) { throw new XMLStreamException("Invalid tag. Was <" + current + "> but expected <"+ tagName+ "> @ "+ streamReader.getLocation()); } }
Example 13
From project com.cedarsoft.serialization, under directory /stax/src/main/java/com/cedarsoft/serialization/stax/.
Source file: AbstractStaxBasedSerializer.java

/** * Returns whether the namespace fits * @param streamReader the stream reader that is used to extract the namespace * @param namespace the expected namespace (or null if the check shall be skipped) * @return true if the namespace fits (or the expected namespace is null), false otherwise */ protected boolean doesNamespaceFit(@Nonnull XMLStreamReader streamReader,@Nullable String namespace){ if (namespace == null) { return true; } QName qName=streamReader.getName(); String nsUri=qName.getNamespaceURI(); return nsUri.equals(namespace); }
Example 14
From project components, under directory /bpel/src/main/java/org/switchyard/component/bpel/riftsaw/.
Source file: RiftsawServiceLocator.java

/** * This method returns the service associated with the supplied process, service and port. * @param processName The process name * @param serviceName The service name * @param portName The port name * @return The service or null if not found */ public Service getService(QName processName,QName serviceName,String portName){ int index=processName.getLocalPart().indexOf('-'); QName localProcessName=new QName(processName.getNamespaceURI(),processName.getLocalPart().substring(0,index)); RegistryEntry re=_registry.get(localProcessName); if (re == null) { LOG.error("No service references found for process '" + localProcessName + "'"); return (null); } Service ret=re.getService(serviceName,portName,_serviceDomains.get(serviceName)); if (ret == null) { LOG.error("No service found for '" + serviceName + "' (port "+ portName+ ")"); } return (ret); }
Example 15
From project components, under directory /camel/camel-core/src/main/java/org/switchyard/component/camel/composer/.
Source file: CamelMessageComposer.java

/** * Returns the current message type based on the state of the exchange. * @param exchange exchange to query * @return the current message type based on the exchange contract */ private QName getMessageType(Exchange exchange){ QName msgType; if (exchange.getPhase() == null) { msgType=exchange.getContract().getConsumerOperation().getInputType(); } else { msgType=exchange.getContract().getConsumerOperation().getOutputType(); } return msgType; }
Example 16
From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/dataholders/loadingutils/.
Source file: XmlMerger.java

/** * Read all {@link javax.xml.stream.events.XMLEvent}'s from specified file and write them onto the {@link javax.xml.stream.XMLEventWriter} * @param file File to import * @param skipRoot Skip-root flag * @param writer Destenation writer * @throws XMLStreamException On event reading/writing error. * @throws FileNotFoundException if the reading file does not exist,is a directory rather than a regular file, or for some other reason cannot be opened for reading. */ private void importFile(File file,boolean skipRoot,XMLEventWriter writer,Properties metadata) throws XMLStreamException, IOException { logger.debug("Appending file " + file); metadata.setProperty(file.getPath(),makeHash(file)); XMLEventReader reader=null; try { reader=inputFactory.createXMLEventReader(new FileReader(file)); QName firstTagQName=null; while (reader.hasNext()) { XMLEvent event=reader.nextEvent(); if (event.isStartDocument() || event.isEndDocument()) continue; if (event instanceof Comment) continue; if (event.isCharacters()) { if (event.asCharacters().isWhiteSpace() || event.asCharacters().isIgnorableWhiteSpace()) continue; } if (firstTagQName == null && event.isStartElement()) { firstTagQName=event.asStartElement().getName(); if (skipRoot) { continue; } else { StartElement old=event.asStartElement(); event=eventFactory.createStartElement(old.getName(),old.getAttributes(),null); } } if (event.isEndElement() && skipRoot && event.asEndElement().getName().equals(firstTagQName)) continue; writer.add(event); } } finally { if (reader != null) try { reader.close(); } catch ( Exception ignored) { } } }
Example 17
From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/web/view/.
Source file: AbstractSaml10ResponseView.java

protected final <T extends SAMLObject>T newSamlObject(final Class<T> objectType){ final QName qName; try { final Field f=objectType.getField(DEFAULT_ELEMENT_NAME_FIELD); qName=(QName)f.get(null); } catch ( final NoSuchFieldException e) { throw new IllegalStateException("Cannot find field " + objectType.getName() + "."+ DEFAULT_ELEMENT_NAME_FIELD); } catch ( final IllegalAccessException e) { throw new IllegalStateException("Cannot access field " + objectType.getName() + "."+ DEFAULT_ELEMENT_NAME_FIELD); } final SAMLObjectBuilder<T> builder=(SAMLObjectBuilder<T>)Configuration.getBuilderFactory().getBuilder(qName); if (builder == null) { throw new IllegalStateException("No SAMLObjectBuilder registered for class " + objectType.getName()); } return objectType.cast(builder.buildObject()); }
Example 18
From project codjo-webservices, under directory /codjo-webservices-common/src/main/java/com/tilab/wsig/wsdl/.
Source file: WSDLGeneratorUtils.java

public static Types createTypes(ExtensionRegistry registry,Element element) throws WSDLException { Types types=new TypesImpl(); Schema schema=(Schema)registry.createExtension(Types.class,new QName(WSDLConstants.XSD,WSDLConstants.SCHEMA)); schema.setElement(element); types.addExtensibilityElement(schema); return types; }
Example 19
From project commons-j, under directory /src/main/java/nerds/antelax/commons/xml/saxbp/.
Source file: ParseInterest.java

static Collection<ParseInterest> fromHandlers(final JAXBContext jaxbContext,final Object... handlers) throws SAXBPException, JAXBException { final Collection<ParseInterest> interest=new LinkedList<ParseInterest>(); for ( final Object handler : handlers) { if (!handler.getClass().isAnnotationPresent(SAXBPHandler.class)) throw new SAXBPException("Handler [" + handler + "] is not annotated with "+ SAXBPHandler.class.getName()); for ( final Method method : handler.getClass().getMethods()) { try { if (method.isAnnotationPresent(XmlElement.class)) { final QName qName=checkQName(method,method.getAnnotation(XmlElement.class)); interest.add(new ParseInterest(qName,null,null,handler,method)); } else if (method.isAnnotationPresent(XmlElements.class)) { for ( final XmlElement xmlElement : method.getAnnotation(XmlElements.class).value()) { final QName qName=checkQName(method,xmlElement); interest.add(new ParseInterest(qName,null,null,handler,method)); } } else if (method.isAnnotationPresent(JAXBHandler.class)) { final Pair<QName,Class<?>> qNameClassPair=checkQName(method); interest.add(new ParseInterest(qNameClassPair.first(),jaxbContext,qNameClassPair.second(),handler,method)); } } catch ( final SAXBPException saxbpe) { throw new SAXBPException("Exception while examining handler[" + handler + "], method["+ method+ "]",saxbpe); } } } return Collections.unmodifiableCollection(interest); }
Example 20
From project Activiti-KickStart, under directory /activiti-kickstart-java/src/main/java/org/activiti/kickstart/bpmn20/model/.
Source file: CallableElement.java

/** * Gets the value of the supportedInterfaceRef property. <p> This accessor method returns a reference to the live list, not a snapshot. Therefore any modification you make to the returned list will be present inside the JAXB object. This is why there is not a <CODE>set</CODE> method for the supportedInterfaceRef property. <p> For example, to add a new item, do as follows: <pre> getSupportedInterfaceRef().add(newItem); </pre> <p> Objects of the following type(s) are allowed in the list {@link QName } */ public List<QName> getSupportedInterfaceRef(){ if (supportedInterfaceRef == null) { supportedInterfaceRef=new ArrayList<QName>(); } return this.supportedInterfaceRef; }
Example 21
From project Aion-Extreme, under directory /AE-go_GameServer/src/com/aionemu/gameserver/dataholders/loadingutils/.
Source file: XmlMerger.java

/** * Extract an attribute value from a <code>StartElement </code> event. * @param element Event object. * @param name Attribute QName * @param def Default value. * @param onErrorMessage On error message. * @return attribute value * @throws XMLStreamException if attribute is missing and there is no default value set. */ private String getAttributeValue(StartElement element,QName name,String def,String onErrorMessage) throws XMLStreamException { Attribute attribute=element.getAttributeByName(name); if (attribute == null) { if (def == null) throw new XMLStreamException(onErrorMessage,element.getLocation()); return def; } return attribute.getValue(); }
Example 22
From project bam, under directory /samples/jbossas/ordermgmt/src/main/java/org/switchyard/quickstarts/demos/orders/.
Source file: PolicyEnforcer.java

public void handleMessage(Exchange exchange) throws HandlerException { if (!_initialized) { init(); } if (LOG.isLoggable(Level.FINE)) { LOG.fine("********* Exchange=" + exchange); } if (_principals != null) { String contentType=null; for ( Property p : exchange.getContext().getProperties(org.switchyard.Scope.valueOf(exchange.getPhase().toString()))) { if (p.getName().equals("org.switchyard.contentType")) { contentType=((QName)p.getValue()).toString(); } } if (exchange.getPhase() == ExchangePhase.IN && contentType != null && contentType.equals("{urn:switchyard-quickstart-demo:orders:1.0}submitOrder")) { String content=getMessageContent(exchange); int start=content.indexOf("<customer>"); if (start != -1) { int end=content.indexOf("</",start); if (end != -1) { String customer=content.substring(start + 10,end); if (_principals.containsKey(customer)) { @SuppressWarnings("unchecked") java.util.Map<String,java.io.Serializable> props=(java.util.Map<String,java.io.Serializable>)_principals.get(customer); if (props.containsKey("suspended") && props.get("suspended").equals(Boolean.TRUE)) { throw new HandlerException("Customer '" + customer + "' has been suspended"); } } if (LOG.isLoggable(Level.FINE)) { LOG.fine("*********** Policy Enforcer: customer '" + customer + "' has not been suspended"); LOG.fine("*********** Principal: " + _principals.get(customer)); } } } } } }
Example 23
From project blog_1, under directory /miniprojects/generic-pojo-mappers/src/main/java/net/jakubholy/blog/genericmappers/xml/.
Source file: XmlElements.java

private <T>T getNodesMatchingXPath(String xpathExpression,QName expectedResult,Class<T> resultType){ try { XPathExpression nodesXPath=makeXPathExpression(xpathExpression); @SuppressWarnings("unchecked") T result=(T)nodesXPath.evaluate(parsedXmlDocument,expectedResult); return result; } catch ( XPathExpressionException e) { throw new RuntimeException("Invalid xpath '" + xpathExpression + "': "+ e.getMessage(),e); } }
Example 24
From project CalendarPortlet, under directory /src/main/java/org/jasig/portlet/calendar/adapter/.
Source file: ExchangeCalendarAdapter.java

/** * Retrieve a set of CalendarEvents from the Exchange server for the specified period and email address. * @param calendar * @param period * @param emailAddress * @return * @throws CalendarException */ public Set<VEvent> retrieveExchangeEvents(CalendarConfiguration calendar,Interval interval,String emailAddress) throws CalendarException { if (log.isDebugEnabled()) { log.debug("Retrieving exchange events for period: " + interval); } Set<VEvent> events=new HashSet<VEvent>(); try { GetUserAvailabilityRequest soapRequest=getAvailabilityRequest(interval,emailAddress); final WebServiceMessageCallback actionCallback=new SoapActionCallback(AVAILABILITY_SOAP_ACTION); final WebServiceMessageCallback customCallback=new WebServiceMessageCallback(){ @Override public void doWithMessage( WebServiceMessage message) throws IOException, TransformerException { actionCallback.doWithMessage(message); SoapMessage soap=(SoapMessage)message; QName rsv=new QName("http://schemas.microsoft.com/exchange/services/2006/types","RequestServerVersion","ns3"); SoapHeaderElement version=soap.getEnvelope().getHeader().addHeaderElement(rsv); version.addAttribute(new QName("Version"),"Exchange2010_SP2"); } } ; GetUserAvailabilityResponse response=(GetUserAvailabilityResponse)webServiceOperations.marshalSendAndReceive(soapRequest,customCallback); for ( FreeBusyResponseType freeBusy : response.getFreeBusyResponseArray().getFreeBusyResponses()) { ArrayOfCalendarEvent eventArray=freeBusy.getFreeBusyView().getCalendarEventArray(); if (eventArray != null && eventArray.getCalendarEvents() != null) { List<com.microsoft.exchange.types.CalendarEvent> msEvents=eventArray.getCalendarEvents(); for ( com.microsoft.exchange.types.CalendarEvent msEvent : msEvents) { VEvent event=getInternalEvent(calendar.getId(),msEvent); events.add(event); } } } } catch ( DatatypeConfigurationException e) { throw new CalendarException(e); } return events; }
Example 25
From project cas, under directory /cas-server-core/src/main/java/org/jasig/cas/web/view/.
Source file: AbstractSaml10ResponseView.java

protected final Status newStatus(final QName codeValue,final String statusMessage){ final Status status=newSamlObject(Status.class); final StatusCode code=newSamlObject(StatusCode.class); code.setValue(codeValue); status.setStatusCode(code); if (statusMessage != null) { final StatusMessage message=newSamlObject(StatusMessage.class); message.setMessage(statusMessage); status.setStatusMessage(message); } return status; }