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

The following examples show how to use org.dom4j.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: TraceEvent.java    From pega-tracerviewer with Apache License 2.0 6 votes vote down vote up
protected void setElapsed(Element traceEventElement) {

        elapsed = -1;

        Element element = traceEventElement.element("Elapsed");

        if (element != null) {
            String elapsedStr = element.getText();

            if ((elapsedStr != null) && (!"".equals(elapsedStr))) {

                try {
                    elapsed = Double.parseDouble(elapsedStr);
                    // convert to seconds
                    elapsed = elapsed / 1000;
                } catch (NumberFormatException nfe) {
                    LOG.error("Error parsing elapsed string: " + elapsedStr, nfe);
                }
            }
        }
    }
 
Example 2
Source File: DataMigrator.java    From onedev with MIT License 6 votes vote down vote up
private void migrateIntegrationStrategy8(Element integrationStrategyElement) {
	if (integrationStrategyElement != null) {
		integrationStrategyElement.setName("mergeStrategy");
		switch (integrationStrategyElement.getText()) {
		case "MERGE_ALWAYS":
			integrationStrategyElement.setText("ALWAYS_MERGE");
			break;
		case "MERGE_WITH_SQUASH":
			integrationStrategyElement.setText("SQUASH_MERGE");
			break;
		case "REBASE_SOURCE_ONTO_TARGET":
			integrationStrategyElement.setText("REBASE_MERGE");
			break;
		case "REBASE_TARGET_ONTO_SOURCE":
			integrationStrategyElement.setText("MERGE_IF_NECESSARY");
			break;
		}
	}
}
 
Example 3
Source File: OozieGraphXMLParser.java    From EasyML with Apache License 2.0 6 votes vote down vote up
/** Parse a edge from xml
 * @param enode  edge node
 */
private static OozieEdge parseOozieEdge(Element enode) {

	String src = "";
	String dst = "";
	List<Element> children = enode.elements();
	for( Element child: children){
		if ("source".equals(child.getName())) {
			src = child.getText();
		} else if ("destination".equals(child.getName())) {
			dst = child.getText();
			break;
		}
	}
	if (src.isEmpty() || dst.isEmpty()) {
		logger.warning("Empty edge, src:" + src + ", dst:" + dst);
		return null;
	}
	else{
		OozieEdge edge = new OozieEdge();
		edge.init(src, dst);
		return edge;
	}
}
 
Example 4
Source File: SurveyFileResourceValidator.java    From olat with Apache License 2.0 6 votes vote down vote up
@Override
public boolean validate(final File unzippedDir) {
    // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    final VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedDir);
    final VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
    // getDocument(..) ensures that InputStream is closed in every case.
    final Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    // if doc is null an error loading the document occured
    if (doc == null) {
        return false;
    }
    final List metas = doc.selectNodes("questestinterop/assessment/qtimetadata/qtimetadatafield");
    for (final Iterator iter = metas.iterator(); iter.hasNext();) {
        final Element el_metafield = (Element) iter.next();
        final Element el_label = (Element) el_metafield.selectSingleNode("fieldlabel");
        final String label = el_label.getText();
        if (label.equals(AssessmentInstance.QMD_LABEL_TYPE)) { // type meta
            final Element el_entry = (Element) el_metafield.selectSingleNode("fieldentry");
            final String entry = el_entry.getText();
            return entry.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY);
        }
    }

    return false;
}
 
Example 5
Source File: GeospatialInformationAuthorityFormat.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
private void readBuildings(Document doc, GMLMap result) {
    List elements = doc.getRootElement().elements(BUILDING_QNAME);
    Logger.debug("Found " + elements.size() + " buildings");
    for (Object next : elements) {
        Element e = (Element)next;
        try {
            Element posList = e.element(LOC_QNAME).element(CURVE_QNAME).element(SEGMENTS_QNAME).element(LINE_STRING_SEGMENT_QNAME).element(POS_LIST_QNAME);
            String coords = posList.getText();
            List<GMLDirectedEdge> edges = readEdges(coords, result);
            result.createBuilding(edges);
        }
        catch (NullPointerException ex) {
            Logger.debug("Building with wonky outline found: " + ex);
        }
    }
}
 
