本文整理汇总了Java中tigase.xml.Element类的典型用法代码示例。如果您正苦于以下问题:Java Element类的具体用法?Java Element怎么用?Java Element使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Element类属于tigase.xml包,在下文中一共展示了Element类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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();
}
}
}
开发者ID:QuickBlox,项目名称:QuickBlox-Tigase-CustomFeatures,代码行数:20,代码来源:QBChatUtils.java
示例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) {
}
}
开发者ID:QuickBlox,项目名称:QuickBlox-Tigase-CustomFeatures,代码行数:17,代码来源:ProcessChatStateNotification.java
示例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);
}
}
开发者ID:QuickBlox,项目名称:QuickBlox-Tigase-CustomFeatures,代码行数:22,代码来源:ChatStatisticsPerUnit.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:33,代码来源:ServiceEntity.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:19,代码来源:ConnectionsTask.java
示例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);
}
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:23,代码来源:CpuTempTask.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:29,代码来源:ComponentInfo.java
示例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);
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:22,代码来源:BlockingCommand.java
示例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);
}
}
}
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:26,代码来源:C2SDeliveryErrorProcessor.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:35,代码来源:ClusterElement.java
示例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);
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:24,代码来源:DiscoveryMonitorModule.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:27,代码来源:AdHocCommandManager.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:18,代码来源:ConfiguratorOld.java
示例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;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:19,代码来源:BoshSession.java
示例16: testList
import tigase.xml.Element; //导入依赖的package包/类
private void testList(XMPPResourceConnection session, String listJID, String testJID, boolean shouldBeAllowed)
throws TigaseStringprepException, NotAuthorizedException {
JID jid = JID.jidInstance("[email protected]/res-1");
JID blockedJID = JID.jidInstance(listJID);
Element list = new Element("list", new String[]{"name"}, new String[]{"default"});
list.addChild(new Element("item", new String[]{"type", "value", "action", "order"},
new String[]{"jid", blockedJID.toString(), "deny", "100"}));
list.addChild(new Element("item", new String[]{"action", "order"},
new String[]{"allow", "110"}));
session.putSessionData("active-list", list);
Packet presence = Packet.packetInstance(new Element("presence",
new String[]{"from", "to"},
new String[]{testJID, jid.toString()}));
boolean isAllowed = privacyFilter.allowed(presence, session);
System.out.println("Privacy item: " + listJID + ", tested item: " + testJID + ", result: " + isAllowed);
if (shouldBeAllowed) {
assertTrue(isAllowed);
} else {
assertFalse(isAllowed);
}
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:27,代码来源:JabberIqPrivacyTest.java
示例17: testValidateListOrderAttributeDuplicate
import tigase.xml.Element; //导入依赖的package包/类
@Test
public void testValidateListOrderAttributeDuplicate() {
List<Element> items = new ArrayList<Element>();
Authorization result = null;
items.add(new Element("item", new String[] { "type", "value", "action", "order" },
new String[] { "subscription", "both", "allow", "10" }));
items.add(new Element("item", new String[] { "action", "order" },
new String[] { "deny", "10" }));
// session is allowed to be null here
result = JabberIqPrivacy.validateList(null, items);
assertEquals(Authorization.BAD_REQUEST, result);
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:17,代码来源:JabberIqPrivacyTest.java
示例18: getRosterElement
import tigase.xml.Element; //导入依赖的package包/类
public Element getRosterElement() {
Element elem = new Element(ELEM_NAME, new String[] { JID_ATT, SUBS_ATT, STRINGPREP_ATT },
new String[] { jid.toString(), subscription.toString(), "" + stringpreped });
if (name != null)
elem.setAttribute(NAME_ATT, XMLUtils.escape(name));
if ((groups != null) && (groups.length > 0)) {
String grps = "";
for (String group : groups) {
grps += XMLUtils.escape(group) + ",";
}
grps = grps.substring(0, grps.length() - 1);
elem.setAttribute(GRP_ATT, grps);
}
if (otherData != null) {
elem.setAttribute(OTHER_ATT, otherData);
}
elem.setAttribute(ACTIVITY_ATT, Double.toString(activity));
elem.setAttribute(WEIGHT_ATT, Double.toString(weight));
elem.setAttribute(LAST_SEEN_ATT, Long.toString(lastSeen));
modified = false;
return elem;
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:27,代码来源:RosterElement.java
示例19: testSilentlyIgnoringMessages
import tigase.xml.Element; //导入依赖的package包/类
@Test
public void testSilentlyIgnoringMessages() throws Exception {
BareJID userJid = BareJID.bareJIDInstance("[email protected]");
JID res1 = JID.jidInstance(userJid, "res1");
// testing default behaviour - error message
Element packetEl = new Element("message", new String[] { "from", "to" },
new String[] { "[email protected]/res1", res1.toString() });
Packet packet = Packet.packetInstance(packetEl);
Queue<Packet> results = new ArrayDeque<Packet>();
messageProcessor.process(packet, null, null, results, null);
assertTrue("no error was generated", !results.isEmpty());
assertTrue("generated result is not an error", results.poll().getType().equals( StanzaType.error));
// testing silently ignoring error responses
results.clear();
final HashMap<String, Object> settings = new HashMap<String,Object>();
settings.put( "silently-ignore-message", "true");
messageProcessor.init(settings);
messageProcessor.process(packet, null, null, results, null);
assertTrue("result was generated", results.isEmpty());
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:25,代码来源:MessageTest.java
示例20: addFieldMultiValue
import tigase.xml.Element; //导入依赖的package包/类
public static void addFieldMultiValue( final Element el, final String f_name,
final List<String> f_value ) {
Element x = el.getChild( "x", "jabber:x:data" );
if ( x == null ){
x = addDataForm( el, DataType.result );
}
if ( f_value != null ){
Element field = new Element( FIELD_EL, new String[] { "var", "type" },
new String[] { XMLUtils.escape( f_name ),
"text-multi" } );
for ( String val : f_value ) {
if ( val != null ){
Element value = new Element( VALUE_EL, XMLUtils.escape( val ) );
field.addChild( value );
}
}
x.addChild( field );
}
}
开发者ID:kontalk,项目名称:tigase-server,代码行数:23,代码来源:DataForm.java
注:本文中的tigase.xml.Element类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论