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


Java Element.getName方法代码示例

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


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

示例1: packetInstance

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * The method returns <code>Packet</code> instance.
 * More specifically it returns instance of one of the following classes:
 * <code>Iq</code>, <code>Message</code> or <code>Presence</code>. It takes stanza XML
 * element as an arguments, parses some the most commonly used data and created an
 * object.
 * Pre-parsed information are: stanza from/to addresses, stanza id, type and presets
 * the <code>Packet</code> priority.<br>
 * If there is a stringprep processing error for either the stanza source or destination
 * address <code>TigaseStringprepException</code> exception is thrown.
 * @param elem is a stanza XML <code>Element</code>
 * @return a <code>Packet</code> instance, more specifically instance of one of the
 * following classes: <code>Iq</code>, <code>Message</code> or <code>Presence</code>.
 * @throws TigaseStringprepException if there is stanza from or to address parsing
 * error.
 */
public static Packet packetInstance(Element elem) throws TigaseStringprepException {
	Packet result = null;

	if (elem.getName() == Message.ELEM_NAME) {
		result = new Message(elem);
	}
	if (elem.getName() == Presence.ELEM_NAME) {
		result = new Presence(elem);
	}
	if (elem.getName() == Iq.ELEM_NAME) {
		result = new Iq(elem);
	}
	if (result == null) {
		result = new Packet(elem);
	}

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

示例2: setElem

import tigase.xml.Element; //导入方法依赖的package包/类
private void setElem(Element elem) {
	if (elem == null) {
		throw new NullPointerException();
	}    // end of if (elem == null)
	this.elem = elem;
	if (elem.getAttributeStaticStr(TYPE_ATT) != null) {
		type = StanzaType.valueof(elem.getAttributeStaticStr(TYPE_ATT));
	} else {
		type = null;
	}    // end of if (elem.getAttribute("type") != null) else
	if (elem.getName() == "cluster") {
		setPriority(Priority.CLUSTER);
	} else {
		if ((elem.getName() == "presence") &&
				((type == null) || (type == StanzaType.available) ||
				 (type == StanzaType.unavailable) || (type == StanzaType.probe))) {
			setPriority(Priority.PRESENCE);
		} else {
			if (elem.getName() == "route") {
				routed = true;
			} else {
				routed = false;
			}    // end of if (elem.getName().equals("route")) else
		}
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:27,代码来源:Packet.java

示例3: applyFilters

import tigase.xml.Element; //导入方法依赖的package包/类
private Element applyFilters(Element packet) {
	Element result = packet.clone();

	if (result.getName() == MESSAGE_ELEMENT_NAME) {
		String body = result.getCDataStaticStr(Message.MESSAGE_BODY_PATH);

		if (body != null) {
			int count = 0;

			// for (Pattern reg: links_regexs) {
			// body = reg.matcher(body).replaceAll(replace_with[count++]);
			// }
			result.getChild("body").setCData(body);
		}
	}

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

示例4: getItemGroups

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * Returns an array of group names retrieved from Element item
 *
 * @param item from which groups should be obtained
 * @return an array of group names retrieved from Element item
 */
public static String[] getItemGroups( Element item ) {
	List<Element> elgr = item.getChildren();

	if ( ( elgr != null ) && ( elgr.size() > 0 ) ){
		ArrayList<String> groups = new ArrayList<String>( 1 );

		for ( Element grp : elgr ) {
			if ( grp.getName() == RosterAbstract.GROUP ){
				groups.add( grp.getCData() );
			}
		}
		if ( groups.size() > 0 ){
			return groups.toArray( new String[ groups.size() ] );
		}
	}

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

示例5: initFromElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void initFromElement(Element elem) {
	if (elem.getName() != ELEM_NAME) {
		throw new IllegalArgumentException("Incorrect element name, expected: " + ELEM_NAME);
	}
	super.initFromElement(elem);

	this.taskName = elem.getAttributeStaticStr(TASK_NAME_ATT);
	try {
		this.type = Type.valueOf(elem.getAttributeStaticStr(TASK_TYPE_ATT));
	} catch (Exception e) {
		e.printStackTrace();
	}
	this.scriptExtension = elem.getAttributeStaticStr(SCRIPT_EXT_ATT);

	setTaskClass(elem.getAttributeStaticStr(TASK_CLASS_ATT));
	setTaskScriptEncoded(elem.getCDataStaticStr(TASK_SCRIPT_PATH));

	Element form = elem.getChild("x", "jabber:x:data");
	if (form != null) {
		this.configuration = new Form(form);
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:24,代码来源:TaskConfigItem.java

示例6: getErrorCondition

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * Method parses the stanza and returns the error condition if there is any.
 *
 * @return parsed stanza error condition or NULL if there is not error condition.
 */
public String getErrorCondition() {
	List<Element> children = elem.getChildrenStaticStr(getElNameErrorPath());

	if (children != null) {
		for (Element cond : children) {
			if (!cond.getName().equals("text")) {
				return cond.getName();
			}    // end of if (!cond.getName().equals("text"))
		}      // end of for (Element cond: children)
	}        // end of if (children == null) else

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

示例7: initFromElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void initFromElement(Element elem) {
	if (elem.getName() != REPO_ITEM_ELEM_NAME) {
		throw new IllegalArgumentException("Incorrect element name, expected: " +
																			 REPO_ITEM_ELEM_NAME);
	}
	super.initFromElement(elem);
	setDomain(elem.getAttributeStaticStr(DOMAIN_ATTR));
	auth_pass  = elem.getAttributeStaticStr(PASSWORD_ATTR);
	remoteHost = elem.getAttributeStaticStr(REMOTE_HOST_ATTR);

	String tmp = elem.getAttributeStaticStr(CONN_TYPE_ATTR);

	if (tmp != null) {
		setConnectionType(tmp);
	}
	tmp = elem.getAttributeStaticStr(PORT_NO_ATTR);
	if (tmp != null) {
		port = parsePortNo(tmp);
	}
	tmp = elem.getAttributeStaticStr(PROTO_XMLNS_ATTR);
	if (tmp != null) {
		setProtocol(tmp);
	}
	tmp = elem.getAttributeStaticStr(LB_NAME_ATTR);
	if (tmp != null) {
		lb = lbInstance(tmp);
	}
	tmp = elem.getAttributeStaticStr(ROUTINGS_ATTR);
	if (tmp != null) {
		routings = tmp.split(",");
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:34,代码来源:CompRepoItem.java

示例8: parseMethodCall

import tigase.xml.Element; //导入方法依赖的package包/类
/**
 * Method description
 *
 *
 * @param method_call
 */
protected void parseMethodCall(Element method_call) {
	method_name = method_call.getAttributeStaticStr(CLUSTER_NAME_ATTR);
	if (method_name != null) {
		method_name = method_name.intern();
	}
	method_params = new LinkedHashMap<String, String>();

	List<Element> children = method_call.getChildren();

	if (children != null) {
		for (Element child : children) {
			if (child.getName() == CLUSTER_METHOD_PAR_EL_NAME) {
				String par_name = child.getAttributeStaticStr(CLUSTER_NAME_ATTR);

				method_params.put(par_name, child.getCData());
			}
			if (child.getName() == CLUSTER_METHOD_RESULTS_EL_NAME) {
				if (method_results == null) {
					method_results = new LinkedHashMap<String, String>();
				}

				List<Element> res_children = child.getChildren();

				if (res_children != null) {
					for (Element res_child : res_children) {
						if (res_child.getName() == CLUSTER_METHOD_RESULTS_VAL_EL_NAME) {
							String val_name = res_child.getAttributeStaticStr(CLUSTER_NAME_ATTR);

							method_results.put(val_name, res_child.getCData());
						}
					}
				}
			}
		}
	}
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:43,代码来源:ClusterElement.java

示例9: initFromElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void initFromElement( Element elem ) {
	if ( elem.getName() != REPO_ITEM_ELEM_NAME ){
		throw new IllegalArgumentException( "Incorrect element name, expected: "
																				+ REPO_ITEM_ELEM_NAME );
	}
	super.initFromElement( elem );
	hostname = elem.getAttributeStaticStr( HOSTNAME_ATTR );
	secondaryHostname = elem.getAttributeStaticStr( SECONDARY_HOSTNAME_ATTR );
	password = elem.getAttributeStaticStr( PASSWORD_ATTR );
	portNo = parsePortNo( elem.getAttributeStaticStr( PORT_NO_ATTR ) );
	lastUpdate = Long.parseLong( elem.getAttributeStaticStr( LAST_UPDATE_ATTR ) );
	cpuUsage = Float.parseFloat( elem.getAttributeStaticStr( CPU_USAGE_ATTR ) );
	memUsage = Float.parseFloat( elem.getAttributeStaticStr( MEM_USAGE_ATTR ) );
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:16,代码来源:ClusterRepoItem.java

示例10: matchToPrivacyListElement

import tigase.xml.Element; //导入方法依赖的package包/类
protected boolean matchToPrivacyListElement(boolean packetIn, Packet packet, Element elem, ITEM_ACTION action) {
	if ((packet.getElemName() == PRESENCE_EL_NAME)
			&& ((packetIn && (elem.getName() == PRESENCE_IN_EL_NAME)) || (!packetIn && (elem.getName() == PRESENCE_OUT_EL_NAME)))
			&& ((packet.getType() == null) || (packet.getType() == StanzaType.unavailable))) {
		return true;
	}
	if (packetIn && (elem.getName() == packet.getElemName())) {
		return true;
	}
	return false;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:12,代码来源:JabberIqPrivacy.java

示例11: fire

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void fire(final Element event) {
	final String name = event.getName();
	final String xmlns = event.getXMLNS();

	doFire(name, xmlns, event);
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:8,代码来源:LocalEventBus.java

示例12: endElement

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public boolean endElement(StringBuilder name) {
	if (log.isLoggable(Level.FINEST)) {
		log.finest("End element name: " + name);
	}

	String tmp_name = name.toString();

	if (tmp_name.equals(ELEM_STREAM_STREAM)) {
		// we should not call xmppStreamClosed() as we still may have received 
		// some packets which may not be processed correctly if we close stream now!
		//service.xmppStreamClosed();
		streamClosed = true;
		return true;
	}    // end of if (tmp_name.equals(ELEM_STREAM_STREAM))

	if (el_stack.isEmpty()) {
		el_stack.push(newElement(tmp_name, null, null, null));
	}    // end of if (tmp_name.equals())

	Element elem = el_stack.pop();
	int idx = tmp_name.indexOf(':');
	String tmp_xmlns = null;

	if (idx > 0) {
		String tmp_name_prefix = tmp_name.substring(0, idx);
		if (tmp_name_prefix != null) {
			for (String pref : namespaces.keySet()) {
				if (tmp_name_prefix.equals(pref)) {
					tmp_xmlns = namespaces.get(pref);
					tmp_name = tmp_name.substring(pref.length() + 1, tmp_name.length());

					if (log.isLoggable(Level.FINEST)) {
						log.finest("new_xmlns = " + tmp_xmlns);
					}
				}    // end of if (tmp_name.startsWith(xmlns))
			}      // end of for (String xmlns: namespaces.keys())
		}		
	}		
	if (elem.getName() != tmp_name.intern() || (tmp_xmlns != null && !tmp_xmlns.equals(elem.getXMLNS())))
		return false;

	if (el_stack.isEmpty()) {
		elements_number_limit_count = 0;
		all_roots.offer(elem);

		if (log.isLoggable(Level.FINEST)) {
			log.finest("Adding new request: " + elem.toString());
		}
	} else {
		el_stack.peek().addChild(elem);
	}    // end of if (el_stack.isEmpty()) else
	return true;
}
 
开发者ID:kontalk,项目名称:tigase-server,代码行数:55,代码来源:XMPPDomBuilderHandler.java

示例13: process

import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void process(Packet packet) throws ComponentException, TigaseStringprepException {
	final Affiliation affiliation = context.getAffiliationStore().getAffiliation(packet.getStanzaFrom());
	if (!affiliation.isPublishItem())
		throw new ComponentException(Authorization.FORBIDDEN);

	final String type = packet.getElement().getAttributeStaticStr("type");

	if (type != null && type.equals("error")) {
		if (log.isLoggable(Level.FINE))
			log.fine("Ignoring error message! " + packet);
		return;
	}

	if (log.isLoggable(Level.FINER))
		log.finer("Received event stanza: " + packet.toStringFull());

	Element eventElem = packet.getElement().getChild("event", "http://jabber.org/protocol/pubsub#event");
	Element itemsElem = eventElem.getChild("items");

	for (Element item : itemsElem.getChildren()) {
		if (!"item".equals(item.getName()))
			continue;
		for (Element event : item.getChildren()) {
			String eventName = event.getName();
			String eventXmlns = event.getXMLNS();

			event.setAttribute("remote", "true");

			if (log.isLoggable(Level.FINER))
				log.finer("Received event (" + eventName + ", " + eventXmlns + "): " + event);

			context.getEventBusInstance().doFire(eventName, eventXmlns, event);

			// forwarding event to _non cluster_ subscribers.
			final Collection<Subscription> subscribers = context.getSubscriptionStore().getSubscribersJIDs(eventName,
					eventXmlns);
			Iterator<Subscription> it = subscribers.iterator();
			while (it.hasNext()) {
				Subscription subscription = it.next();
				if (subscription.isInClusterSubscription())
					it.remove();
			}
			eventPublisherModule.publishEvent(eventName, eventXmlns, event, subscribers);
		}
	}

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


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