Example 6
Source File: SurveyFileResourceValidator.java    From olat with Apache License 2.0 6 votes vote down vote up
@Override
public boolean validate(final File unzippedDir) {
    // with VFS FIXME:pb:c: remove casts to LocalFileImpl and LocalFolderImpl if no longer needed.
    final VFSContainer vfsUnzippedRoot = new LocalFolderImpl(unzippedDir);
    final VFSItem vfsQTI = vfsUnzippedRoot.resolve("qti.xml");
    // getDocument(..) ensures that InputStream is closed in every case.
    final Document doc = QTIHelper.getDocument((LocalFileImpl) vfsQTI);
    // if doc is null an error loading the document occured
    if (doc == null) {
        return false;
    }
    final List metas = doc.selectNodes("questestinterop/assessment/qtimetadata/qtimetadatafield");
    for (final Iterator iter = metas.iterator(); iter.hasNext();) {
        final Element el_metafield = (Element) iter.next();
        final Element el_label = (Element) el_metafield.selectSingleNode("fieldlabel");
        final String label = el_label.getText();
        if (label.equals(AssessmentInstance.QMD_LABEL_TYPE)) { // type meta
            final Element el_entry = (Element) el_metafield.selectSingleNode("fieldentry");
            final String entry = el_entry.getText();
            return entry.equals(AssessmentInstance.QMD_ENTRY_TYPE_SURVEY);
        }
    }

    return false;
}
 
Example 7
Source File: SavedSearchResultsMap.java    From alfresco-repository with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * @see org.alfresco.repo.template.BaseTemplateMap#get(java.lang.Object)
 */
public Object get(Object key)
{
    String search = null;
    
    if (key != null && key.toString().length() != 0)
    {
        // read the Saved Search XML on the specified node - and get the Lucene search from it
        try
        {
            NodeRef ref = new NodeRef(key.toString());
            
            ContentReader content = services.getContentService().getReader(ref, ContentModel.PROP_CONTENT);
            if (content != null && content.exists())
            {
                // get the root element
                SAXReader reader = new SAXReader();
                Document document = reader.read(new StringReader(content.getContentString()));
                Element rootElement = document.getRootElement();
                
                Element queryElement = rootElement.element(ELEMENT_QUERY);
                if (queryElement != null)
                {
                    search = queryElement.getText();
                }
            }
        }
        catch (Throwable err)
        {
            throw new AlfrescoRuntimeException("Failed to find or load saved Search: " + key, err);
        }
    }
    
    // execute the search
    return query(search);
}
 
Example 8
Source File: IMSMetadataDocument.java    From olat with Apache License 2.0 5 votes vote down vote up
private static void collectLangString(final StringBuilder sb, final Element element) {
    if ("langstring".equals(element.getName())) {
        final String content = element.getText();
        if (!stopWords.contains(content)) {
            sb.append(content).append(' ');
        }
    }
    @SuppressWarnings("rawtypes")
    final List children = element.elements();
    for (int i = 0; i < children.size(); i++) {
        final Element child = (Element) children.get(i);
        collectLangString(sb, child);
    }
}
 
