當前位置: 首頁>>代碼示例>>Java>>正文


Java QName類代碼示例

本文整理匯總了Java中org.dom4j.QName的典型用法代碼示例。如果您正苦於以下問題:Java QName類的具體用法?Java QName怎麽用?Java QName使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


QName類屬於org.dom4j包,在下文中一共展示了QName類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toDsml

import org.dom4j.QName; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public Element toDsml( Element root )
{
    Element element = super.toDsml( root );

    // Request Name
    if ( getDecorated().getRequestName() != null )
    {
        element.addElement( "requestName" ).setText(
            getDecorated().getRequestName() );
    }

    // Request Value        
    Namespace xsdNamespace = new Namespace( "xsd", ParserUtils.XML_SCHEMA_URI );
    Namespace xsiNamespace = new Namespace( "xsi", ParserUtils.XML_SCHEMA_INSTANCE_URI );
    element.getDocument().getRootElement().add( xsdNamespace );
    element.getDocument().getRootElement().add( xsiNamespace );

    Element valueElement = element.addElement( "requestValue" ).addText(
        ParserUtils.base64Encode( getRequestValue() ) );
    valueElement.addAttribute( new QName( "type", xsiNamespace ),
        "xsd:" + ParserUtils.BASE64BINARY );

    return element;
}
 
開發者ID:apache,項目名稱:directory-ldap-api,代碼行數:29,代碼來源:ExtendedRequestDsml.java

示例2: resolveQName

import org.dom4j.QName; //導入依賴的package包/類
/**
 *  Tries to resolve give QName into a "top-level" namespace and prefix. If the
 *  there is no prefix and the namespace is the default namespace, assign the
 *  NAMED defaultNamespace.
 *
 * @param  qName          Description of the Parameter
 * @return                Description of the Return Value
 * @exception  Exception  Description of the Exception
 */
private QName resolveQName(QName qName) throws Exception {
	String prefix = qName.getNamespacePrefix();
	String name = qName.getName();
	String uri = qName.getNamespaceURI();
	prtln("\n\t resolveQName: ", 1);
	prtln("\t\t name: " + name, 1);
	prtln("\t\t prefix: " + prefix, 1);
	prtln("\t\t uri: " + uri, 1);
	Namespace topLevelNS = namespaces.getNSforUri(uri);
	if (topLevelNS == null) {
		prtlnErr("ERROR: resolveQName could not find top-level namespace for " + uri);
		return null;
	}
	else if (topLevelNS == namespaces.getDefaultNamespace()) {
		topLevelNS = namespaces.getNamedDefaultNamespace();
	}

	return df.createQName(name, topLevelNS);
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:29,代碼來源:StructureWalker.java

示例3: createChildElement

import org.dom4j.QName; //導入依賴的package包/類
/**
 *  Resolve qualified name against top-level namespace registry
 *
 * @param  name  NOT YET DOCUMENTED
 * @return       NOT YET DOCUMENTED
 */
private Element createChildElement(String name) {
	prtln("\n createChildElement() name: " + name, 1);
	Namespace ns = getCurrentNamespace();
	prtln("\t currentNamespace -- " + ns.getPrefix() + ": " + ns.getURI(), 1);
	Element child = null;
	if (ns == null || !namespaceEnabled) {
		child = df.createElement(name);
	}
	else {
		QName baseQName = df.createQName(name, ns);
		try {
			child = df.createElement(resolveQName(baseQName));
		} catch (Exception e) {
			prtlnErr("createChildElement error: " + e.getMessage());
			e.printStackTrace();
			return null;
		}
	}
	prtln("   ... child: " + child.asXML(), 1);
	return child;
}
 
開發者ID:NCAR,項目名稱:joai-project,代碼行數:28,代碼來源:StructureWalker.java

示例4: removeNamespaces

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Remove namespaces from element recursively.
 */
@SuppressWarnings("unchecked")
public void removeNamespaces( Element elem )
{
    elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) );

    Node n;

    Iterator<Node> it = elem.elementIterator();
    while ( it.hasNext() )
    {
        n = it.next();

        switch ( n.getNodeType() )
        {
            case Node.ATTRIBUTE_NODE:
                ( (Attribute) n ).setNamespace( Namespace.NO_NAMESPACE );
                break;
            case Node.ELEMENT_NODE:
                removeNamespaces( (Element) n );
                break;
        }
    }
}
 
