Java Code Examples for org.dom4j.Element#element()
The following examples show how to use
org.dom4j.Element#element() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BookmarkInterceptor.java From openfire-ofmeet-plugin with Apache License 2.0 | 6 votes |
/** * Find and returns a 'storage' element as defined in XEP-0048 'Bookmarks' from a XML element that is expected to be a child element as defined in * XEP-0223 "Persistent Storage of Private Data via PubSub" * * @param pubsubElement a child element (can be null). * @return The XEP-0048-defined 'storage' element that was found in the child element, or null. */ static Element findStorageElementInPubsub( final Element pubsubElement ) { if ( pubsubElement == null ) { return null; } final Element itemsElement = pubsubElement.element( "items" ); if ( itemsElement == null || !"storage:bookmarks".equals( itemsElement.attributeValue( "node" ) ) ) { return null; } final Element itemElement = itemsElement.element( "item" ); if ( itemElement == null ) { return null; } return itemElement.element( QName.get( "storage", "storage:bookmarks" ) ); }
Example 2
Source File: AbstractFieldLoader.java From cuba with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") protected void loadValidation(Field component, Element element) { Element validatorsHolder = element.element("validators"); if (validatorsHolder != null) { List<Element> validators = validatorsHolder.elements(); ValidatorLoadFactory loadFactory = beanLocator.get(ValidatorLoadFactory.NAME); for (Element validatorElem : validators) { AbstractValidator validator = loadFactory.createValidator(validatorElem, context.getMessagesPack()); if (validator != null) { component.addValidator(validator); } else if (validatorElem.getName().equals("email")) { component.addValidator(new EmailValidator(validatorElem, context.getMessagesPack())); } } } }
Example 3
Source File: AbstractResourceViewLoader.java From cuba with Apache License 2.0 | 6 votes |
protected boolean loadFileResource(ResourceView resultComponent, Element element) { Element fileResource = element.element("file"); if (fileResource == null) return false; String filePath = fileResource.attributeValue("path"); if (StringUtils.isEmpty(filePath)) { throw new GuiDevelopmentException("No path provided for the FileResource", context); } File file = new File(filePath); if (!file.exists()) { String msg = String.format("Can't load FileResource. File with given path does not exists: %s", filePath); throw new GuiDevelopmentException(msg, context); } FileResource resource = resultComponent.createResource(FileResource.class); resource.setFile(file); loadStreamSettings(resource, fileResource); resultComponent.setSource(resource); return true; }
Example 4
Source File: AbstractDataGridLoader.java From cuba with Apache License 2.0 | 6 votes |
@Nullable protected DataGrid.Renderer loadRenderer(Element columnElement) { Element rendererElement; for (Map.Entry<String, Class<?>> entry : RENDERERS_MAP.entrySet()) { rendererElement = columnElement.element(entry.getKey()); if (rendererElement != null) { return loadRendererByClass(rendererElement, entry.getValue()); } } rendererElement = columnElement.element("renderer"); if (rendererElement != null) { return loadLegacyRenderer(rendererElement); } return null; }
Example 5
Source File: FlakyCaseResult.java From flaky-test-handler-plugin with Apache License 2.0 | 5 votes |
private static String getSkippedMessage(Element testCase) { String message = null; Element skippedElement = testCase.element("skipped"); if (skippedElement != null) { message = skippedElement.attributeValue("message"); } return message; }
Example 6
Source File: FilterParserImpl.java From cuba with Apache License 2.0 | 5 votes |
@Override public ConditionsTree getConditions(Filter filter, String xml) { ConditionsTree conditions = new ConditionsTree(); if (!StringUtils.isBlank(xml)) { Element root = dom4JTools.readDocument(xml).getRootElement(); Element andElem = root.element("and"); if (andElem == null) throw new IllegalStateException("Root element doesn't contain 'and': " + xml); recursiveFromXml(andElem, null, filter, xml, conditions); } return conditions; }
Example 7
Source File: PointInTimeDataImport.java From unitime with Apache License 2.0 | 5 votes |
@SuppressWarnings("unchecked") private void loadOfferings(Element rootElement) throws Exception{ Element offeringsElement = rootElement.element(PointInTimeDataExport.sOfferingsElementName); ProgressTracker progressTracker = new ProgressTracker("Instructional Offerings", offeringsElement.elements().size(), 2, this.getClass()); info("Loading data for " + offeringsElement.elements().size() + " offerings."); String progress = null; int successCount = 0; int failCount = 0; for ( Element offeringElement : (List<Element>) offeringsElement.elements()) { try { elementOffering(offeringElement); flush(true); successCount++; } catch (Exception e) { addNote("Not Loading 'offering' Error: " + e.getMessage()); e.printStackTrace(); addNote("\t " + offeringElement.asXML()); failCount++; throw(e); } progress = progressTracker.getProgressStringIfNeeded(); if (progress != null) { info(progress); } } info("Loading of offering data complete. " + successCount + " successfully loaded. " + failCount + " failed to load."); // progress = progressTracker.getElapsedTimeAnalysisString(); // if (progress != null) { // info(progress); // } }
Example 8
Source File: DataMigrator.java From onedev with MIT License | 5 votes |
private void migrate5(File dataDir, Stack<Integer> versions) { for (File file: dataDir.listFiles()) { if (file.getName().startsWith("Configs.xml")) { VersionedXmlDoc dom = VersionedXmlDoc.fromFile(file); for (Element element: dom.getRootElement().elements()) { if (element.elementTextTrim("key").equals("MAIL")) { Element settingElement = element.element("setting"); if (settingElement != null) settingElement.addElement("enableSSL").setText("false"); } } dom.writeToFile(file, false); } } }
Example 9
Source File: FlakyCaseResult.java From flaky-test-handler-plugin with Apache License 2.0 | 5 votes |
private static String getErrorMessage(Element testCase) { Element msg = testCase.element("error"); if (msg == null) { msg = testCase.element("failure"); } if (msg == null) { return null; // no error or failure elements! damn! } return msg.attributeValue("message"); }
Example 10
Source File: WindowLoader.java From cuba with Apache License 2.0 | 5 votes |
protected void loadScreenData(Window window, Element element) { Element dataEl = element.element("data"); if (dataEl != null) { ScreenDataXmlLoader screenDataXmlLoader = beanLocator.get(ScreenDataXmlLoader.class); ScreenData screenData = UiControllerUtils.getScreenData(window.getFrameOwner()); screenDataXmlLoader.load(screenData, dataEl, null); ((ComponentLoaderContext) context).setScreenData(screenData); } }
Example 11
Source File: TraceEventAlert.java From pega-tracerviewer with Apache License 2.0 | 5 votes |
@Override protected void setName(Element traceEventElement) { String name = ""; Element element = traceEventElement.element("AlertLabel"); if (element != null) { name = element.getText(); } setName(name); }
Example 12
Source File: JPAOverriddenAnnotationReader.java From lams with GNU General Public License v2.0 | 5 votes |
/** * Adds an @OrderColumn annotation to the specified annotationList if the specified element * contains an order-column sub-element. This should only be the case for element-collection, * many-to-many, or one-to-many associations. */ private void getOrderColumn(List<Annotation> annotationList, Element element) { Element subelement = element != null ? element.element( "order-column" ) : null; if ( subelement != null ) { AnnotationDescriptor ad = new AnnotationDescriptor( OrderColumn.class ); copyStringAttribute( ad, subelement, "name", false ); copyBooleanAttribute( ad, subelement, "nullable" ); copyBooleanAttribute( ad, subelement, "insertable" ); copyBooleanAttribute( ad, subelement, "updatable" ); copyStringAttribute( ad, subelement, "column-definition", false ); annotationList.add( AnnotationFactory.create( ad ) ); } }
Example 13
Source File: ChoiceQuestion.java From olat with Apache License 2.0 | 5 votes |
/** * Build fail resprocessing: Adjust score to 0 (if multiple correct mode) and set hints, solutions and fail feedback * * @param resprocessingXML * @param isSingleCorrect */ private void buildRespcondition_fail(final Element resprocessingXML, final boolean isSingleCorrect) { // build final Element respcondition_fail = resprocessingXML.addElement("respcondition"); respcondition_fail.addAttribute("title", "Fail"); respcondition_fail.addAttribute("continue", "Yes"); final Element conditionvar = respcondition_fail.addElement("conditionvar"); final Element or = conditionvar.addElement("or"); for (final Iterator i = getResponses().iterator(); i.hasNext();) { final ChoiceResponse tmpChoice = (ChoiceResponse) i.next(); Element varequal; // Add this response to the fail case // if single correct type and not correct // or multi correct and points negative or 0 if ((isSingleCorrect && !tmpChoice.isCorrect()) || (!isSingleCorrect && tmpChoice.getPoints() <= 0)) { varequal = or.addElement("varequal"); varequal.addAttribute("respident", getIdent()); varequal.addAttribute("case", "Yes"); varequal.addText(tmpChoice.getIdent()); } } // for loop if (isSingleCorrect) { final Element setvar = respcondition_fail.addElement("setvar"); setvar.addAttribute("varname", "SCORE"); setvar.addAttribute("action", "Set"); setvar.addText("0"); } // Use fail feedback, hints and solutions QTIEditHelperEBL.addFeedbackFail(respcondition_fail); QTIEditHelperEBL.addFeedbackHint(respcondition_fail); QTIEditHelperEBL.addFeedbackSolution(respcondition_fail); // remove whole respcondition if empty if (or.element("varequal") == null) { resprocessingXML.remove(respcondition_fail); } }
Example 14
Source File: SolverImport.java From unitime with Apache License 2.0 | 5 votes |
protected DataProperties getConfig(Element root) { DataProperties config = new DataProperties(); if (root.element("configuration") != null) for (Iterator i = root.element("configuration").elementIterator("property"); i.hasNext(); ) { Element e = (Element)i.next(); config.setProperty(e.attributeValue("name"), e.getText()); } config.setProperty("General.OwnerPuid", getManager().getExternalUniqueId()); Session session = Session.getSessionUsingInitiativeYearTerm( root.attributeValue("initiative", root.attributeValue("campus")), root.attributeValue("year"), root.attributeValue("term")); if (session != null) { config.setProperty("General.SessionId", session.getUniqueId().toString()); } else { Long sessionId = config.getPropertyLong("General.SessionId", null); if (sessionId == null) { throw new RuntimeException("Academic session id not provided."); } session = SessionDAO.getInstance().get(sessionId, getHibSession()); if (session == null) { throw new RuntimeException("Academic session " + sessionId + " does not exist."); } } config.setProperty("General.Save","false"); config.setProperty("General.CreateNewSolution","false"); config.setProperty("General.Unload","false"); return config; }
Example 15
Source File: MsgH225cs.java From mts with GNU General Public License v3.0 | 5 votes |
/** * Parse the message from XML element */ @Override public void parseFromXml(ParseFromXmlContext context, Element root, Runner runner) throws Exception { super.parseFromXml(context,root,runner); this.msgAsn1 = new Asn1Message(); this.msgAsn1.parseElement(root); Element ie = root.element("ISDN"); this.msgQ931 = new MessageQ931(ie); }
Example 16
Source File: PersistentElementHolder.java From cacheonix-core with GNU Lesser General Public License v2.1 | 5 votes |
public PersistentElementHolder(SessionImplementor session, CollectionPersister persister, Serializable key) throws HibernateException { super(session); Element owner = (Element) session.getPersistenceContext().getCollectionOwner(key, persister); if (owner==null) throw new AssertionFailure("null owner"); //element = XMLHelper.generateDom4jElement( persister.getNodeName() ); final String nodeName = persister.getNodeName(); if ( ".".equals(nodeName) ) { element = owner; } else { element = owner.element( nodeName ); if (element==null) element = owner.addElement( nodeName ); } }
Example 17
Source File: SolverImport.java From unitime with Apache License 2.0 | 5 votes |
protected byte[] toData(Element root) throws UnsupportedEncodingException, IOException { Element configEl = root.element("configuration"); if (configEl != null) root.remove(configEl); ByteArrayOutputStream ret = new ByteArrayOutputStream(); (new XMLWriter(ret, OutputFormat.createCompactFormat())).write(root.getDocument()); ret.flush(); ret.close(); return ret.toByteArray(); }
Example 18
Source File: Dom4jAccessor.java From cacheonix-core with GNU Lesser General Public License v2.1 | 4 votes |
public Object get(Object owner) throws HibernateException { Element ownerElement = (Element) owner; Node element = ownerElement.element(elementName); return element==null ? null : super.propertyType.fromXMLNode(element, super.factory); }
Example 19
Source File: WeiXinUtil.java From xnx3 with Apache License 2.0 | 4 votes |
/** * 接收xml格式消息,用户通过微信公众号发送消息,有服务器接收。这里将微信服务器推送来的消息进行格式化为 {@link MessageReceive}对象 * <br/>通常此会存在于一个Servlet中,用于接收微信服务器推送来的消息。例如SpringMVC中可以这样写: * <br/><pre> * * </pre> * @param messageContent 这里便是微信服务器接收到消息后,将消息POST提交过来消息内容,如: * <pre> * <xml><ToUserName><![CDATA[gh_674025ffa56e]]></ToUserName><FromUserName><![CDATA[open_jmQkHQEf8o3xfyjfLjKXTnE]]></FromUserName><CreateTime>1509453449</CreateTime><MsgType><![CDATA[text]]></MsgType><Content><![CDATA[123]]></Content><MsgId>6483053198716493194</MsgId></xml> * </pre> * @return 返回 {@link MessageReceive} * @throws DocumentException */ public MessageReceive receiveMessage(String messageContent) throws DocumentException{ MessageReceive mr = new MessageReceive(); if(messageContent == null || messageContent.length() == 0){ //为空,那么直接返回mr,当然,mr中的各项都是空的 return mr; } mr.setReceiveBody(messageContent); Document doc = DocumentHelper.parseText(messageContent); Element e = doc.getRootElement(); if(e.element("CreateTime") != null){ mr.setCreateTime(Lang.stringToInt(e.element("CreateTime").getText(), 0)); } if(e.element("FromUserName") != null){ mr.setFromUserName(e.element("FromUserName").getText()); } if(e.element("MsgType") != null){ mr.setMsgType(e.element("MsgType").getText()); } if(e.element("ToUserName") != null){ mr.setToUserName(e.element("ToUserName").getText()); } if(e.element("MsgId") != null){ mr.setMsgId(e.element("MsgId").getText()); } if(e.element("Content") != null){ mr.setContent(e.element("Content").getText()); } if(e.element("Description") != null){ mr.setDescription(e.element("Description").getText()); } if(e.element("Format") != null){ mr.setFormat(e.element("Format").getText()); } if(e.element("MediaId") != null){ mr.setMediaId(e.element("MediaId").getText()); } if(e.element("PicUrl") != null){ mr.setPicUrl(e.element("PicUrl").getText()); } if(e.element("ThumbMediaId") != null){ mr.setThumbMediaId(e.element("ThumbMediaId").getText()); } if(e.element("Title") != null){ mr.setTitle(e.element("Title").getText()); } if(e.element("Url") != null){ mr.setUrl(e.element("Url").getText()); } if(e.element("Event") != null){ mr.setEvent(e.element("Event").getText()); } if(e.element("EventKey") != null){ mr.setEventKey(e.element("EventKey").getText()); } if(e.element("Ticket") != null){ mr.setTicket(e.element("Ticket").getText()); } return mr; }
Example 20
Source File: TraceEvent.java From pega-tracerviewer with Apache License 2.0 | 4 votes |
protected void setName(Element traceEventElement) { Element element = traceEventElement.element("EventKey"); if (element != null) { name = element.getText(); } else { element = traceEventElement.element("InstanceName"); if (element != null) { name = element.getText(); } } if ((name != null) && (!"".equals(name))) { if (isInstanceHandle(name)) { Attribute attribute = traceEventElement.attribute("inskey"); if (attribute != null) { attribute = traceEventElement.attribute("keyname"); if (attribute != null) { name = attribute.getText(); if (isDataPageEventKey()) { name = buildActivityName(name); name = buildDataPageDisplayName(name); } } } else { name = buildActivityName(name); } } else if (!isInstanceWithKeys(name)) { name = buildActivityName(name); } } }