当前位置: 首页>>代码示例>>Java>>正文


Java Element.addAttribute方法代码示例

本文整理汇总了Java中tigase.xml.Element.addAttribute方法的典型用法代码示例。如果您正苦于以下问题:Java Element.addAttribute方法的具体用法?Java Element.addAttribute怎么用?Java Element.addAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在tigase.xml.Element的用法示例。


在下文中一共展示了Element.addAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getValidResponse

import tigase.xml.Element; //导入方法依赖的package包/类
private Packet getValidResponse(String elem_name, CID cid, String id, StanzaType type,
		String cdata) {
	Element elem = new Element(elem_name);

	if (cdata != null) {
		elem.setCData(cdata);
	}
	if (type != null) {
		elem.addAttribute("type", type.name());
	}
	if (id != null) {
		elem.addAttribute("id", id);
	}

	Packet result = Packet.packetInstance(elem, JID.jidInstanceNS(cid.getLocalHost()), JID
			.jidInstanceNS(cid.getRemoteHost()));

	return result;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:20,代码来源:S2SConnectionManager.java

示例2: sendEvent

import tigase.xml.Element; //导入方法依赖的package包/类
private void sendEvent( REPO_ITEM_UPDATE_TYPE action, String hostname, String secondary ) {

		// either RepositoryItem was wrong or EventBus is not enabled - skiping broadcasting the event;
		if ( eventBus == null || hostname == null ){
			return;
		}

		Element event = new Element( REPO_ITEM_EVENT_NAME, new String[] { "xmlns" },
																 new String[] { EVENTBUS_REPO_ITEM_EVENT_XMLNS } );
		event.setAttribute( "local", "true" );
		Element repoItem = new Element( "repo-item" );
		{
			repoItem.setAttribute( "action", action.name() );
			repoItem.addAttribute( "hostname", hostname );
			repoItem.addAttribute( "secondary", ( null != secondary ? secondary : "" ) );
		}
		event.addChild( repoItem );

		if ( log.isLoggable( Level.FINEST ) ){
			log.log( Level.FINEST, "Sending event: " + event );
		}

		eventBus.fire( event );

	}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:26,代码来源:ClusterConnectionManager.java

示例3: sendEvent

import tigase.xml.Element; //导入方法依赖的package包/类
private void sendEvent( String action, BareJID... user ) {
	if ( user != null && user.length > 0 ){

		Element event = new Element( presenceSessionEventName, new String[] { "xmlns" },
																 new String[] { EVENTBUS_PRESENCE_SESSION_XMLNS } );
		for ( BareJID bareJID : user ) {
			if ( bareJID != null ){
				Element jidElement = new Element( "jid", bareJID.toString() );
				jidElement.addAttribute( "action", action );
				event.addChild( jidElement );
			}
		}

		if ( log.isLoggable( Level.FINEST ) ){
			log.log( Level.FINEST, "Sending event: " + event );
		}

		eventBus.fire( event );
	}

}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:22,代码来源:PresenceOffline.java

示例4: makeElement

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * Method description
 * 
 * 
 * @param insertOriginal
 * 
 * @return
 */
public Element makeElement(boolean insertOriginal) {
	Element answer = insertOriginal ? item.clone() : new Element(item.getName());

	answer.addAttribute("id", item.getAttributeStaticStr("id"));
	answer.addAttribute("type", "error");
	answer.addAttribute("to", item.getAttributeStaticStr("from"));
	answer.addAttribute("from", item.getAttributeStaticStr("to"));
	if (this.message != null) {
		Element text = new Element("text", this.message, new String[] { "xmlns" },
				new String[] { "urn:ietf:params:xml:ns:xmpp-stanzas" });

		answer.addChild(text);
	}
	answer.addChild(makeErrorElement());

	return answer;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:26,代码来源:AdHocCommandException.java

示例5: toElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public Element toElement() {
	final Element elem = super.toElement();

	elem.addAttribute(TASK_NAME_ATT, this.taskName);
	elem.addAttribute(TASK_TYPE_ATT, this.type.name());

	if (this.scriptExtension != null)
		elem.addAttribute(SCRIPT_EXT_ATT, this.scriptExtension);

	if (this.taskScript != null)
		elem.addChild(new Element(SCRIPT_ELEM, Base64.encode(this.taskScript.getBytes())));

	if (this.taskClass != null)
		elem.addChild(new Element(CLASS_ELEM, this.taskClass.getName()));

	if (this.configuration != null) {
		elem.addChild(this.configuration.getElement());
	}

	return elem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:23,代码来源:TaskConfigItem.java

示例6: toElement

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * Method description
 *
 *
 * 
 */
@Override
public Element toElement() {
	Element elem = super.toElement();

	if (clusterNode != null) {
		elem.addAttribute(CLUSTER_NODE_ATTR, clusterNode);
	}
	elem.addAttribute(COMPONENT_NAME_ATTR, compName);
	if (nodeName != null) {
		elem.addAttribute(NODE_NAME_ATTR, nodeName);
	}
	elem.addAttribute(KEY_NAME_ATTR, keyName);
	elem.addAttribute(VALUE_ATTR, DataTypes.valueToString(value));
	elem.addAttribute(VALUE_TYPE_ATTR, "" + DataTypes.getTypeId(value));
	elem.addAttribute(FLAG_ATTR, flag.name());

	return elem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:25,代码来源:ConfigItem.java

示例7: getMessage

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * Creates a packet with message stanza.
 *
 *
 * @param from
 *          is a <code>JID</code> instance with message source address.
 * @param to
 *          is a <code>JID</code> instance with message destination address.
 * @param type
 *          is a <code>StanzaType</code> object with the message type.
 * @param body
 *          is a <code>String</code> object with message body content.
 * @param subject
 *          is a <code>String</code> object with message subject.
 * @param thread
 *          is a <code>String</code> object with message thread.
 * @param id
 *          is a <code>String</code> object with packet id value. Normally we
 *          do not set packet IDs for messages but in some cases this might be
 *          useful.
 *
 * @return a new <code>Packet</code> instance (more specifically
 *         <code>Message</code> instance) with the message stanza.
 */
public static Packet getMessage(JID from, JID to, StanzaType type, String body,
		String subject, String thread, String id) {
	Element message = new Element("message", null, null);

	message.setXMLNS(CLIENT_XMLNS);
	if (body != null) {
		message.addChild(new Element("body", body));
	}
	if (from != null) {
		message.addAttribute("from", from.toString());
	}
	if (to != null) {
		message.addAttribute("to", to.toString());
	}
	if (type != null) {
		message.addAttribute("type", type.name());
	}
	if (id != null) {
		message.addAttribute("id", id);
	}
	if (subject != null) {
		message.addChild(new Element("subject", subject));
	}
	if (thread != null) {
		message.addChild(new Element("thread", thread));
	}

	return packetInstance(message, from, to);
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:54,代码来源:Message.java

示例8: getBodyElem

import tigase.xml.Element; //导入方法依赖的package包/类
private Element getBodyElem() {
	Element body = new Element(BODY_EL_NAME, new String[] { FROM_ATTR, SECURE_ATTR,
			"xmpp:version", "xmlns:xmpp", "xmlns:stream" }, new String[] { this.domain,
			"true", "1.0", "urn:xmpp:xbosh", "http://etherx.jabber.org/streams" });

	if (this.hostname != null) {
		body.addAttribute(HOST_ATTR, this.hostname);
	}
	
	body.setXMLNS(BOSH_XMLNS);

	return body;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:14,代码来源:BoshSession.java

示例9: toElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public Element toElement() {
	Element elem = super.toElement();

	elem.addAttribute(DOMAIN_ATTR, domain);
	elem.addAttribute(PASSWORD_ATTR, auth_pass);
	if ((remoteHost != null) &&!remoteHost.isEmpty()) {
		elem.addAttribute(REMOTE_HOST_ATTR, remoteHost);
	}
	elem.addAttribute(CONN_TYPE_ATTR, type.name());
	if (port > 0) {
		elem.addAttribute(PORT_NO_ATTR, "" + port);
	}
	if (prop_xmlns != null)
		elem.addAttribute(PROTO_XMLNS_ATTR, prop_xmlns);
	elem.addAttribute(LB_NAME_ATTR, lb.getClass().getName());

	StringBuilder route = new StringBuilder();

	for (String r : routings) {
		if (route.length() > 0) {
			route.append(',');
		}
		route.append(r);
	}
	elem.addAttribute(ROUTINGS_ATTR, route.toString());

	return elem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:30,代码来源:CompRepoItem.java

示例10: toElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public Element toElement() {
	Element elem = new Element(getElemName());

	if (owner != null) {
		elem.addAttribute(OWNER_ATT, owner);
	}
	if (admins != null) {
		elem.addAttribute(ADMINS_ATT, adminsToString(admins));
	}

	return elem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:14,代码来源:RepositoryItemAbstract.java

示例11: toElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public Element toElement() {
	Element elem = super.toElement();

	elem.addAttribute( HOSTNAME_ATTR, hostname );
	elem.addAttribute( SECONDARY_HOSTNAME_ATTR, secondaryHostname );
	elem.addAttribute( PASSWORD_ATTR, password );
	elem.addAttribute( PORT_NO_ATTR, "" + portNo );
	elem.addAttribute( LAST_UPDATE_ATTR, "" + lastUpdate );
	elem.addAttribute( CPU_USAGE_ATTR, "" + cpuUsage );
	elem.addAttribute( MEM_USAGE_ATTR, "" + memUsage );

	return elem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:15,代码来源:ClusterRepoItem.java

示例12: updateBuddyChange

import tigase.xml.Element; //导入方法依赖的package包/类
public void updateBuddyChange(final XMPPResourceConnection session,
		final Queue<Packet> results, final Element item)
				throws NotAuthorizedException, TigaseDBException, NoConnectionIdException {
	Element update = new Element("iq");

	update.setXMLNS(CLIENT_XMLNS);
	update.setAttribute("type", StanzaType.set.toString());

	Element query = new Element("query");

	query.setXMLNS(ROSTER_XMLNS);
	query.addAttribute(VER_ATT, getBuddiesHash(session));
	query.addChild(item);
	update.addChild(query);
	for (XMPPResourceConnection conn : session.getActiveSessions()) {
		Element conn_update = update.clone();

		conn_update.setAttribute("to", conn.getBareJID().toString());
		conn_update.setAttribute("id", "rst" + session.nextStanzaId());

		Packet pack_update = Packet.packetInstance(conn_update, null, conn.getJID());

		pack_update.setPacketTo(conn.getConnectionId());

		// pack_update.setPacketFrom(session.getJID());
		results.offer(pack_update);
	}    // end of for (XMPPResourceConnection conn: sessions)
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:29,代码来源:RosterAbstract.java

示例13: process

import tigase.xml.Element; //导入方法依赖的package包/类
public Packet process(Packet packet, Element commandElement, String node, String action, String sessionId,
		AdHocCommand adHocCommand) throws AdHocCommandException {
	State currentState = null;
	final AdhHocRequest request = new AdhHocRequest(packet, commandElement, node, packet.getStanzaFrom(), action,
			sessionId);
	final AdHocResponse response = new AdHocResponse(sessionId, currentState);
	final AdHocSession session = (sessionId == null) ? new AdHocSession() : this.sessions.get(sessionId);

	adHocCommand.execute(request, response);

	Element commandResult = new Element("command", new String[] { "xmlns", "node", },
			new String[] { "http://jabber.org/protocol/commands", node });

	commandResult.addAttribute("status", response.getNewState().name());
	if ((response.getCurrentState() == null) && (response.getNewState() == State.executing)) {
		this.sessions.put(response.getSessionid(), session);
	} else if ((response.getSessionid() != null)
			&& ((response.getNewState() == State.canceled) || (response.getNewState() == State.completed))) {
		this.sessions.remove(response.getSessionid());
	}
	if (response.getSessionid() != null) {
		commandResult.addAttribute("sessionid", response.getSessionid());
	}
	for (Element r : response.getElements()) {
		commandResult.addChild(r);
	}

	return packet.okResult(commandResult, 0);
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:30,代码来源:AdHocCommandManager.java

示例14: prepareUnsubscribeElement

import tigase.xml.Element; //导入方法依赖的package包/类
private Element prepareUnsubscribeElement(EventName event, JID jid, String service) {
	Element subscribeElem = new Element("unsubscribe");
	subscribeElem.addAttribute("node", event.toEventBusNode());
	subscribeElem.addAttribute("jid", jid.toString());

	if (service != null) {
		subscribeElem.addChild(new Element("service", service));
	}

	return subscribeElem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:12,代码来源:UnsubscribeModule.java

示例15: prepareSubscribeElement

import tigase.xml.Element; //导入方法依赖的package包/类
private Element prepareSubscribeElement(EventName event, JID jid, String service) {
	Element subscribeElem = new Element("subscribe");
	subscribeElem.addAttribute("node", event.toEventBusNode());
	subscribeElem.addAttribute("jid", jid.toString());

	if (service != null) {
		subscribeElem.addChild(new Element("service", service));
	}

	return subscribeElem;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:12,代码来源:SubscribeModule.java


注:本文中的tigase.xml.Element.addAttribute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。