本文整理汇总了Java中tigase.xml.Element类的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Element类属于tigase.xml包,在下文中一共展示了Element类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: escapeElement
import tigase.xml.Element; //导入依赖的package包/类
public static void escapeElement(Element element){
if(element != null) {
try {
String originValue = element.getCData();
if (originValue != null) {
String escapedValue = QBChatUtils.escapeXml(originValue);
List<XMLNodeIfc> newChildren = new LinkedList<XMLNodeIfc>();
newChildren.add(new CData(escapedValue));
element.setChildren(newChildren);
}
}catch (NullPointerException npe){
log.severe("NullPointerException while escaping element: " + npe.toString() + ", element: " + element);
npe.printStackTrace();
}catch (Exception e){
log.severe("Exception while escaping element: " + e.toString() + ", element: " + element);
e.printStackTrace();
}
}
}
示例2: execute
import tigase.xml.Element; //导入依赖的package包/类
@Override
public void execute(Packet packet, String appId, EventBus eventBus) {
//composing || paused
Element packetEl = packet.getElement();
Element stateNotification = packetEl.getChild(QBChatUtils.COMPOSING_METRIC);
if (stateNotification == null) {
stateNotification = packetEl.getChild(QBChatUtils.PAUSED_METRIC);
}
try {
if (stateNotification.getAttributeStaticStr("xmlns").equals(CHAT_STATE_NOTIFICATIONS_XMLNS)) {
Util.fireEvent(eventBus, appId, stateNotification.getName());
}
} catch (NullPointerException e) {
}
}
示例3: onEvent
import tigase.xml.Element; //导入依赖的package包/类
@Override
public void onEvent(String name, String xmlns, Element event) {
String appId = event.getAttributeStaticStr(QBChatUtils.APP_ID_KEY);
String userId = event.getAttributeStaticStr("user_id");
String metric = event.getAttributeStaticStr("metric");
// action-attribute indicates that the element is connection
String action = event.getAttributeStaticStr("action");
//in case appId is invalid -> log incoming event elemt
try {
Integer.valueOf(appId);
} catch (NumberFormatException e) {
log.warning("Bad appId format : event type = " + name + "; event = " + event);
return;
}
if (action == null || action.equals("increment")) {
chatStatisticsStorage.increment(appId, userId, metric);
} else {
chatStatisticsStorage.decrement(appId, userId, metric);
}
}
示例4: destroyRoom
import tigase.xml.Element; //导入依赖的package包/类
@Override
public void destroyRoom(BareJID roomJID, Element destroyElement) throws RepositoryException {
if (log.isLoggable(Level.FINE)) {
log.fine("Destroying room '" + roomJID);
}
this.rooms.remove(roomJID);
//
//
final BareJID owner = getRoomOwner(roomJID);
if(owner != null) {
final Integer appID = QBChatUtils.getApplicationIDAndUserIDFromUserJIDLocalPart(owner.getLocalpart())[0];
ConcurrentHashMap<BareJID, InternalRoom> applicationRooms = allRooms.get(appID);
if (applicationRooms != null) {
applicationRooms.remove(roomJID);
}
}
dao.destroyRoom(roomJID);
}
开发者ID:QuickBlox,项目名称:QuickBlox-Tigase-CustomFeatures,代码行数:21,代码来源:InMemoryMucRepositoryWithSplitRoomsByApps.java
示例5: getDiscoItem
import tigase.xml.Element; //导入依赖的package包/类
/**
* Describe <code>getDiscoItem</code> method here.
*
* @param node a <code>String</code> value
* @param jid a <code>String</code> value
* @return an <code>Element</code> value
*/
public Element getDiscoItem(String node, String jid) {
Element item = new Element("item");
if (jid != null) {
item.setAttribute("jid", jid);
} else {
if (this.jid != null) {
item.setAttribute("jid", this.jid);
}
}
if (node != null) {
item.setAttribute("node", node + ((this.node != null)
? "/" + this.node
: ""));
} else {
if (this.node != null) {
item.setAttribute("node", this.node);
}
}
if (name != null) {
item.setAttribute("name", name);
}
return item;
}
示例6: run
import tigase.xml.Element; //导入依赖的package包/类
@Override
protected void run() {
if (log.isLoggable(Level.FINEST))
log.finest("Running task...");
ConfiguratorAbstract configurator = XMPPServer.getConfigurator();
SessionManager sess = (SessionManager) configurator.getComponent("sess-man");
final int currentOnlineUsers = sess.getOpenUsersConnectionsAmount();
Element event = createAlarmEvent(currentOnlineUsers, lastOnlineUsers, thresholdMinimal, threshold);
if (event != null) {
event.addChild(new Element("hostname", component.getDefHostName().toString()));
eventBus.fire(event);
}
this.lastOnlineUsers = currentOnlineUsers;
}
示例7: run
import tigase.xml.Element; //导入依赖的package包/类
@Override
protected void run() {
checkCPUTemperature();
// checkCPUFrequency();
// checkCPUThrottling();
if (cpu_temp >= cpuTempThreshold) {
Element event = new Element(CPU_TEMP_MONITOR_EVENT_NAME, new String[] { "xmlns" },
new String[] { MonitorComponent.EVENTS_XMLNS });
event.addChild(new Element("hostname", component.getDefHostName().toString()));
event.addChild(new Element("timestamp", "" + dtf.formatDateTime(new Date())));
event.addChild(new Element("cpuTemp", "" + cpu_temp));
if (!triggeredEvents.contains(event.getName())) {
eventBus.fire(event);
triggeredEvents.add(event.getName());
}
} else {
triggeredEvents.remove(CPU_TEMP_MONITOR_EVENT_NAME);
}
}
示例8: toElement
import tigase.xml.Element; //导入依赖的package包/类
/**
* Allows retrieving of component's information as Element
*
* @return component information as Element
*/
public Element toElement() {
Element cmpInfo = new Element( "cmpInfo" );
if ( name != null ){
cmpInfo.addChild(new Element( "name", name ) );
}
if ( !title.isEmpty() ){
cmpInfo.addChild( new Element( "title", title ) );
}
if ( !version.isEmpty() ){
cmpInfo.addChild( new Element( "version", version ) );
}
if ( !cls.isEmpty() ){
cmpInfo.addChild( new Element( "class", cls ) );
}
if ( !cmpData.isEmpty() ){
Element data = new Element( "cmpData" );
for ( String key : cmpData.keySet() ) {
data.addChild( new Element( key, cmpData.get( key ).toString() ) );
}
cmpInfo.addChild( data );
}
return cmpInfo;
}
示例9: processSetUnblock
import tigase.xml.Element; //导入依赖的package包/类
private void processSetUnblock(Packet packet, Element e, XMPPResourceConnection session, Queue<Packet> results) throws NotAuthorizedException, TigaseDBException {
List<JID> jids = collectJids(e);
if (jids == null || jids.isEmpty()) {
List<String> jidsStr = Privacy.getBlocked(session);
if (jidsStr != null) {
jids = new ArrayList<>(jidsStr.size());
for (String jidStr : jidsStr) {
jids.add(JID.jidInstanceNS(jidStr));
}
}
}
if (jids != null) {
for (JID jid : jids) {
Privacy.unblock(session, jid.toString());
sendUnblockPresences(session, jid, results);
}
}
results.offer(packet.okResult((Element) null, 0));
sendPush(session.getParentSession(), packet, results);
}
示例10: filter
import tigase.xml.Element; //导入依赖的package包/类
/**
* Filters packets created by processors to remove delivery-error payload
*
* @param packet
* @param session
* @param repo
* @param results
* @param toIgnore
*/
public static void filter(Packet packet, XMPPResourceConnection session, NonAuthUserRepository repo, Queue<Packet> results, JID toIgnore) {
for (Packet p : results) {
if (p.getElemName() != tigase.server.Message.ELEM_NAME)
continue;
Element elem = p.getElement();
Element error = elem.getChildStaticStr(ELEM_NAME);
if (error != null && error.getXMLNS() == XMLNS) {
// We are removing delivery-error payload for outgoing messages
// to other components than with jid toIgnore
if (toIgnore == null || !toIgnore.equals(packet.getPacketTo())) {
elem.removeChild(error);
}
}
}
}
示例11: createClusterMethodCall
import tigase.xml.Element; //导入依赖的package包/类
/**
* Method description
*
*
* @param from
* @param to
* @param type
* @param method_name
* @param params
*
*
*/
public static ClusterElement createClusterMethodCall(JID from, JID to, StanzaType type,
String method_name, Map<String, String> params) {
Element cluster_el = clusterElement(from, to, type);
Element method_call = new Element(CLUSTER_METHOD_EL_NAME,
new String[] { CLUSTER_NAME_ATTR },
new String[] { method_name });
if (params != null) {
for (Map.Entry<String, String> entry : params.entrySet()) {
method_call.addChild(new Element(CLUSTER_METHOD_PAR_EL_NAME, entry.getValue(),
new String[] { CLUSTER_NAME_ATTR },
new String[] { entry.getKey() }));
}
}
cluster_el.findChildStaticStr(CLUSTER_CONTROL_PATH).addChild(method_call);
ClusterElement result_cl = new ClusterElement(cluster_el);
result_cl.addVisitedNode(from);
return result_cl;
}
示例12: processDiscoInfo
import tigase.xml.Element; //导入依赖的package包/类
@Override
protected void processDiscoInfo(Packet packet, JID jid, String node, JID senderJID) throws ComponentException,
RepositoryException {
if (jid.getResource() == null) {
super.processDiscoInfo(packet, jid, node, senderJID);
} else if (jid.getResource() != null && context.getKernel().getInstance(jid.getResource()) != null) {
final Object taskInstance = context.getKernel().getInstance(jid.getResource());
Element resultQuery = new Element("query", new String[] { "xmlns" }, new String[] { DISCO_INFO_XMLNS });
Packet resultIq = packet.okResult(resultQuery, 0);
resultQuery.addChild(new Element("identity", new String[] { "category", "type", "name" }, new String[] {
"automation", "task", "Task " + jid.getResource() }));
if (isAdHocCompatible(taskInstance)) {
resultQuery.addChild(new Element("feature", new String[] { "var" }, new String[] { Command.XMLNS }));
}
write(resultIq);
} else
throw new ComponentException(Authorization.ITEM_NOT_FOUND);
}
示例13: process
import tigase.xml.Element; //导入依赖的package包/类
/**
* Method description
*
*
* @param packet
*
* @return
*
* @throws AdHocCommandException
*/
public Packet process(Packet packet) throws AdHocCommandException {
final Element element = packet.getElement();
final JID senderJid = packet.getStanzaFrom();
final Element command = element.getChild("command", "http://jabber.org/protocol/commands");
final String node = command.getAttributeStaticStr("node");
final String action = command.getAttributeStaticStr("action");
final String sessionId = command.getAttributeStaticStr("sessionid");
AdHocCommand adHocCommand = getCommand(node);
if (adHocCommand == null) {
} else {
return process(packet, command, node, action, sessionId, adHocCommand);
}
return null;
}
示例14: getDiscoItems
import tigase.xml.Element; //导入依赖的package包/类
@Override
public List<Element> getDiscoItems(String node, JID jid, JID from) {
if (isAdmin(from)) {
if (getName().equals(jid.getLocalpart())) {
return serviceEntity.getDiscoItems(node, jid.toString());
} else {
if (node == null) {
return Arrays.asList(serviceEntity.getDiscoItem(null, BareJID.toString(
getName(), jid.toString())));
} else {
return null;
}
}
}
return null;
}
示例15: 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;
}