本文整理汇总了Java中tigase.xml.Element.getChildren方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getChildren方法的具体用法?Java Element.getChildren怎么用?Java Element.getChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类tigase.xml.Element
的用法示例。
在下文中一共展示了Element.getChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getExpireAtRule
import tigase.xml.Element; //导入方法依赖的package包/类
private Element getExpireAtRule(Packet packet) {
Element amp = packet.getElement().getChild("amp", AMP_XMLNS);
List<Element> rules = amp.getChildren();
Element rule = null;
if ((rules != null) && (rules.size() > 0)) {
for (Element r : rules) {
String cond = r.getAttributeStaticStr(CONDITION_ATT);
if ((cond != null) && cond.equals(ExpireAt.NAME)) {
rule = r;
break;
}
}
}
return rule;
}
示例2: removeExpireAtRule
import tigase.xml.Element; //导入方法依赖的package包/类
private void removeExpireAtRule(Packet packet) {
Element amp = packet.getElement().getChild("amp", AMP_XMLNS);
List<Element> rules = amp.getChildren();
if ((rules != null) && (rules.size() > 0)) {
for (Element r : rules) {
String cond = r.getAttributeStaticStr(CONDITION_ATT);
if ((cond != null) && cond.equals(ExpireAt.NAME)) {
amp.removeChild(r);
break;
}
}
}
rules = amp.getChildren();
if ((rules == null) || (rules.size() == 0)) {
packet.getElement().removeChild(amp);
}
}
示例3: getFieldValue
import tigase.xml.Element; //导入方法依赖的package包/类
public static String getFieldValue( final Element el, 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 ) ){
String value = child.getChildCDataStaticStr( FIELD_VALUE_PATH );
if ( value != null ){
return XMLUtils.unescape( value );
}
}
}
}
}
return null;
}
示例4: removeFieldValue
import tigase.xml.Element; //导入方法依赖的package包/类
public static boolean removeFieldValue( 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 ) ){
return x.removeChild( child );
}
}
}
}
return false;
}
示例5: getFieldKeyStartingWith
import tigase.xml.Element; //导入方法依赖的package包/类
public static String getFieldKeyStartingWith( final Element el, 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" ).startsWith( f_name ) ){
return child.getAttributeStaticStr( "var" );
}
}
}
}
return null;
}
示例6: block
import tigase.xml.Element; //导入方法依赖的package包/类
public static boolean block(XMPPResourceConnection session, String jid) throws NotAuthorizedException, TigaseDBException {
String name = getDefaultListName(session);
if(name == null) {
name = "default";
}
Element list = getList(session,name);
if(list != null) {
if (list.findChild(item -> jid.equals(item.getAttributeStaticStr(VALUE)) && isBlockItem(item)) != null)
return false;
}
Element list_new = new Element(LIST,new String[]{NAME},new String[]{name});
list_new.addChild(new Element(ITEM,new String[]{TYPE,ACTION,VALUE,ORDER},new String[]{"jid","deny",jid,"0"}));
if (list != null) {
List<Element> items = list.getChildren();
if (items != null) {
Collections.sort(items, JabberIqPrivacy.compar);
for (int i = 0; i < items.size(); i++) {
items.get(i).setAttribute(ORDER, "" + (i + 1));
}
list_new.addChildren(items);
}
}
updateList(session, name, list_new);
return true;
}
示例7: 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;
}
示例8: walk
import tigase.xml.Element; //导入方法依赖的package包/类
private boolean walk(Element elem) {
boolean result;
String xmlns = elem.getXMLNS();
if (xmlns == null) {
xmlns = "jabber:client";
}
result = isSupporting(elem.getName(), xmlns);
if (!result) {
Collection<Element> children = elem.getChildren();
if (children != null) {
for (Element child : children) {
result = walk(child);
} // end of for (Element child: children)
} // end of if (children != null)
}
return result;
}
示例9: escapeElementBodyAndExtraParams
import tigase.xml.Element; //导入方法依赖的package包/类
public static void escapeElementBodyAndExtraParams(Element element){
// element is an instance of packet's element with 'body' and 'extraParams' children
Element bodyChild = element.getChild("body");
escapeElement(bodyChild);
//
Element extraParamsChild = element.getChild("extraParams");
if(extraParamsChild != null && extraParamsChild.getChildren() != null){
for(Element extraParam : extraParamsChild.getChildren()){
escapeElement(extraParam);
}
}
}
示例10: 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;
}
示例11: 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());
}
}
}
}
}
}
}
示例12: storeVCard
import tigase.xml.Element; //导入方法依赖的package包/类
@Override
protected void storeVCard(XMPPResourceConnection session, Element elvCard) throws TigaseDBException, NotAuthorizedException {
if (elvCard != null && elvCard.getChildren() != null) {
if (log.isLoggable(Level.FINER)) {
log.finer("Adding vCard: " + elvCard);
}
session.setPublicData(ID, VCARD_KEY, elvCard.toString());
} else {
if (log.isLoggable(Level.FINER)) {
log.finer("Removing vCard");
}
session.removePublicData(ID, VCARD_KEY);
} // end of else
}
示例13: processPacket
import tigase.xml.Element; //导入方法依赖的package包/类
@Override
public void processPacket(Packet packet) {
packet.processedBy(getName());
Element child = packet.getElement().getChild(ELEM_NAME, XMLNS);
if (child != null) {
List<Element> addresses = child.getChildren();
if (addresses != null && addresses.size() > 0) {
addresses.stream().filter(address -> address.getName() == CHILD_ELEM_NAME).forEach(address -> {
// TODO only "to" is supported for now
String type = address.getAttributeStaticStr("type");
if ("to".equals(type)) {
String jid = address.getAttributeStaticStr("jid");
if (jid != null) {
try {
JID to = JID.jidInstance(jid);
Packet fwd = packet.copyElementOnly();
fwd.initVars(packet.getStanzaFrom(), to);
stripAddresses(fwd);
addOutPacket(fwd);
}
catch (TigaseStringprepException e) {
log.log(Level.WARNING, "invalid JID: " + jid);
// TODO how to handle errors?
}
}
}
});
}
}
}
示例14: handleBlockRequest
import tigase.xml.Element; //导入方法依赖的package包/类
private void handleBlockRequest(Packet packet, XMPPResourceConnection session, Element block, Queue<Packet> results)
throws NotAuthorizedException, TigaseDBException, TigaseStringprepException {
int count = 0;
List<Element> items = block.getChildren();
Set<BareJID> list = null;
if (items != null) {
list = getBlocklist(session);
for (Element item : items) {
if ("item".equalsIgnoreCase(item.getName())) {
String jidString = item.getAttributeStaticStr("jid");
BareJID jid;
if (jidString != null) {
// if jid is not valid it will throw exception
try {
jid = BareJID.bareJIDInstance(jidString);
}
catch (TigaseStringprepException e) {
// invalid jid
throw new IllegalArgumentException("invalid jid: " + jidString);
}
count++;
list = addItem(list, jid);
}
}
}
}
packet.processedBy(ID);
if (count > 0 && list != null) {
setBlocklist(session, list);
results.offer(packet.okResult((Element) null, 0));
}
else {
// bad request
throw new IllegalArgumentException();
}
}
示例15: getBlocklist
import tigase.xml.Element; //导入方法依赖的package包/类
/** Loads the user's block list. */
private Set<BareJID> getBlocklist(XMPPResourceConnection session)
throws NotAuthorizedException, TigaseDBException {
@SuppressWarnings("unchecked")
Set<BareJID> list = (Set<BareJID>) session.getCommonSessionData(BLOCKLIST);
if (list == null) {
String list_str = session.getData(BLOCKLIST, BLOCKLIST, null);
if ((list_str != null) && !list_str.isEmpty()) {
SimpleParser parser = SingletonFactory.getParserInstance();
DomBuilderHandler domHandler = new DomBuilderHandler();
parser.parse(domHandler, list_str.toCharArray(), 0, list_str.length());
Queue<Element> elems = domHandler.getParsedElements();
Element result = elems.poll();
if (log.isLoggable(Level.FINEST)) {
log.log(Level.FINEST, "Loaded block list: {0}", result);
}
List<Element> children = result.getChildren();
if (children != null) {
list = new HashSet<>(children.size());
for (Element item : children) {
list.add(BareJID.bareJIDInstanceNS(item.getAttributeStaticStr("jid")));
}
}
}
}
return list;
}