開發者ID:ruikom,項目名稱:apache-archiva,代碼行數:27,代碼來源:XMLReader.java

示例5: createNotificationIQ

import org.dom4j.QName; //導入依賴的package包/類
/**
 * 創建一個新的通知IQ,並返回它。
 * 
 * @param imageUrl
 */
private IQ createNotificationIQ(String id, String apiKey, String title,
		String message, String uri, String imageUrl) {
	// Random random = new Random();
	// String id = Integer.toHexString(random.nextInt());
	// String id = String.valueOf(System.currentTimeMillis());

	Element notification = DocumentHelper.createElement(QName.get(
			"notification", NOTIFICATION_NAMESPACE));
	notification.addElement("id").setText(id);
	notification.addElement("apiKey").setText(apiKey);
	notification.addElement("title").setText(title);
	notification.addElement("message").setText(message);
	notification.addElement("uri").setText(uri);
	notification.addElement("imageUrl").setText(imageUrl);

	IQ iq = new IQ();
	iq.setType(IQ.Type.set);
	iq.setChildElement(notification);

	return iq;
}
 
開發者ID:lijian17,項目名稱:androidpn-server,代碼行數:27,代碼來源:NotificationManager.java

示例6: resolveQName

import org.dom4j.QName; //導入依賴的package包/類
/**
 *  Tries to resolve give QName into a "top-level" namespace and prefix. If the
 *  there is no prefix and the namespace is the default namespace, assign the
 *  NAMED defaultNamespace.
 *
 * @param  qName          Description of the Parameter
 * @return                Description of the Return Value
 * @exception  Exception  Description of the Exception
 */
private QName resolveQName(QName qName) throws Exception {
	String prefix = qName.getNamespacePrefix();
	String name = qName.getName();
	String uri = qName.getNamespaceURI();
	prtln("\n\t resolveQName: ", 1);
	prtln("\t\t name: " + name, 1);
	prtln("\t\t prefix: " + prefix, 1);
	prtln("\t\t uri: " + uri, 1);
	Namespace topLevelNS = namespaces.getNSforUri(uri);
	if (topLevelNS == null) {
		prtlnErr("ERROR: resolveQName could not find top-level namespace for " + uri);
		return null;
	}
	else if (topLevelNS == namespaces.getDefaultNamespace()) {
		topLevelNS = namespaces.getNamedDefaultNamespace();
	}

	return DocumentHelper.createQName(name, topLevelNS);
}
 
開發者ID:NCAR,項目名稱:dls-repository-stack,代碼行數:29,代碼來源:StructureWalker.java

示例7: createChildElement

import org.dom4j.QName; //導入依賴的package包/類
/**
 *  Resolve qualified name against top-level namespace registry
 *
 * @param  name  NOT YET DOCUMENTED
 * @return       NOT YET DOCUMENTED
 */
private Element createChildElement(String name) {
	prtln("\n createChildElement() name: " + name, 1);
	Namespace ns = getCurrentNamespace();
	prtln("\t currentNamespace -- " + ns.getPrefix() + ": " + ns.getURI(), 1);
	Element child = null;
	if (ns == null || !namespaceEnabled) {
		child = DocumentHelper.createElement(name);
	}
	else {
		QName baseQName = DocumentHelper.createQName(name, ns);
		try {
			child = DocumentHelper.createElement(resolveQName(baseQName));
		} catch (Exception e) {
			prtlnErr("createChildElement error: " + e.getMessage());
			e.printStackTrace();
			return null;
		}
	}
	prtln("   ... child: " + child.asXML(), 1);
	return child;
}
 
開發者ID:NCAR,項目名稱:dls-repository-stack,代碼行數:28,代碼來源:StructureWalker.java

