本文整理汇总了Java中org.dom4j.QName.get方法的典型用法代码示例。如果您正苦于以下问题:Java QName.get方法的具体用法?Java QName.get怎么用?Java QName.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.dom4j.QName
的用法示例。
在下文中一共展示了QName.get方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: canGetListUsingCorrectListAndSiteName
import org.dom4j.QName; //导入方法依赖的package包/类
/**
* ALF-19833: MacOS: Could not save to SharePoint
*/
@Test
public void canGetListUsingCorrectListAndSiteName() throws Exception
{
VtiSoapRequest soapRequest = Mockito.mock(VtiSoapRequest.class);
VtiSoapResponse soapResponse = new VtiSoapResponse(new MockHttpServletResponse());//Mockito.mock(VtiSoapResponse.class);
Element requestElement = Mockito.mock(Element.class);
SimpleNamespaceContext nc = Mockito.mock(SimpleNamespaceContext.class);
Element rootElement = new DefaultElement(QName.get("root", "lists", "some://uri"));
when(soapRequest.getDocument()).thenReturn(new DefaultDocument(rootElement));
// Invoke the method under test.
listItemsEndpoint.executeListActionDetails(soapRequest, soapResponse,
"my-site", "documentLibrary", requestElement, nc);
// Check the condition this test is for.
verify(listHandler).getList("documentLibrary", "my-site");
}
示例2: sendRosterToComponent
import org.dom4j.QName; //导入方法依赖的package包/类
private void sendRosterToComponent(IQ requestPacket, Collection<RosterItem> items, String subdomain) {
IQ response = IQ.createResultIQ(requestPacket);
response.setTo(subdomain);
Element query = new DefaultElement( QName.get("query","jabber:iq:roster"));
for (RosterItem i : items) {
String jid = i.getJid().toString();
if (!jid.equals(subdomain) && jid.contains(subdomain)) {
Log.debug("Roster exchange for external component " + subdomain + ". Sending user " + i.getJid().toString());
Element item = new DefaultElement("item", null);
item.add(new DefaultAttribute("jid", i.getJid().toString()));
item.add(new DefaultAttribute("name", i.getNickname()));
item.add(new DefaultAttribute("subscription", "both"));
for (String s : i.getGroups()) {
Element group = new DefaultElement("group");
group.setText(s);
item.add(group);
}
query.add(item);
}
}
response.setChildElement(query);
dispatchPacket(response);
}
示例3: main
import org.dom4j.QName; //导入方法依赖的package包/类
public static void main(String args[]){
Namespace rootNs = new Namespace("", "uri:oozie:workflow:0.4"); // root namespace uri
QName rootQName = QName.get("workflow-app", rootNs); // your root element's name
Element workflow = DocumentHelper.createElement(rootQName);
Document doc = DocumentHelper.createDocument(workflow);
workflow.addAttribute("name", "test");
Element test = workflow.addElement("test");
test.addText("hello");
OutputFormat outputFormat = OutputFormat.createPrettyPrint();
outputFormat.setEncoding("UTF-8");
outputFormat.setIndent(true);
outputFormat.setIndent(" ");
outputFormat.setNewlines(true);
try {
StringWriter stringWriter = new StringWriter();
XMLWriter xmlWriter = new XMLWriter(stringWriter);
xmlWriter.write(doc);
xmlWriter.close();
System.out.println( doc.asXML() );
System.out.println( stringWriter.toString().trim());
} catch (Exception ex) {
ex.printStackTrace();
}
}
示例4: generateActionXML
import org.dom4j.QName; //导入方法依赖的package包/类
/**
* the detail xml configurations goes here, this will be called in append2XML
* @param action
*/
public void generateActionXML(Element action) {
Namespace xmlns = new Namespace("", "uri:oozie:shell-action:0.2"); // root namespace uri
QName qName = QName.get("shell", xmlns); // your root element's name
Element shell = action.addElement(qName);
// action.appendChild( shell );
generateElement(shell, "job-tracker", "${jobTracker}");
generateElement(shell, "name-node", "${nameNode}");
Element configuration = shell.addElement("configuration");
createProperty(configuration, "mapred.job.queue.name", "${queueName}");
createProperty(configuration, "mapreduce.map.memeory.mb", "10240");
if( program.isScriptProgram() ){
//单机脚本类型程序
generateElement(shell, "exec", "./" + widgetId + ".startup");
} else {
generateElement(shell, "exec", "./run.sh");
}
command2XMLforShell(shell);
if( program.isScriptProgram() ){
generateElement(shell, "file", "${appPath}/" + widgetId
+ ".startup");
generateElement(shell, "file", "${appPath}/" + widgetId
+ ".script");
} else
generateElement(shell, "file", "${nameNode}/" + program.getPath()
+ "/run.sh");
shell.addElement("capture-output");
}
示例5: addIgnoreExchangeEventProperty
import org.dom4j.QName; //导入方法依赖的package包/类
private void addIgnoreExchangeEventProperty(CamelProcessItem item) throws PersistenceException, DocumentException {
String springContent = item.getSpringContent();
if (null != springContent && !springContent.isEmpty()) {
Document document = DocumentHelper.parseText(springContent);
QName qname = QName.get("bean", SPRING_BEANS_NAMESPACE);
List<Element> beans = document.getRootElement().elements(qname);
for (Element bean : beans) {
if ("jmxEventNotifier".equals(bean.attributeValue("id")) &&
"org.apache.camel.management.JmxNotificationEventNotifier".equals(bean.attributeValue("class")))
{
List<Element> properties = bean.elements(QName.get("property", SPRING_BEANS_NAMESPACE));
boolean hasIgnore = false;
for (Element property : properties) {
List<Attribute> propertyAttributes = property.attributes();
for (Attribute propertyAttribute : propertyAttributes) {
if (propertyAttribute.getValue().equals(IGNORE_EXCHANGE_EVENTS)) {
hasIgnore = true;
break;
}
}
}
if (!hasIgnore)
{
DefaultElement ignoreExchangeElement = new DefaultElement("property", bean.getNamespace());
ignoreExchangeElement.add(DocumentHelper.createAttribute(ignoreExchangeElement, "name", IGNORE_EXCHANGE_EVENTS));
ignoreExchangeElement.add(DocumentHelper.createAttribute(ignoreExchangeElement, "value", "true"));
bean.add(ignoreExchangeElement);
item.setSpringContent(document.asXML());
saveItem(item);
}
break;
}
}
}
}
示例6: enable
import org.dom4j.QName; //导入方法依赖的package包/类
/**
* Attempts to enable Stream Management for the entity identified by the provided JID.
*
* @param namespace The namespace that defines what version of SM is to be enabled.
* @param resume Whether the client is requesting a resumable session.
*/
private void enable( String namespace, boolean resume )
{
boolean offerResume = allowResume();
// Ensure that resource binding has occurred.
if (session.getStatus() != Session.STATUS_AUTHENTICATED) {
this.namespace = namespace;
sendUnexpectedError();
return;
}
String smId = null;
synchronized ( this )
{
// Do nothing if already enabled
if ( isEnabled() )
{
sendUnexpectedError();
return;
}
this.namespace = namespace;
this.resume = resume && offerResume;
if ( this.resume ) {
// Create SM-ID.
smId = StringUtils.encodeBase64( session.getAddress().getResource() + "\0" + session.getStreamID().getID());
}
}
// Send confirmation to the requestee.
Element enabled = new DOMElement(QName.get("enabled", namespace));
if (this.resume) {
enabled.addAttribute("resume", "true");
enabled.addAttribute( "id", smId);
}
session.deliverRawText(enabled.asXML());
}
示例7: sendEmptyRoster
import org.dom4j.QName; //导入方法依赖的package包/类
private void sendEmptyRoster(Packet requestPacket, String subdomain) {
IQ iq = (IQ) requestPacket;
IQ response = IQ.createResultIQ(iq);
response.setTo(subdomain);
Element query = new DefaultElement( QName.get("query","jabber:iq:roster") );
response.setChildElement(query);
dispatchPacket(response);
}
示例8: toWorkflow
import org.dom4j.QName; //导入方法依赖的package包/类
/**
* Transform the Graph into an workflow xml definition
* @param jobname the job name of Oozie job, can't be null
* @return workflow xml
*/
public String toWorkflow(String jobname) {
Namespace xmlns = new Namespace("", "uri:oozie:workflow:0.4"); // root namespace uri
QName qName = QName.get("workflow-app", xmlns); // your root element's name
Element workflow = DocumentHelper.createElement(qName);
Document xmldoc = DocumentHelper.createDocument(workflow);
// Create workflow root
workflow.addAttribute("xmlns", "uri:oozie:workflow:0.4");
// <workflow-app name='xxx'></workflow-app>
if (jobname == null || "".equals(jobname))
workflow.addAttribute("name", "Not specified");
else
workflow.addAttribute("name", jobname);
Queue<NodeDef> que = new LinkedList<NodeDef>();
que.add(start);
while (!que.isEmpty()) {
NodeDef cur = que.remove();
cur.append2XML(workflow);
for (NodeDef toNode : cur.getOutNodes()) {
toNode.delInNode(cur);
if (toNode.getInDegree() == 0)
que.add(toNode);
}
}
// Set XML document format
OutputFormat outputFormat = OutputFormat.createPrettyPrint();
// Set XML encoding, use the specified encoding to save the XML document to the string, it can be specified GBK or ISO8859-1
outputFormat.setEncoding("UTF-8");
outputFormat.setSuppressDeclaration(true); // Whether generate xml header
outputFormat.setIndent(true); // Whether set indentation
outputFormat.setIndent(" "); // Implement indentation with four spaces
outputFormat.setNewlines(true); // Set whether to wrap
try {
// stringWriter is used to save xml document
StringWriter stringWriter = new StringWriter();
// xmlWriter is used to write XML document to string(tool)
XMLWriter xmlWriter = new XMLWriter(stringWriter, outputFormat);
// Write the created XML document into the string
xmlWriter.write(xmldoc);
xmlWriter.close();
System.out.println( stringWriter.toString().trim());
// Print the string, that is, the XML document
return stringWriter.toString().trim();
} catch (Exception ex) {
ex.printStackTrace();
}
return null;
}