当前位置: 首页>>代码示例>>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;未经允许,请勿转载。