示例8: generateSetElementFromResults

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Generates a Result Set Management 'set' element that describes the parto
 * of the result set that was generated. You typically would use the List
 * that was returned by {@link #applyRSMDirectives(Element)} as an argument
 * to this method.
 * 
 * @param returnedResults
 *            The subset of Results that is returned by the current query.
 * @return An Element named 'set' that can be included in the result IQ
 *         stanza, which returns the subset of results.
 */
public Element generateSetElementFromResults(List<E> returnedResults) {
	if (returnedResults == null) {
		throw new IllegalArgumentException(
				"Argument 'returnedResults' cannot be null.");
	}
	final Element setElement = DocumentHelper.createElement(QName.get(
			"set", ResultSet.NAMESPACE_RESULT_SET_MANAGEMENT));
	// the size element contains the size of this entire result set.
	setElement.addElement("count").setText(String.valueOf(size()));

	// if the query wasn't a 'count only' query, add two more elements
	if (returnedResults.size() > 0) {
		final Element firstElement = setElement.addElement("first");
		firstElement.addText(returnedResults.get(0).getUID());
		firstElement.addAttribute("index", String
				.valueOf(indexOf(returnedResults.get(0))));

		setElement.addElement("last").addText(
				returnedResults.get(returnedResults.size() - 1).getUID());
	}

	return setElement;
}
 
開發者ID:citlab,項目名稱:Intercloud,代碼行數:35,代碼來源:ResultSet.java

示例9: getItems

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Returns an unmodifiable copy of the {@link Item Items} in the roster packet.
 *
 * @return an unmodifable copy of the {@link Item Items} in the roster packet.
 */
@SuppressWarnings("unchecked")
public Collection<Item> getItems() {
    Collection<Item> items = new ArrayList<Item>();
    Element query = element.element(new QName("query", Namespace.get("jabber:iq:roster")));
    if (query != null) {
        for (Iterator<Element> i=query.elementIterator("item"); i.hasNext(); ) {
            Element item = i.next();
            String jid = item.attributeValue("jid");
            String name = item.attributeValue("name");
            String ask = item.attributeValue("ask");
            String subscription = item.attributeValue("subscription");
            Collection<String> groups = new ArrayList<String>();
            for (Iterator<Element> j=item.elementIterator("group"); j.hasNext(); ) {
                Element group = j.next();
                groups.add(group.getText().trim());
            }
            Ask askStatus = ask == null ? null : Ask.valueOf(ask);
            Subscription subStatus = subscription == null ?
                    null : Subscription.valueOf(subscription);
            items.add(new Item(new JID(jid), name, askStatus, subStatus, groups));
        }
    }
    return Collections.unmodifiableCollection(items);
}
 
開發者ID:citlab,項目名稱:Intercloud,代碼行數:30,代碼來源:Roster.java

示例10: getExtension

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Returns a {@link PacketExtension} on the first element found in this packet's
 * child element for the specified <tt>name</tt> and <tt>namespace</tt> or <tt>null</tt> if
 * none was found. If the IQ packet does not have a child element then <tt>null</tt>
 * will be returned.<p>
 *
 * Note: packet extensions on IQ packets are only for use in specialized situations.
 * In most cases, you should only need to set the child element of the IQ.
 *
 * @param name the child element name.
 * @param namespace the child element namespace.
 * @return a PacketExtension on the first element found in this packet for the specified
 *         name and namespace or <tt>null</tt> if none was found.
 */
@SuppressWarnings("unchecked")
public PacketExtension getExtension(String name, String namespace) {
    Element childElement = getChildElement();
    if (childElement == null) {
        return null;
    }
    // Search for extensions in the child element
    List<Element> extensions = childElement.elements(QName.get(name, namespace));
    if (!extensions.isEmpty()) {
        Class<? extends PacketExtension> extensionClass = PacketExtension.getExtensionClass(name, namespace);
        if (extensionClass != null) {
            try {
                Constructor<? extends PacketExtension> constructor = extensionClass.getDeclaredConstructor(new Class[]{
                    Element.class});
                return constructor.newInstance(new Object[]{
                    extensions.get(0)});
            }
            catch (Exception e) {
                Log.warn("Packet extension (name "+name+", namespace "+namespace+") cannot be found.", e);
            }
        }
    }
    return null;
}
 
開發者ID:citlab,項目名稱:Intercloud,代碼行數:39,代碼來源:IQ.java

示例11: setText

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Sets the text description of the error. Optionally, a language code
 * can be specified to indicate the language of the description.
 *
 * @param text the text description of the error.
 * @param lang the language code of the description, or <tt>null</tt> to specify
 *      no language code.
 */
public void setText(String text, String lang) {
    Element textElement = element.element("text");
    // If text is null, clear the text.
    if (text == null) {
        if (textElement != null) {
            element.remove(textElement);
        }
        return;
    }

    if (textElement == null) {
        textElement = docFactory.createElement("text", ERROR_NAMESPACE);
        if (lang != null) {
            textElement.addAttribute(QName.get("lang", "xml",
                    "http://www.w3.org/XML/1998/namespace"), lang);
        }
        element.add(textElement);
    }
    textElement.setText(text);
}
 
開發者ID:citlab,項目名稱:Intercloud,代碼行數:29,代碼來源:PacketError.java

示例12: setText

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Sets the text description of the error. Optionally, a language code
 * can be specified to indicate the language of the description.
 *
 * @param text the text description of the error.
 * @param language the language code of the description, or <tt>null</tt> to specify
 *      no language code.
 */
public void setText(String text, String language) {
    Element textElement = element.element("text");
    // If text is null, clear the text.
    if (text == null) {
        if (textElement != null) {
            element.remove(textElement);
        }
        return;
    }

    if (textElement == null) {
        textElement = docFactory.createElement("text", ERROR_NAMESPACE);
        if (language != null) {
            textElement.addAttribute(QName.get("lang", "xml",
                    "http://www.w3.org/XML/1998/namespace"), language);
        }
        element.add(textElement);
    }
    textElement.setText(text);
}
 
開發者ID:citlab,項目名稱:Intercloud,代碼行數:29,代碼來源:StreamError.java

示例13: getExtension

import org.dom4j.QName; //導入依賴的package包/類
/**
 * Returns a {@link PacketExtension} on the first element found in this packet
 * for the specified <tt>name</tt> and <tt>namespace</tt> or <tt>null</tt> if
 * none was found.
 *
 * @param name the child element name.
 * @param namespace the child element namespace.
 * @return a PacketExtension on the first element found in this packet for the specified
 *         name and namespace or null if none was found.
 */
@SuppressWarnings("unchecked")
public PacketExtension getExtension(String name, String namespace) {
    List<Element> extensions = element.elements(QName.get(name, namespace));
    if (!extensions.isEmpty()) {
        Class<? extends PacketExtension> extensionClass = PacketExtension.getExtensionClass(name, namespace);
        // If a specific PacketExtension implementation has been registered, use that.
        if (extensionClass != null) {
            try {
                Constructor<? extends PacketExtension> constructor = extensionClass.getDeclaredConstructor(Element.class);
                return constructor.newInstance(extensions.get(0));
            }
            catch (Exception e) {
                Log.warn("Packet extension (name "+name+", namespace "+namespace+") cannot be found.", e);
            }
        }
        // Otherwise, use a normal PacketExtension.
        else {
            return new PacketExtension(extensions.get(0));
        }
    }
    return null;
}
 
開發者ID:citlab,項目名稱:Intercloud,代碼行數:33,代碼來源:Packet.java

示例14: addAttribute

import org.dom4j.QName; //導入依賴的package包/類
public void addAttribute(QName name, AX2JMethod method, int methodType) {
    AX2JAttribute attribute = findAttribute(name);
    if (attribute == null) {
        attribute = new AX2JAttribute(name, type);
        attributeList.add(attribute);
    }

    AX2JMethod oldMethod = findMethod(method);
    if (oldMethod != null) {
        method = oldMethod;
    } else {
        methodList.add(method);
    }

    if (method.findAttribute(attribute) == null) {
        method.addRelativeAttribute(attribute);
    }
    if (attribute.findMethod(method) == null) {
        attribute.addRelativeMethod(method, methodType);
    }
}
 
開發者ID:sickworm,項目名稱:AndroidXMLToJava,代碼行數:22,代碼來源:AX2JClassTranslator.java

示例15: construct

import org.dom4j.QName; //導入依賴的package包/類
@Override
protected void construct() {
    try {
        defaultHeader().action(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command"))
        .resourceURI(new URI("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd")).shellId(shellId);

        Element body = DocumentHelper.createElement(QName.get("Signal", Namespaces.NS_WIN_SHELL)).addAttribute(
                                                                                                               "CommandId",
                                                                                                               commandId);

        body.addElement(QName.get("Code", Namespaces.NS_WIN_SHELL))
        .addText("http://schemas.microsoft.com/wbem/wsman/1/windows/shell/signal/terminate");
        setBody(body);
    } catch (URISyntaxException e) {
        throw new RuntimeException("Error while building request content", e);
    }
}
 
開發者ID:hudson3-plugins,項目名稱:ec2-plugin,代碼行數:18,代碼來源:SignalRequest.java


注:本文中的org.dom4j.QName類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。