Java Code Examples for org.jdom.Element#getText()
The following examples show how to use
org.jdom.Element#getText() .
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: ActionMacro.java From consulo with Apache License 2.0 | 6 votes |
public void readExternal(Element macro) throws InvalidDataException { setName(macro.getAttributeValue(ATTRIBUTE_NAME)); List actions = macro.getChildren(); for (final Object o : actions) { Element action = (Element)o; if (ELEMENT_TYPING.equals(action.getName())) { Pair<List<Integer>, List<Integer>> codes = parseKeyCodes(action.getAttributeValue(ATTRIBUTE_KEY_CODES)); String text = action.getText(); if (text == null || text.length() == 0) { text = action.getAttributeValue(ATTRIBUTE_TEXT); } text = text.replaceAll(" ", " "); if (!StringUtil.isEmpty(text)) { myActions.add(new TypedDescriptor(text, codes.getFirst(), codes.getSecond())); } } else if (ELEMENT_ACTION.equals(action.getName())) { myActions.add(new IdActionDescriptor(action.getAttributeValue(ATTRIBUTE_ID))); } else if (ELEMENT_SHORTCUT.equals(action.getName())) { myActions.add(new ShortcutActionDesciption(action.getAttributeValue(ATTRIBUTE_TEXT))); } } }
Example 2
Source File: SeoPageExtraConfigDOM.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
@Override protected void addExtraConfig(PageMetadata pageMetadata, Document doc) { super.addExtraConfig(pageMetadata, doc); if (!(pageMetadata instanceof SeoPageMetadata)) { return; } Element root = doc.getRootElement(); SeoPageMetadata seoPage = (SeoPageMetadata) pageMetadata; Element useExtraDescriptionsElement = root.getChild(USE_EXTRA_DESCRIPTIONS_ELEMENT_NAME); if (null != useExtraDescriptionsElement) { Boolean value = Boolean.valueOf(useExtraDescriptionsElement.getText()); seoPage.setUseExtraDescriptions(value.booleanValue()); } Element descriptionsElement = root.getChild(DESCRIPTIONS_ELEMENT_NAME); this.extractMultilangProperty(descriptionsElement, seoPage.getDescriptions(), "description"); Element keywordsElement = root.getChild(KEYWORDS_ELEMENT_NAME); this.extractMultilangProperty(keywordsElement, seoPage.getKeywords(), "keywords"); Element friendlyCodeElement = root.getChild(FRIENDLY_CODE_ELEMENT_NAME); if (null != friendlyCodeElement) { seoPage.setFriendlyCode(friendlyCodeElement.getText()); } Element xmlConfigElement = root.getChild(XML_CONFIG_ELEMENT_NAME); if (null != xmlConfigElement) { //Used to guarantee porting with previous versions of the plugin String xml = xmlConfigElement.getText(); seoPage.setComplexParameters(this.extractComplexParameters(xml)); } else { Element complexParamElement = root.getChild(COMPLEX_PARAMS_ELEMENT_NAME); if (null != complexParamElement) { List<Element> elements = complexParamElement.getChildren(); seoPage.setComplexParameters(this.extractComplexParameters(elements)); } } }
Example 3
Source File: MessageNotifierConfigDOM.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
protected String[] extractRecipients(Element recipentsElem, String type) { List<Element> recipentsElements = recipentsElem.getChildren(type); String[] recipents = new String[recipentsElements.size()]; int index = 0; for (Element recipentElem : recipentsElements) { recipents[index++] = recipentElem.getText(); } return recipents; }
Example 4
Source File: SystemParamsUtils.java From entando-core with GNU Lesser General Public License v3.0 | 5 votes |
private static void insertParams(Element currentElement, Map<String, String> params) { if ("Param".equals(currentElement.getName())) { String key = currentElement.getAttributeValue("name"); String value = currentElement.getText(); params.put(key, value); } List<Element> elements = currentElement.getChildren(); for (int i = 0; i < elements.size(); i++) { Element element = elements.get(i); insertParams(element, params); } }
Example 5
Source File: MailConfigDOM.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
/** * Extract the senders from the xml element and save it into the MailConfig object. * @param root The xml root element containing the senders configuration. * @param config The configuration. */ private void extractSenders(Element root, MailConfig config) { Element sendersRootElem = root.getChild(SENDERS_ELEM); if (sendersRootElem!=null) { List sendersElem = sendersRootElem.getChildren(SENDER_CHILD); for (int i=0; i<sendersElem.size(); i++) { Element senderElem = (Element) sendersElem.get(i); String code = senderElem.getAttributeValue(SENDER_CODE_ATTR); String sender = senderElem.getText(); config.addSender(code, sender); } } }
Example 6
Source File: DAOMCScenarioStandard.java From Llunatic with GNU General Public License v3.0 | 5 votes |
@SuppressWarnings("unchecked") private void loadQueries(Element queriesElement, Scenario scenario) { if (queriesElement == null) { return; } List<Element> sourceElements = queriesElement.getChildren("query"); for (Element sourceElement : sourceElements) { String queryId = sourceElement.getAttributeValue("id"); String queryString = sourceElement.getText(); SQLQueryString sqlQueryString = new SQLQueryString(queryId, queryString); scenario.addSQLQueryString(sqlQueryString); } }
Example 7
Source File: MessageNotifierConfigDOM.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
protected String[] extractRecipients(Element recipentsElem, String type) { List<Element> recipentsElements = recipentsElem.getChildren(type); String[] recipents = new String[recipentsElements.size()]; int index = 0; for (Element recipentElem : recipentsElements) { recipents[index++] = recipentElem.getText(); } return recipents; }
Example 8
Source File: MailConfigDOM.java From entando-components with GNU Lesser General Public License v3.0 | 5 votes |
/** * Extract the jpmail configuration from an xml. * @param xml The xml containing the configuration. * @return The jpmail configuration. * @throws ApsSystemException In case of parsing errors. */ public MailConfig extractConfig(String xml) throws ApsSystemException { MailConfig config = new MailConfig(); Element root = this.getRootElement(xml); Element activeElem = root.getChild(ACTIVE_ELEM); if (activeElem != null) { String active = activeElem.getText(); config.setActive(null != active && active.equalsIgnoreCase("true")); } this.extractSenders(root, config); this.extractSmtp(root, config); return config; }
Example 9
Source File: PermissionXmlParser.java From jivejdon with Apache License 2.0 | 5 votes |
private PermissionRule parse(Element root) throws Exception { PermissionRule pr = new PermissionRule(); List services = root.getChildren("service"); Iterator iter = services.iterator(); while (iter.hasNext()) { Element service = (Element) iter.next(); String refName = service.getAttributeValue("ref"); if (service.getChildren("method") != null) { Iterator i = service.getChildren("method").iterator(); while (i.hasNext()) { Element method = (Element) i.next(); String methodName = method.getAttributeValue("name"); Debug.logVerbose(" method name=" + methodName, module); List roles = method.getChildren("role"); Iterator ii = roles.iterator(); while (ii.hasNext()) { Element role = (Element) ii.next(); String roleName = role.getText(); Debug.logVerbose(" role name=" + roleName, module); pr.putRule(refName, methodName, roleName); } } } } return pr; }
Example 10
Source File: JDOMUtils.java From geowave with Apache License 2.0 | 5 votes |
@SuppressFBWarnings( value = "NP_BOOLEAN_RETURN_NULL", justification = "its private and only used by methods that check for null") private static Boolean getBooleanVal(final Element e) { final String text = e.getText(); if ((text == null) || (text.isEmpty())) { return null; } return Boolean.valueOf(text); }
Example 11
Source File: SlackProjectSettings.java From TCSlackNotifierPlugin with MIT License | 5 votes |
public void readFrom(Element element) { Element channelElement = element.getChild(ELEMENT_CHANNEL); Element logoElement = element.getChild(ELEMENT_LOGO_URL); Attribute enabledAttr = element.getAttribute(ATTR_ENABLED); if( enabledAttr != null ) { try { enabled = enabledAttr.getBooleanValue() ; } catch (DataConversionException e) { enabled = true ; } } else { enabled = true ; } if( channelElement != null ) { this.channel = channelElement.getText(); } if( logoElement != null ) { this.logoUrl = logoElement.getText(); } }
Example 12
Source File: EpisodeElement.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public String getText(){ Element text = getElement().getChild("text", getContainer().getNamespace()); if (text != null) { return text.getText(); } return ""; }
Example 13
Source File: XMLBean.java From document-management-software with GNU Lesser General Public License v3.0 | 5 votes |
/** * This returns the text between a begining and an ending tag. * * @param elem Name of the element. * @return Text of the element. */ public String getText(Element elem) { if (doc == null) { return null; } else { return elem.getText(); } }
Example 14
Source File: GhidraToolTemplate.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void restoreFromXml(Element root) { java.util.List<?> list = root.getChildren("SUPPORTED_DATA_TYPE"); java.util.List<Class<?>> dtList = new ArrayList<>(); for (int i = 0; i < list.size(); ++i) { Element elem = (Element) list.get(i); String className = elem.getAttribute(CLASS_NAME_XML_NAME).getValue(); try { dtList.add(Class.forName(className)); } catch (ClassNotFoundException e) { Msg.error(this, "Class not found: " + className, e); } catch (Exception exc) {//TODO Msg.error(this, "Unexpected Exception: " + exc.getMessage(), exc); } } supportedDataTypes = new Class<?>[dtList.size()]; dtList.toArray(supportedDataTypes); Element iconElem = root.getChild(ICON_XML_NAME); String location = iconElem.getAttributeValue(LOCATION_XML_NAME); String iconText = iconElem.getText(); if (iconText != null && iconText.length() > 0) { iconText = iconText.trim(); byte[] imageBytes = NumericUtilities.convertStringToBytes(iconText); iconURL = new ToolIconURL(location, imageBytes); } else { iconURL = new ToolIconURL(location); } toolElement = root.getChild(TOOL_XML_NAME); }
Example 15
Source File: RobotCapabilitiesParser.java From swellrt with Apache License 2.0 | 4 votes |
private void parseRobotDescriptionXmlFile() throws CapabilityFetchException { // Fetch the XML file that defines the Robot capabilities. try { String xmlContent = connection.get(capabilitiesXmlUrl); if (xmlContent == null || xmlContent.isEmpty()) { throw new CapabilityFetchException("Empty capabilities.xml"); } StringReader reader = new StringReader(xmlContent); Document document = new SAXBuilder().build(reader); // Parse all "<w:capability>" tags. List<Element> capabilities = getElements(document, CAPABILITIES_TAG, CAPABILITY_TAG, XML_NS); for (Element capability : capabilities) { parseCapabilityTag(capability); } // Always react to SELF_ADDED: if (!this.capabilities.containsKey(EventType.WAVELET_SELF_ADDED)) { this.capabilities.put(EventType.WAVELET_SELF_ADDED, new Capability(EventType.WAVELET_SELF_ADDED, Capability.DEFAULT_CONTEXT)); } // Parse "<w:version>" tag. Element capabilitiesHashElement = document.getRootElement().getChild(ROBOT_VERSION_TAG, XML_NS); if (capabilitiesHashElement != null) { capabilitiesHash = capabilitiesHashElement.getText(); } // Parse "<w:protocolversion>" tag. Element protocolVersionElement = document.getRootElement().getChild(PROTOCOL_VERSION_TAG, XML_NS); if (protocolVersionElement != null) { protocolVersion = ProtocolVersion.fromVersionString(protocolVersionElement.getText()); } else { // In V1 API, we don't have <w:protocolversion> tag in the // capabilities.xml file. protocolVersion = ProtocolVersion.V1; } // Parse "<w:consumer_key>" tag(s). for (Element consumerKeyElement : getElements(document, CONSUMER_KEYS_TAG, CONSUMER_KEY_TAG, XML_NS)) { String forUrl = consumerKeyElement.getAttributeValue(CONSUMER_KEY_FOR_ATTRIBUTE); if (forUrl != null && forUrl.equals(activeRobotApiUrl)) { consumerKey = consumerKeyElement.getText(); } } } catch (IOException iox) { throw new CapabilityFetchException("Failure reading capabilities for: " + capabilitiesXmlUrl, iox); } catch (JDOMException jdomx) { throw new CapabilityFetchException("Failure parsing capabilities for: " + capabilitiesXmlUrl, jdomx); } catch (RobotConnectionException e) { throw new CapabilityFetchException(e); } }
Example 16
Source File: RobotCapabilitiesParser.java From incubator-retired-wave with Apache License 2.0 | 4 votes |
private void parseRobotDescriptionXmlFile() throws CapabilityFetchException { // Fetch the XML file that defines the Robot capabilities. try { String xmlContent = connection.get(capabilitiesXmlUrl); if (xmlContent == null || xmlContent.isEmpty()) { throw new CapabilityFetchException("Empty capabilities.xml"); } StringReader reader = new StringReader(xmlContent); Document document = new SAXBuilder().build(reader); // Parse all "<w:capability>" tags. List<Element> capabilities = getElements(document, CAPABILITIES_TAG, CAPABILITY_TAG, XML_NS); for (Element capability : capabilities) { parseCapabilityTag(capability); } // Always react to SELF_ADDED: if (!this.capabilities.containsKey(EventType.WAVELET_SELF_ADDED)) { this.capabilities.put(EventType.WAVELET_SELF_ADDED, new Capability(EventType.WAVELET_SELF_ADDED, Capability.DEFAULT_CONTEXT)); } // Parse "<w:version>" tag. Element capabilitiesHashElement = document.getRootElement().getChild(ROBOT_VERSION_TAG, XML_NS); if (capabilitiesHashElement != null) { capabilitiesHash = capabilitiesHashElement.getText(); } // Parse "<w:protocolversion>" tag. Element protocolVersionElement = document.getRootElement().getChild(PROTOCOL_VERSION_TAG, XML_NS); if (protocolVersionElement != null) { protocolVersion = ProtocolVersion.fromVersionString(protocolVersionElement.getText()); } else { // In V1 API, we don't have <w:protocolversion> tag in the // capabilities.xml file. protocolVersion = ProtocolVersion.V1; } // Parse "<w:consumer_key>" tag(s). for (Element consumerKeyElement : getElements(document, CONSUMER_KEYS_TAG, CONSUMER_KEY_TAG, XML_NS)) { String forUrl = consumerKeyElement.getAttributeValue(CONSUMER_KEY_FOR_ATTRIBUTE); if (forUrl != null && forUrl.equals(activeRobotApiUrl)) { consumerKey = consumerKeyElement.getText(); } } } catch (IOException iox) { throw new CapabilityFetchException("Failure reading capabilities for: " + capabilitiesXmlUrl, iox); } catch (JDOMException jdomx) { throw new CapabilityFetchException("Failure parsing capabilities for: " + capabilitiesXmlUrl, jdomx); } catch (RobotConnectionException e) { throw new CapabilityFetchException(e); } }
Example 17
Source File: SelfRestCallPostProcess.java From entando-core with GNU Lesser General Public License v3.0 | 4 votes |
@Override public void createConfig(Element element) { try { this.setLangCode(element.getAttributeValue("langCode")); this.setNamespace(element.getAttributeValue("namespace")); this.setResourceName(element.getAttributeValue("resourceName")); String methodString = element.getAttributeValue("method"); if (null != methodString) { this.setMethod(Enum.valueOf(ApiMethod.HttpMethod.class, methodString.toUpperCase())); } else { this.setMethod(ApiMethod.HttpMethod.GET); } String expectedString = element.getAttributeValue("expected"); if (null != expectedString) { try { this.setExpectedResult(Integer.parseInt(expectedString)); } catch (Exception e) {} } this.setPrintResponse(Boolean.parseBoolean(element.getAttributeValue("printresponse"))); String failOnError = element.getAttributeValue("failonerror"); if (null != failOnError) { this.setFailOnError(Boolean.parseBoolean(failOnError)); } Element parametersElement = element.getChild("query"); if (null != parametersElement) { List<Element> parameterElements = parametersElement.getChildren("parameter"); for (int i = 0; i < parameterElements.size(); i++) { Element parameterElement = parameterElements.get(i); String name = parameterElement.getAttributeValue("name"); String value = parameterElement.getAttributeValue("value"); if (null != name && null != value) { this.getQueryParameters().put(name, value); } } } Element contentBodyElement = element.getChild("contentBody"); if (null != contentBodyElement) { String contentTypeString = contentBodyElement.getAttributeValue("content-type"); this.setContentType(MediaType.valueOf(contentTypeString)); String text = contentBodyElement.getText(); if (null == text || text.trim().length() == 0) { String path = contentBodyElement.getAttributeValue("path"); if (null != path) { this.setContentBodyPath(path); } } if (null != text) { this.setContentBody(text); } } } catch (Throwable t) { _logger.error("Error creating Self rest call", t); //ApsSystemUtils.logThrowable(t, this, "createConfig"); throw new RuntimeException("Error creating Self rest call", t); } }
Example 18
Source File: ApiMethod.java From entando-core with GNU Lesser General Public License v3.0 | 4 votes |
private void buildMethod(Element element) { try { this.setDefaultRequiredAuth(Boolean.parseBoolean(element.getAttributeValue("requiredAuth"))); this.setRequiredAuth(this.getDefaultRequiredAuth()); this.setDefaultRequiredPermission(element.getAttributeValue("requiredPermission")); this.setRequiredPermission(this.getDefaultRequiredPermission()); String httpMethod = element.getAttributeValue("httpMethod"); if (null != httpMethod) { this.setHttpMethod(Enum.valueOf(ApiMethod.HttpMethod.class, httpMethod.toUpperCase())); } else { this.setHttpMethod(HttpMethod.GET); } this.setDefaultStatus(Boolean.parseBoolean(element.getAttributeValue(ApiResourcesDefDOM.ACTIVE_ATTRIBUTE_NAME))); this.setStatus(this.getDefaultStatus()); this.setDefaultHidden(Boolean.parseBoolean(element.getAttributeValue(ApiResourcesDefDOM.HIDDEN_ATTRIBUTE_NAME))); this.setHidden(this.getDefaultHidden()); this.setCanSpawnOthers(Boolean.parseBoolean(element.getAttributeValue(ApiResourcesDefDOM.CAN_SPAWN_OTHER_ATTRIBUTE_NAME))); this.setDescription(element.getChildText(ApiResourcesDefDOM.METHOD_DESCRIPTION_ELEMENT_NAME)); Element springBeanElement = element.getChild(ApiResourcesDefDOM.SPRING_BEAN_ELEMENT_NAME); this.setSpringBean(springBeanElement.getAttributeValue(ApiResourcesDefDOM.SPRING_BEAN_NAME_ATTRIBUTE_NAME)); this.setSpringBeanMethod(springBeanElement.getAttributeValue(ApiResourcesDefDOM.SPRING_BEAN_METHOD_ATTRIBUTE_NAME)); this.setResponseClassName(element.getChildText(ApiResourcesDefDOM.RESPONSE_CLASS_ELEMENT_NAME)); Element parametersElement = element.getChild(ApiResourcesDefDOM.PARAMETERS_ELEMENT_NAME); if (null != parametersElement) { List<Element> parametersElements = parametersElement.getChildren(ApiResourcesDefDOM.PARAMETER_ELEMENT_NAME); for (int i = 0; i < parametersElements.size(); i++) { Element parameterElement = parametersElements.get(i); ApiMethodParameter parameter = new ApiMethodParameter(parameterElement); if (null == this.getParameters()) { this.setParameters(new ArrayList<ApiMethodParameter>()); } this.getParameters().add(parameter); } } Element relatedWidgetElement = element.getChild(ApiResourcesDefDOM.RELATED_WIDGET_ELEMENT_NAME); if (null != relatedWidgetElement) { this.setRelatedWidget(new ApiMethodRelatedWidget(relatedWidgetElement)); } if (this.getHttpMethod().equals(HttpMethod.POST) || this.getHttpMethod().equals(HttpMethod.PUT)) { Element expectedTypeElement = element.getChild("expectedType"); String className = (null != expectedTypeElement) ? expectedTypeElement.getText() : null; if (null == className || className.trim().length() == 0) { throw new ApsSystemException("Expected Class required for Http Methods POST and PUT"); } Class beanClass = Class.forName(className); this.setExpectedType(beanClass); } } catch (Throwable t) { _logger.error("Error building api method '{}'", this.getResourceName(), t); throw new RuntimeException("Error building api method", t); } }
Example 19
Source File: DefaultArrangementSettingsSerializer.java From consulo with Apache License 2.0 | 4 votes |
@Nonnull private List<StdArrangementMatchRule> deserializeRules(@Nonnull Element element, @Nullable final Set<StdArrangementRuleAliasToken> aliases) { if (aliases != null && myMixin instanceof MutableMixin) { ((MutableMixin)myMixin).setMyRuleAliases(aliases); } final List<StdArrangementMatchRule> rules = new ArrayList<StdArrangementMatchRule>(); for (Object o : element.getChildren(RULE_ELEMENT_NAME)) { Element ruleElement = (Element)o; Element matcherElement = ruleElement.getChild(MATCHER_ELEMENT_NAME); if (matcherElement == null) { continue; } StdArrangementEntryMatcher matcher = null; for (Object c : matcherElement.getChildren()) { matcher = myMatcherSerializer.deserialize((Element)c); if (matcher != null) { break; } } if (matcher == null) { return ContainerUtil.newSmartList(); } Element orderTypeElement = ruleElement.getChild(ORDER_TYPE_ELEMENT_NAME); ArrangementSettingsToken orderType = null; if (orderTypeElement != null) { String orderTypeId = orderTypeElement.getText(); orderType = StdArrangementTokens.byId(orderTypeId); if (orderType == null) { orderType = myMixin.deserializeToken(orderTypeId); } if (orderType == null) { LOG.warn(String.format("Can't deserialize matching rule order type for id '%s'. Falling back to default (%s)", orderTypeId, ArrangementMatchRule.DEFAULT_ORDER_TYPE.getId())); } } if (orderType == null) { orderType = ArrangementMatchRule.DEFAULT_ORDER_TYPE; } rules.add(new StdArrangementMatchRule(matcher, orderType)); } return rules; }
Example 20
Source File: Samdas.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public String getText(){ Element eText = getTextElement(); return eText.getText(); }