Java Code Examples for org.dom4j.Element#getStringValue()

The following examples show how to use org.dom4j.Element#getStringValue() . 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: ScenarioReference.java    From mts with GNU General Public License v3.0 6 votes vote down vote up
public ScenarioReference(Element elements, Testcase testcase) {
    _name = elements.attributeValue("name");
    _name = Utils.replaceFileName(this._name);
    _routingName = elements.attributeValue("routingName");
    _description = elements.attributeValue("description");
    String strState = elements.attributeValue("state");
    if (strState != null)
    {
    	_state = Utils.parseBoolean(strState, "state");
    	//_state = Boolean.parseBoolean(strState);
    }
    _filename = elements.attributeValue("file");
    if(null == _filename)
    {
        _filename = elements.getStringValue();
    }
    _filename = _filename.trim();
    _testcase = testcase;
}
 
Example 2
Source File: SkipXmlNodeMatcher.java    From ats-framework with Apache License 2.0 5 votes vote down vote up
List<Element> getMatchingNodes( String snapshot, XmlNode xmlNode ) {

            // cycle all nodes that come for this XPath
            List<Element> matchedNodes = new ArrayList<>();

            List foundNodeObjects = xmlNode.getnode().selectNodes(this.xpath);
            if (foundNodeObjects != null) {
                for (Object foundNodeObject : foundNodeObjects) {
                    Element node = (Element) foundNodeObject;

                    String message = null;
                    String nodeValue = node.getStringValue();
                    if (matchType == MATCH_TYPE.TEXT && nodeValue.equalsIgnoreCase(value)) {
                        // equals text
                        message = "equals ignoring case '" + value + "'";
                    } else if (matchType == MATCH_TYPE.CONTAINS_TEXT
                               && nodeValue.toLowerCase().contains(this.value.toLowerCase())) {
                        // contains text
                        message = "contains ignoring case '" + value + "'";
                    } else if (nodeValue.matches(value)) {
                        // matches regex
                        message = "matches the '" + value + "' regular expression";
                    }

                    if (message != null) {
                        if (log.isDebugEnabled()) {
                            log.debug("[" + snapshot + "] File " + filePath + ": Removing XML node "
                                      + new XmlNode(xmlNode, node).getSignature("") + " as its value '"
                                      + nodeValue + "' " + message);
                        }
                        matchedNodes.add(node);
                    }
                }
            }

            return matchedNodes;
        }
 
Example 3
Source File: FlowNodeParser.java    From urule with Apache License 2.0 5 votes vote down vote up
private Connection buildConnection(Element element){
	Connection conn=new Connection();
	conn.setName(element.attributeValue("name"));
	conn.setToName(element.attributeValue("to"));
	conn.setG(element.attributeValue("g"));
	String script=element.getStringValue();
	if(StringUtils.isNotEmpty(script)){
		conn.setScript(script);
	}
	return conn;
}
 
Example 4
Source File: ScriptNodeParser.java    From urule with Apache License 2.0 5 votes vote down vote up
@Override
public ScriptNode parse(Element element) {
	ScriptNode node =new ScriptNode();
	node.setName(element.attributeValue("name"));
	node.setEventBean(element.attributeValue("event-bean"));
	node.setX(element.attributeValue("x"));
	node.setY(element.attributeValue("y"));
	node.setWidth(element.attributeValue("width"));
	node.setHeight(element.attributeValue("height"));
	node.setConnections(parseConnections(element));
	String script=element.getStringValue();
	node.setScript(script);
	return node;
}
 
Example 5
Source File: DecisionNodeParser.java    From urule with Apache License 2.0 5 votes vote down vote up
private DecisionItem parseDecisionItem(Element element){
	DecisionItem item=new DecisionItem();
	item.setTo(element.attributeValue("connection"));
	String script=element.getStringValue();
	item.setScript(script);
	String percent=element.attributeValue("percent");
	if(StringUtils.isNotEmpty(percent)){
		item.setPercent(Integer.valueOf(percent));			
	}
	return item;
}
 
Example 6
Source File: ConfigParseUtils.java    From jeesuite-config with Apache License 2.0 5 votes vote down vote up
private static void parseDataFromXML(Map<String, Object> result, String xmlContents) {
	 Document doc = null;
	try {
           //doc = DocumentHelper.parseText(xmlContents);
		SAXReader reader = new SAXReader();
		 //忽略dtd验证
		reader.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false); 
           InputSource source = new InputSource(new StringReader(xmlContents));
	    source.setEncoding("UTF-8");
	    doc = reader.read(source);
           Element rootElt = doc.getRootElement(); 
           Iterator<?> iter = rootElt.elementIterator("entry"); 
           // 遍历head节点
           while (iter.hasNext()) {
               Element elm = (Element) iter.next();
               String stringValue = elm.getStringValue();
               if(StringUtils.isNotBlank(stringValue)){                	
               	result.put(elm.attribute("key").getStringValue(), stringValue.trim());
               }
           }
       } catch (Exception e) {
       	if(e instanceof  org.dom4j.DocumentException){
       		throw new JeesuiteBaseException(500, "xml文件内容格式错误");
       	}
       	throw new RuntimeException(e);
       }
}
 
Example 7
Source File: Delay.java    From bulbasaur with Apache License 2.0 5 votes vote down vote up
@Override
public StateLike parse(Element elem) {
    super.parse(elem);
    List<Element> intervalElement = elem.selectNodes(TIME_TAG);
    // 拿 孩子节点
    for (Element intervalNode : intervalElement) {
        this.time = intervalNode.getStringValue();
    }
    return this;
}
 
Example 8
Source File: TextMarker.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor, used to create an object from an XML element
 * 
 * @param textMarkerElement
 */
