List of usage examples for org.dom4j Element elements
List<Element> elements();
From source file:cc.warlock.core.script.configuration.ScriptConfiguration.java
License:Open Source License
public void parseScriptConfig(Element scriptConfig) { // clear();//from w ww . j a va 2 s. c o m for (Element element : (List<Element>) scriptConfig.elements()) { if ("dir".equals(element.getName())) { scriptDirectories.add(new File(element.getTextTrim())); } else if ("autoScan".equals(element.getName())) { scanTimeout.set(Long.parseLong(element.attributeValue("timeout"))); autoScan.set(Boolean.parseBoolean(element.getTextTrim())); } else if ("suppressExceptions".equals(element.getName())) { suppressExceptions.set(Boolean.parseBoolean(element.getTextTrim())); } else if ("script-prefix".equals(element.getName())) { scriptPrefix = element.getTextTrim(); } else if ("engine-file-extensions".equals(element.getName())) { for (Element extElement : (List<Element>) element.elements()) { addEngineExtension(element.attributeValue("engineId"), extElement.getTextTrim()); } } } }
From source file:cc.warlock.core.stormfront.ProfileConfiguration.java
License:Open Source License
public void parseElement(Element element) { if (element.getName().equals("account")) { String accountName = element.attributeValue("name"); String password = element.attributeValue("password"); Account account = new Account(accountName, Account.decryptPassword(password)); accounts.put(accountName, account); for (Element pElement : (List<Element>) element.elements()) { String profileId = pElement.attributeValue("id"); String profileName = pElement.attributeValue("name"); String gameCode = pElement.attributeValue("gameCode"); String gameName = pElement.attributeValue("gameName"); Profile profile = new Profile(); profile.setAccount(account); profile.setId(profileId);//from ww w .ja va 2 s . c o m profile.setName(profileName); profile.setGameCode(gameCode); profile.setGameName(gameName); account.getProfiles().add(profile); } } }
From source file:cc.warlock.rcp.configuration.GameViewConfiguration.java
License:Open Source License
public void parseElement(Element element) { if (element.getName().equals("game-view")) { bufferLines = Integer.parseInt(element.attributeValue("buffer")); suppressPrompt = Boolean.parseBoolean(element.attributeValue("suppressPrompt")); for (Element e : (List<Element>) element.elements()) { if (e.getName().equals("default-colors")) { defaultBackground = new WarlockColor(e.attributeValue("background")); defaultForeground = new WarlockColor(e.attributeValue("foreground")); defaultEchoBackground = new WarlockColor(e.attributeValue("echo-background")); defaultEchoForeground = new WarlockColor(e.attributeValue("echo-foreground")); } else if (e.getName().equals("default-font")) { defaultFontFace = e.attributeValue("face"); defaultFontSize = Integer.parseInt(e.attributeValue("size")); }//from w ww .j a va2 s .c o m } } }
From source file:ch.javasoft.xml.config.XmlConfig.java
License:BSD License
@SuppressWarnings("unchecked") protected List<Element> getReferredElementContent(String name, String path) throws XmlConfigException, MissingReferableException { Iterator<Element> it = getRootElement().elementIterator(XmlElement.referable.getXmlName()); while (it.hasNext()) { Element ref = it.next(); String refName = ref.attributeValue(XmlAttribute.name.getXmlName()); if (name.equals(refName)) { return ref.elements(); }//from w ww . j a va2 s .co m } throw new MissingReferableException(name, "cannot find referred element '" + name + "'", path); }
From source file:client.ManageNets.java
License:Open Source License
@SuppressWarnings("unchecked") private void parseDoc() { //seznam uzivatelu List<Element> u = serverroot.elements(); //seznam siti List<Element> n; //seznam verzi List<Element> v; //n.size();//from www . ja va 2s . c om names = new String[u.size()]; nets = new String[u.size()][]; versions = new String[u.size()][][]; descriptions = new String[u.size()][][]; int i = 0; int j = 0; int k = 0; for (Element e : u) { names[i] = e.attribute("login").getValue(); n = e.elements(); nets[i] = new String[n.size()]; versions[i] = new String[n.size()][]; descriptions[i] = new String[n.size()][]; j = 0; for (Element f : n) { nets[i][j] = f.attribute("name").getText(); v = f.elements(); versions[i][j] = new String[v.size()]; descriptions[i][j] = new String[v.size()]; //s verzema jdu odzadu aby byly nejnovejsi nejdrive k = v.size() - 1; for (Element g : v) { versions[i][j][k] = convVerToPrint(g.attribute("time").getText()); descriptions[i][j][k] = g.attribute("description").getText(); k--; } j++; } i++; } }
From source file:cms.service.template.TemplateXml.java
private void parseRecord(Element record) { List<Element> fileds = record.elements(); dbobject = doc.getRootElement().getName(); fields = new String[fileds.size()]; datatype = new String[fileds.size()]; value = new String[fileds.size()]; index = new int[fileds.size()]; //set query// www . j ava2s . c o m insertquery = "\tinsert into table_" + dbobject + "( " + (isparent ? "" : relfield + ","); insertvalue = ")values(" + (isparent ? "" : "'0',"); updatequery = "\tupdate table_" + dbobject + " set "; colcount = 0; for (Element field : fileds) { String elmXml = field.asXML(); String fname = field.getName(); String fvalue = field.getText(); fields[colcount] = field.getName(); datatype[colcount] = field.attributeValue("type"); index[colcount] = colcount; setValue(fvalue, field.getName(), field.attributeValue("type"), field.attributeValue("isRequired")); } makeSql(); }
From source file:cms.service.util.ItemUtility.java
License:Open Source License
public HashMap<String, String> getItemValueMap(String xml) { List<Element> itemlist; List<Element> items; HashMap<String, String> varmap = new HashMap<String, String>(); Element root = this.getRootElementFromXML(xml); if (root != null) { items = root.elements(); if (items.size() == 1 && items.get(0).hasContent()) { itemlist = items.get(0).elements(); } else {/*from w w w .j a v a 2 s . co m*/ itemlist = items; } for (Element var : itemlist) { String name = var.getName(); String value = var.getText(); varmap.put(name, value); } } return varmap; }
From source file:cn.myloveqian.utils.XmlUtils.java
License:Open Source License
/** * @param elements/*from w w w .j a va 2 s . c om*/ * @return * @throws DocumentException */ public static List<Map<String, String>> getEachElement(List elements) throws DocumentException { List<Map<String, String>> resultList = new ArrayList<>(); if (elements.size() > 0) { for (Iterator it = elements.iterator(); it.hasNext();) { Map<String, String> resultMap = new HashMap<>(); Element subElement = (Element) it.next(); List subElements = subElement.elements(); for (Iterator subIt = subElements.iterator(); subIt.hasNext();) { Element son = (Element) subIt.next(); String name = son.getName(); String text = son.getText(); resultMap.put(name, text); } resultList.add(resultMap); } } else { throw new DocumentException("this element is disappeared"); } return resultList; }
From source file:com.adspore.splat.xep0060.LeafNode.java
License:Open Source License
/** * Publishes the list of items to the node. Event notifications will be sent to subscribers * for the new published event. The published event may or may not include an item. When the * node is not persistent and does not require payloads then an item is not going to be created * nore included in the event notification.<p> * * When an affiliate has many subscriptions to the node, the affiliate will get a * notification for each set of items that affected the same list of subscriptions.<p> * * When an item is included in the published event then a new {@link PublishedItem} is * going to be created and added to the list of published item. Each published item will * have a unique ID in the node scope. The new published item will be added to the end * of the published list to keep the cronological order. When the max number of published * items is exceeded then the oldest published items will be removed.<p> * * For performance reasons the newly added published items and the deleted items (if any) * are saved to the database using a background thread. Sending event notifications to * node subscribers may also use another thread to ensure good performance.<p> * * @param publisher the full JID of the user that sent the new published event. * @param itemElements list of dom4j elements that contain info about the published items. *///from ww w. j a va2s . c om public void publishItems(JID publisher, List<Element> itemElements) { List<PublishedItem> newPublishedItems = new ArrayList<PublishedItem>(); if (isItemRequired()) { String itemID; Element payload; PublishedItem newItem; for (Element item : itemElements) { itemID = item.attributeValue("id"); List entries = item.elements(); payload = entries.isEmpty() ? null : (Element) entries.get(0); // Make sure that the published item has a unique ID if NOT assigned by publisher if (itemID == null) { itemID = genIdSeed + sequenceCounter.getAndIncrement(); } // Create a new published item newItem = new PublishedItem(this, publisher, itemID, new Date(mService.mContext.getContextTime())); newItem.setPayload(payload); // Add the new item to the list of published items newPublishedItems.add(newItem); setLastPublishedItem(newItem); } } // Build event notification packet to broadcast to subscribers Message message = new Message(); Element event = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event"); // Broadcast event notification to subscribers and parent node subscribers Set<NodeAffiliate> affiliatesToNotify = new HashSet<NodeAffiliate>(affiliates); // Get affiliates that are subscribed to a parent in the hierarchy of parent nodes for (CollectionNode parentNode : getParents()) { for (NodeSubscription subscription : parentNode.getSubscriptions()) { affiliatesToNotify.add(subscription.getAffiliate()); } } mService.submitTask( new NotifyAffiliatesCallable(affiliatesToNotify, message, event, this, newPublishedItems)); }
From source file:com.adspore.splat.xep0060.LeafNode.java
License:Open Source License
/** * Publishes an item or retracts an item based on the caller provided criteria. Provides a means * of controlling PublishedItem visibility on a user by user basis outside of the subscription * scheme.// w ww.j a v a 2s .c om * @param publisher JID of the entity responsible for the publishing/retracting/ignoring operation * @param publishCriteria Caller supplied test that will be applied to each subscriber * @param itemElements List of 'item' elements which are to be published. */ public void publishOrRetractByCriteria(JID publisher, IPublishCriteria publishCriteria, List<Element> itemElements) { List<PublishedItem> newPublishedItems = new ArrayList<PublishedItem>(); if (isItemRequired()) { String itemID; Element payload; PublishedItem newItem; for (Element item : itemElements) { itemID = item.attributeValue("id"); List entries = item.elements(); payload = entries.isEmpty() ? null : (Element) entries.get(0); // Make sure that the published item has a unique ID if NOT assigned by publisher if (itemID == null) { itemID = genIdSeed + sequenceCounter.getAndIncrement(); } // Create a new published item newItem = new PublishedItem(this, publisher, itemID, new Date(mService.mContext.getContextTime())); newItem.setPayload(payload); // Add the new item to the list of published items newPublishedItems.add(newItem); setLastPublishedItem(newItem); } } // Build both event notification packets to broadcast to subscribers Message message = new Message(); Element event = message.addChildElement("event", "http://jabber.org/protocol/pubsub#event"); Set<NodeAffiliate> affiliatesToNotify = new HashSet<NodeAffiliate>(affiliates); for (CollectionNode parentNode : getParents()) { for (NodeSubscription subscription : parentNode.getSubscriptions()) { affiliatesToNotify.add(subscription.getAffiliate()); } } for (NodeAffiliate affiliate : affiliatesToNotify) { ItemPublishOperation operation = publishCriteria.getOperationForAffiliate(this, affiliate, newPublishedItems); switch (operation) { case publish: if (isPayloadDelivered()) { affiliate.sendPublishedNotifications(message, event, this, newPublishedItems); } else { affiliate.sendPublishedNotifications(message, event, this, Collections.EMPTY_LIST); } break; case retract: if (isNotifiedOfRetract()) { affiliate.sendDeletionNotifications(message, event, this, newPublishedItems); } break; case none: // Do nothing, don't send message but don't retract either..'no-op' break; } } }