本文整理汇总了Java中tigase.xml.Element.getCData方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getCData方法的具体用法?Java Element.getCData怎么用?Java Element.getCData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tigase.xml.Element
的用法示例。
在下文中一共展示了Element.getCData方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: isAllowedForOfflineStorage
import tigase.xml.Element; //导入方法依赖的package包/类
/**
* Saves only:
* <ul>
* <li>message stanza with either {@code <body>} or {@code <event>} child element and only of type normal, chat and doesn't save chat state notifications with an empty body</li>
* <li>presence stanza of type subscribe, subscribed, unsubscribe and unsubscribed</li>
* </ul>
*
* @param pac packet to check
* @return true, if allowed; false - otherwise.
*/
protected boolean isAllowedForOfflineStorage(Packet pac) {
StanzaType type = pac.getType();
switch (pac.getElemName()) {
case "message":
if ((type == null) || (type == StanzaType.normal) || (type == StanzaType.chat)) {
//check for chat state notifications
if (MESSAGE_CHAT_STATE_XMLNS.equals(pac.getAttributeStaticStr(MESSAGE_ACTIVE, "xmlns")) || MESSAGE_CHAT_STATE_XMLNS.equals(pac.getAttributeStaticStr(MESSAGE_INACTIVE, "xmlns"))
|| MESSAGE_CHAT_STATE_XMLNS.equals(pac.getAttributeStaticStr(MESSAGE_GONE, "xmlns")) || MESSAGE_CHAT_STATE_XMLNS.equals(pac.getAttributeStaticStr(MESSAGE_COMPOSING, "xmlns"))
|| MESSAGE_CHAT_STATE_XMLNS.equals(pac.getAttributeStaticStr(MESSAGE_PAUSED, "xmlns"))) {
//check body
Element bodyElem = pac.getElement().getChild("body");
if (bodyElem == null || bodyElem.getCData() == null) {
return false;
}
}
return true;
}
return false;
case "presence":
if ((type == StanzaType.subscribe) || (type == StanzaType.subscribed)
|| (type == StanzaType.unsubscribe) || (type == StanzaType.unsubscribed)) {
return true;
}
break;
default:
break;
}
return false;
}
示例3: getFieldValues
import tigase.xml.Element; //导入方法依赖的package包/类
public static String[] getFieldValues( final Element el, final String f_name ) {
Element x = el.getChild( "x", "jabber:x:data" );
if ( x != null ){
List<Element> children = x.getChildren();
if ( children != null ){
for ( Element child : children ) {
if ( child.getName().equals( FIELD_EL )
&& child.getAttributeStaticStr( "var" ).equals( f_name ) ){
List<String> values = new LinkedList<String>();
List<Element> val_children = child.getChildren();
if ( val_children != null ){
for ( Element val_child : val_children ) {
if ( val_child.getName().equals( VALUE_EL ) ){
String value = val_child.getCData();
if ( value != null ){
values.add( XMLUtils.unescape( value ) );
}
}
}
}
return values.toArray( new String[ 0 ] );
}
}
}
}
return null;
}
示例4: onEvent
import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void onEvent(String name, String xmlns, Element event) {
String n = event.getCData(NAME_PATH);
String x = event.getCData(XMLNS_PATH);
if (x == null || !x.equals(LocalEventBus.EVENTBUS_INTERNAL_EVENTS_XMLNS))
UnsubscribeModule.this.onRemoveHandler(n, x);
}
示例5: onEvent
import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void onEvent(String name, String xmlns, Element event) {
String n = event.getCData(NAME_PATH);
String x = event.getCData(XMLNS_PATH);
if (x == null || !x.equals(LocalEventBus.EVENTBUS_INTERNAL_EVENTS_XMLNS))
SubscribeModule.this.onAddHandler(n, x);
}
示例6: processClusterSubscription
import tigase.xml.Element; //导入方法依赖的package包/类
protected Element processClusterSubscription(final Packet packet) throws TigaseStringprepException {
// subscription from cluster node
log.finest("Processing cluster subscription request from " + packet.getStanzaFrom());
List<Element> subscribeElements = packet.getElemChildrenStaticStr(new String[] { "iq", "pubsub" });
for (Element subscribe : subscribeElements) {
Element serviceItem = subscribe.getChild("service");
final EventName parsedName = NodeNameUtil.parseNodeName(subscribe.getAttributeStaticStr("node"));
final JID jid = JID.jidInstance(subscribe.getAttributeStaticStr("jid"));
final String service;
if (serviceItem != null && serviceItem.getCData() != null) {
service = serviceItem.getCData();
} else {
service = null;
}
if (log.isLoggable(Level.FINE))
log.fine("Node " + jid + " subscribed for events " + parsedName);
Subscription subscription = new Subscription(jid);
subscription.setInClusterSubscription(true);
subscription.setServiceJID(JID.jidInstanceNS(service));
context.getSubscriptionStore().addSubscription(parsedName.getName(), parsedName.getXmlns(), subscription);
}
return null;
}
示例7: onEvent
import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void onEvent( String name, String xmlns, Element event ) {
if ( !( presenceSessionEventName.equals( name ) && EVENTBUS_PRESENCE_SESSION_XMLNS.equals( xmlns ) ) ){
return;
}
List<Element> jidElements = event.getChildrenStaticStr( JID_PATH );
if ( log.isLoggable( Level.FINEST ) ){
log.log( Level.FINEST, "Procesing userPresence event: {0} with following jids: {1}", new Object[] { event, jidElements } );
}
if ( jidElements != null && !jidElements.isEmpty() ){
for ( Element jidElement : jidElements ) {
String jidStr = jidElement != null ? jidElement.getCData() : null;
if ( jidStr != null && jidElement != null ){
BareJID jid = BareJID.bareJIDInstanceNS( jidStr );
String actionStr = jidElement.getAttributeStaticStr( "action" );
if ( actionStr != null ){
switch ( actionStr ) {
case "presence":
presenceCache.remove( jid );
if ( log.isLoggable( Level.FINEST ) ){
log.log( Level.FINEST, "Clearing presence cache: {0}, remaining items: {1}",
new Object[] { jidStr, presenceCache.size() } );
}
break;
case "roster":
rosterCache.remove( jid );
if ( log.isLoggable( Level.FINEST ) ){
log.log( Level.FINEST, "Clearing roster cache: {0}, remaining items: {1}",
new Object[] { jidStr, rosterCache.size() } );
}
break;
}
}
}
}
}
}