Example 9
Source File: VersionUpdater.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
public void getLastVersion(File controlpath){
	System.out.println("old version file path: " + controlpath.getAbsolutePath());
	String dayTag = "DayInPast";
	String versionTag = "LastDate";
	String name;
	
	/*
	this.setCvsControlPath(controlpath);
	*/
	SAXReader saxReader = new SAXReader();
	Document document = null;
	try{
		document = saxReader.read(this.cvsControlPath);
	}catch(org.dom4j.DocumentException dex){
		dex.printStackTrace();
	}
	Element rootElement = document.getRootElement();
	Iterator it = rootElement.elementIterator();
	while(it.hasNext()){
		Element element = (Element)it.next();
		name = element.getName();
		if ( name.equalsIgnoreCase(versionTag)){
			this.oldVersion = element.getText();
		}else if( name.equalsIgnoreCase(dayTag) ){
			this.daysInPast = Integer.valueOf(element.getText().trim()).intValue();

		}
	}
	
}
 
Example 10
Source File: TemplateCommentGenerator.java    From mybatis-generator-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * 构造函数
 * @param context
 * @param templatePath  模板路径
 */
public TemplateCommentGenerator(Context context, String templatePath) {
    try {
        Document doc = null;
        File file = new File(templatePath);
        if (file.exists()) {
            doc = new SAXReader().read(file);
        } else {
            logger.error("没有找到对应注释模板:" + templatePath);
        }

        // 遍历comment 节点
        if (doc != null) {
            for (EnumNode node : EnumNode.values()) {
                Element element = doc.getRootElement().elementByID(node.value());
                if (element != null) {
                    Configuration cfg = new Configuration(Configuration.VERSION_2_3_26);
                    // 字符串清理
                    Template template = new Template(node.value(), element.getText(), cfg);
                    templates.put(node, template);
                }
            }
        }

        // 解析mybatis generator 注释配置
        CommentGeneratorConfiguration config = context.getCommentGeneratorConfiguration();
        if (config != null) {
            this.addConfigurationProperties(config.getProperties());
        }
    } catch (Exception e) {
        logger.error("注释模板XML解析失败!", e);
    }
}
 
Example 11
Source File: HbmBinder.java    From cacheonix-core with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static void bindNamedQuery(Element queryElem, String path, Mappings mappings) {
	String queryName = queryElem.attributeValue( "name" );
	if (path!=null) queryName = path + '.' + queryName;
	String query = queryElem.getText();
	log.debug( "Named query: " + queryName + " -> " + query );

	boolean cacheable = "true".equals( queryElem.attributeValue( "cacheable" ) );
	String region = queryElem.attributeValue( "cache-region" );
	Attribute tAtt = queryElem.attribute( "timeout" );
	Integer timeout = tAtt == null ? null : new Integer( tAtt.getValue() );
	Attribute fsAtt = queryElem.attribute( "fetch-size" );
	Integer fetchSize = fsAtt == null ? null : new Integer( fsAtt.getValue() );
	Attribute roAttr = queryElem.attribute( "read-only" );
	boolean readOnly = roAttr != null && "true".equals( roAttr.getValue() );
	Attribute cacheModeAtt = queryElem.attribute( "cache-mode" );
	String cacheMode = cacheModeAtt == null ? null : cacheModeAtt.getValue();
	Attribute cmAtt = queryElem.attribute( "comment" );
	String comment = cmAtt == null ? null : cmAtt.getValue();

	NamedQueryDefinition namedQuery = new NamedQueryDefinition(
			query,
			cacheable,
			region,
			timeout,
			fetchSize,
			getFlushMode( queryElem.attributeValue( "flush-mode" ) ) ,
			getCacheMode( cacheMode ),
			readOnly,
			comment,
			getParameterTypes(queryElem)
		);

	mappings.addQuery( queryName, namedQuery );
}
 
Example 12
Source File: TraceEvent.java    From pega-tracerviewer with Apache License 2.0 5 votes vote down vote up
private void setInsKey(Element traceEventElement) {

        Element element = traceEventElement.element("EventKey");

        if (element != null) {
            insKey = element.getText();
        } else {
            element = traceEventElement.element("InstanceName");

            if (element != null) {
                insKey = element.getText();
            }
        }

        // flow type has different eventkey, try to get inskey attribute, if
        // available
        if ((insKey != null) && (!"".equals(insKey))) {

            if (!isInstanceHandle(insKey)) {

                Attribute attribute = traceEventElement.attribute("inskey");

                if (attribute != null) {
                    insKey = attribute.getText();
                }
            }
        }

    }
 
