List of usage examples for javax.xml.namespace QName QName
public QName(String namespaceURI, String localPart, String prefix)
QName
constructor specifying the Namespace URI, local part and prefix.
If the Namespace URI is null
, it is set to javax.xml.XMLConstants#NULL_NS_URI XMLConstants.NULL_NS_URI .
From source file:com.xiongyingqi.util.xml.XMLEventStreamWriter.java
@Override public void writeStartElement(String prefix, String localName, String namespaceURI) throws XMLStreamException { writeStartElement(eventFactory.createStartElement(new QName(namespaceURI, localName, prefix), null, null)); }
From source file:edu.internet2.middleware.openid.message.encoding.EncodingUtils.java
/** * Build an appropriate {@link QName} for a namespaced parameter name. * //from ww w .j a v a 2 s .com * @param parameter namespaced parameter name * @param namespaces map of registered namespaces * @return QName for the parameter */ public static QName decodeParameterName(String parameter, NamespaceMap namespaces) { String[] parts = parameter.split("\\.", 2); // check if parameter name is for a namespace declaration if (OpenIDConstants.MESSAGE_NAMESPACE_PREFIX.equals(parts[0])) { String alias; if (parts.length == 2) { alias = parts[1]; } else { alias = XMLConstants.DEFAULT_NS_PREFIX; } return new NamespaceQName(namespaces.getURI(alias), alias); } // otherwise, parameter name is for a message parameter String alias; String localPart; if (parts.length == 2) { alias = parts[0]; localPart = parts[1]; } else { alias = XMLConstants.DEFAULT_NS_PREFIX; localPart = parts[0]; } return new QName(namespaces.getURI(alias), localPart, alias); }
From source file:com.evolveum.midpoint.prism.xml.GlobalDynamicNamespacePrefixMapper.java
@Override public QName setQNamePrefix(QName qname) { String namespace = qname.getNamespaceURI(); String prefix = getPrefix(namespace); if (prefix == null) { return qname; }//from w ww . j av a 2s. c o m return new QName(qname.getNamespaceURI(), qname.getLocalPart(), prefix); }
From source file:io.twipple.springframework.data.clusterpoint.mapping.BasicClusterpointPersistentProperty.java
@Override @NotNull//from w w w . ja va 2 s .c o m public QName getQualifiedName() { if (qualifiedName == null) { ClusterpointPersistentEntity<?> ownerEntity = (ClusterpointPersistentEntity<?>) getOwner(); Assert.notNull(ownerEntity); String namespaceUri = ownerEntity.getXmlNamespace(); String prefix = ownerEntity.getPreferredXmlPrefix(); String localName = getName(); qualifiedName = new QName(namespaceUri, localName, prefix); } return qualifiedName; }
From source file:com.googlecode.ddom.frontend.saaj.SOAPElementTest.java
@Validated @Test//from www.j a v a2s. c o m public void testAddAttributeFromQNameWithNamespace() throws Exception { SOAPElement element = saajUtil.createSOAPElement(null, "test", null); SOAPElement retValue = element.addAttribute(new QName("urn:ns", "attr", "p"), "value"); assertSame(element, retValue); Attr attr = element.getAttributeNodeNS("urn:ns", "attr"); assertEquals("urn:ns", attr.getNamespaceURI()); assertEquals("attr", attr.getLocalName()); assertEquals("p", attr.getPrefix()); assertEquals("value", attr.getValue()); Attr nsDecl = element.getAttributeNodeNS(XMLConstants.XMLNS_ATTRIBUTE_NS_URI, "p"); assertNotNull(nsDecl); assertEquals("urn:ns", nsDecl.getValue()); }
From source file:com.evolveum.midpoint.prism.marshaller.PathHolderSegment.java
/** * Sets a given prefix to current QName (without changing NS URI). * It's a bit of hack.//w w w. j ava 2 s .co m * * Precondition: there is no prefix set. * @param prefix */ public void setQNamePrefix(String prefix) { if (qName == null) { throw new IllegalStateException("qName is null"); } if (StringUtils.isNotEmpty(qName.getPrefix())) { throw new IllegalStateException("Prefix for qName is already set: " + qName.getPrefix()); } qName = new QName(qName.getNamespaceURI(), qName.getLocalPart(), prefix); }
From source file:com.evolveum.midpoint.prism.xml.GlobalDynamicNamespacePrefixMapper.java
@Override public QName setQNamePrefixExplicit(QName qname) { String namespace = qname.getNamespaceURI(); String prefix = getPrefixExplicit(namespace); if (prefix == null) { return qname; }//from w w w . jav a 2 s. c o m return new QName(qname.getNamespaceURI(), qname.getLocalPart(), prefix); }
From source file:com.evolveum.midpoint.util.QNameUtil.java
public static QName nullNamespace(QName qname) { return new QName(null, qname.getLocalPart(), qname.getPrefix()); }
From source file:org.opensaml.soap.client.soap11.decoder.http.impl.HttpClientResponseSOAP11DecoderTest.java
@Test(expectedExceptions = SOAP11FaultDecodingException.class) public void testFault() throws ComponentInitializationException, MessageDecodingException, MarshallingException, IOException { Fault fault = SOAPSupport.buildSOAP11Fault(new QName("urn:test:soap:fault:foo", "TestFault", "foo"), "Test fault", null, null, null); Envelope envelope = buildMessageSkeleton(); envelope.getBody().getUnknownXMLObjects().add(fault); HttpResponse httpResponse = buildResponse(HttpStatus.SC_INTERNAL_SERVER_ERROR, envelope); decoder.setBodyHandler(new TestPayloadBodyHandler()); decoder.setHttpResponse(httpResponse); decoder.initialize();//from w w w. j a v a 2s . co m decoder.decode(); }
From source file:com.streamreduce.util.JiraClientIT.java
/** * Tests {@link JiraClient#getActivity(java.util.Set)}. * * @throws Exception if anything goes wrong *///from w w w . j av a 2 s . c o m @Test public void testJiraGetActivityParts() throws Exception { int maxResults = 100; List<Entry> testProjectActivity = jiraClient.getActivity(monitoredProjects, maxResults); Assert.assertTrue(testProjectActivity.size() > 0 && testProjectActivity.size() <= maxResults); for (Entry activity : testProjectActivity) { org.apache.abdera.model.Element activityObjectElement = activity .getFirstChild(new QName("http://activitystrea.ms/spec/1.0/", "object", "activity")); String projectKey = jiraClient.getProjectKeyOfEntry(activityObjectElement, monitoredProjects); // Prepare the inventory item inventoryItem.setExternalId(projectKey); Map<String, Object> activityParts = jiraClient.getPartsForActivity(inventoryItem, activity); Assert.assertNotNull(activityParts); String title = (String) activityParts.get("title"); String content = (String) activityParts.get("content"); Set<String> hashtags = (Set<String>) activityParts.get("hashtags"); int expectedHashtagCount = 2; // #jira and #[project.key] is always expected try { Assert.assertNotNull(title); Assert.assertTrue(hashtags.contains("#" + projectKey.toLowerCase())); Assert.assertTrue(hashtags.contains("#jira")); // No good way to test content since it can be null a few different ways if (hashtags.contains("#issue")) { // Issue related tests expectedHashtagCount += 4; // #issue #[issue-type] #[issue-priority] #[issue-status] // There is no good way to test the actual issue hashtags because they could outdated } else if (hashtags.contains("#source")) { // Source related tests expectedHashtagCount += 2; // #source #[activity] Assert.assertFalse(hashtags.contains("#file")); // This is an ignored hashtag Assert.assertTrue(hashtags.contains("#changeset") || hashtags.contains("#review")); } else if (hashtags.contains("#wiki")) { // Wiki related tests if (!hashtags.contains("#blog") && !hashtags.contains("#page")) { expectedHashtagCount += 1; // #wiki } else { expectedHashtagCount += 2; // #wiki #[target] } Assert.assertFalse(hashtags.contains("#space")); // This is an ignored hashtag Assert.assertFalse(hashtags.contains("#article")); // This is an ignored hashtag Assert.assertFalse(hashtags.contains("#file")); // This is an ignored hashtag } else { Assert.fail("All Jira activity hashtags should contain at least one of he following: " + "#issue, #source or #wiki"); } // For comments and attachments, expected hashtags is one extra if (hashtags.contains("#comment") || hashtags.contains("#attachment")) { expectedHashtagCount += 1; } if (hashtags.contains("#issue") || (hashtags.contains("#wiki") && !hashtags.contains("#blog"))) { Assert.assertTrue(hashtags.size() >= expectedHashtagCount); } else { Assert.assertEquals(expectedHashtagCount, hashtags.size()); } } catch (AssertionFailedError e) { // Add some extra output to make debugging easier System.out.println("Problematic title: " + activity.getTitle()); System.out.println("Hashtags (Expected: " + expectedHashtagCount + "):"); for (String hashtag : hashtags) { System.out.println(" " + hashtag); } throw e; } } }