public TextMarker(Element textMarkerElement) {
    Element markedTexEl = textMarkerElement.element(XML_MARKED_TEXT_ELEMENT);
    this.markedText = (markedTexEl == null ? null : markedTexEl.getStringValue());
    Element hooverEl = textMarkerElement.element(XML_HOOVER_TEXT_ELEMENT);
    this.hooverText = (hooverEl == null ? null : hooverEl.getStringValue());
    Element cssEl = textMarkerElement.element(XML_CSS_CLASS_ELEMENT);
    this.cssClass = (cssEl == null ? null : cssEl.getStringValue());
}
 
Example 9
Source File: TextMarker.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor, used to create an object from an XML element
 * 
 * @param textMarkerElement
 */
public TextMarker(Element textMarkerElement) {
    Element markedTexEl = textMarkerElement.element(XML_MARKED_TEXT_ELEMENT);
    this.markedText = (markedTexEl == null ? null : markedTexEl.getStringValue());
    Element hooverEl = textMarkerElement.element(XML_HOOVER_TEXT_ELEMENT);
    this.hooverText = (hooverEl == null ? null : hooverEl.getStringValue());
    Element cssEl = textMarkerElement.element(XML_CSS_CLASS_ELEMENT);
    this.cssClass = (cssEl == null ? null : cssEl.getStringValue());
}
 
Example 10
Source File: SiteServiceImpl.java    From studio with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("unchecked")
private  Map<String, Object> createMap(Element element) {
	Map<String, Object> map = new HashMap<String, Object>();
	for ( int i = 0, size = element.nodeCount(); i < size; i++ ) {
		Node currentNode = element.node(i);
		if ( currentNode instanceof Element ) {
			Element currentElement = (Element)currentNode;
			String key = currentElement.getName();
			Object toAdd = null;
			if (currentElement.isTextOnly()) {
				 toAdd = currentElement.getStringValue();
			} else {
				toAdd = createMap(currentElement);
			}
			if (map.containsKey(key)) {
				Object value = map.get(key);
				List listOfValues = new ArrayList<Object>();
				if (value instanceof List) {
					listOfValues = (List<Object>)value;
				} else {
					listOfValues.add(value);
				}
				listOfValues.add(toAdd);
				map.put(key, listOfValues);
			} else {
				map.put(key, toAdd);
			}
		}
	}
	return map;
}
 
Example 11
Source File: RssLoader.java    From android-opensource-library-56 with Apache License 2.0 5 votes vote down vote up
@Override
public RssList loadInBackground() {
    try {
        SAXReader reader = new SAXReader();
        Document document = reader.read(this.mFeed.url);
        List<Element> list = document.selectNodes("/rss/channel/item");
        if (list != null) {
            for (Element element : list) {
                Item item = new Item();
                Element title = element.element("title");
                if (title != null) {
                    item.title = title.getStringValue();
                }
                Element link = element.element("link");
                if (link != null) {
                    item.url = link.getStringValue();
                }
                if (mList == null) {
                    mList = new RssList();
                }
                mList.addItem(item);
            }
        } else {
            Log.d(TAG, "not found");
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    return mList;
}
 
Example 12
Source File: SuggestionFieldQueryLoader.java    From cuba with Apache License 2.0 4 votes vote down vote up
protected void loadQuery(SuggestionField suggestionField, Element element) {
    Element queryElement = element.element("query");
    if (queryElement != null) {
        final boolean escapeValue;

        String stringQuery = queryElement.getStringValue();

        String searchFormat = queryElement.attributeValue("searchStringFormat");

        String view = queryElement.attributeValue("view");

        String escapeValueForLike = queryElement.attributeValue("escapeValueForLike");
        if (StringUtils.isNotEmpty(escapeValueForLike)) {
            escapeValue = Boolean.valueOf(escapeValueForLike);
        } else {
            escapeValue = false;
        }

        String entityClassName = queryElement.attributeValue("entityClass");
        if (StringUtils.isNotEmpty(entityClassName)) {
            DataManager dataManager = beanLocator.get(DataManager.NAME);
            suggestionField.setSearchExecutor((searchString, searchParams) -> {
                Class<Entity> entityClass = ReflectionHelper.getClass(entityClassName);
                if (escapeValue) {
                    searchString = QueryUtils.escapeForLike(searchString);
                }
                searchString = applySearchFormat(searchString, searchFormat);

                LoadContext loadContext = LoadContext.create(entityClass);
                if (StringUtils.isNotEmpty(view)) {
                    loadContext.setView(view);
                }
                loadContext.setQuery(LoadContext.createQuery(stringQuery).setParameter("searchString", searchString));

                //noinspection unchecked
                return dataManager.loadList(loadContext);
            });
        } else {
            throw new GuiDevelopmentException(String.format("Field 'entityClass' is empty in component %s.",
                    suggestionField.getId()), getContext());
        }
    }
}
 
Example 13
Source File: ServerConfiguration.java    From livingdoc-confluence with GNU General Public License v3.0 4 votes vote down vote up
private String getStringData(Element element) {
    String value = element.getStringValue();
    value = value.trim().replace('\\', '/');
    return value;
}
 
Example 14
Source File: Signatures.java    From ofdrw with Apache License 2.0 2 votes vote down vote up
/**
 * 【可选 属性】
 * 获取 安全标识的最大值
 * <p>
 * 作用与文档入口文件 Document.xml 中的 MaxID相同,
 * 为了避免在签名时影响文档入口文件,采用了与ST_ID不一样
 * 的ID编码方式。
 * <p>
 * 推荐使用“sNNN”的编码方式,NNN从1开始
 *
 * @return 安全标识的最大值
 */
public String getMaxSignId() {
    Element e = this.getOFDElement("MaxSignId");
    return e == null ? null :e.getStringValue();
}