Example 13
Source File: RobocupFormat.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private String readNodeCoordinates(Element node) throws MapException {
    Element pointProperty = node.element(Common.GML_POINT_PROPERTY_QNAME);
    if (pointProperty == null) {
        throw new MapException("Couldn't find gml:pointProperty child of node");
    }
    Element point = pointProperty.element(Common.GML_POINT_QNAME);
    if (point == null) {
        throw new MapException("Couldn't find gml:Point child of node");
    }
    Element coords = point.element(Common.GML_COORDINATES_QNAME);
    if (coords == null) {
        throw new MapException("Couldn't find gml:coordinates child of node");
    }
    return coords.getText();
}
 
Example 14
Source File: QTI_varequal.java    From olat with Apache License 2.0 5 votes vote down vote up
/**
 * var equals qti ims 1.2.1 <!ELEMENT varequal (#PCDATA)> <!ATTLIST varequal %I_Case; %I_RespIdent; %I_Index; > mit I_Case = case (Yes | No ) 'No' e.g. <varequal
 * respident = "LID01">A</varequal>
 */
@Override
public boolean eval(final Element boolElement, final ItemContext userContext, final EvalContext ect) {
    final ItemInput iinp = userContext.getItemInput();
    if (iinp.isEmpty()) {
        return false; // user has given no answer
    }
    final String respident = boolElement.attributeValue("respident");
    final String yescase = boolElement.attributeValue("case");
    final boolean caseimp = (yescase == null) ? true : yescase.equals("Yes"); // make it compatible with faulty QTI documentation
    final String shouldVal = boolElement.getText(); // the answer is tested against content of elem.
    final boolean ok = (caseimp ? iinp.contains(respident, shouldVal) : iinp.containsIgnoreCase(respident, shouldVal));
    return ok;
}
 
Example 15
Source File: TraceEventAlert.java    From pega-tracerviewer with Apache License 2.0 5 votes vote down vote up
@Override
protected void setStatus(Element traceEventElement) {
    String status = "";

    Element element = traceEventElement.element("EventType");

    if (element != null) {
        status = element.getText();
    }

    setStatus(status);
}
 
Example 16
Source File: TraceEvent.java    From pega-tracerviewer with Apache License 2.0 4 votes vote down vote up
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);
            }
        }
    }
 
Example 17
Source File: XmlUtil.java    From fixflow with Apache License 2.0 4 votes vote down vote up
public static String getElementText(Element element){
	String result = null;
	if(element!=null)
		result = element.getText();
	return result;
}
 
Example 18
Source File: TraceEvent.java    From pega-tracerviewer with Apache License 2.0 3 votes vote down vote up
protected void setEventType(Element traceEventElement) {

        String eventType = null;

        Element element = traceEventElement.element("EventType");

        if (element != null) {
            eventType = element.getText();
        }

        setEventType(eventType);
    }
 
Example 19
Source File: CT_Path.java    From ofdrw with Apache License 2.0 2 votes vote down vote up
/**
 * 【必选】
 * 获取 图形轮廓数据
 * <p>
 * 由一系列紧缩的操作符和操作数构成
 *
 * @return 图形轮廓数据字符串
 */
public String getAbbreviatedData() {
    Element e = this.getOFDElement("AbbreviatedData");
    return e == null ? null : e.getText();
}
 
Example 20
Source File: Annot.java    From ofdrw with Apache License 2.0 2 votes vote down vote up
/**
 * 【可选】
 * 获取 注释说明内容
 *
 * @return 注释说明内容
 */
public String getRemark() {
    Element e = this.getOFDElement("Remark");
    return e == null ? null : e.getText();
}