当前位置: 首页>>代码示例>>Java>>正文


Java ElementFilter类代码示例

本文整理汇总了Java中org.jdom2.filter.ElementFilter的典型用法代码示例。如果您正苦于以下问题:Java ElementFilter类的具体用法?Java ElementFilter怎么用?Java ElementFilter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ElementFilter类属于org.jdom2.filter包,在下文中一共展示了ElementFilter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: loopxml

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
/**
 * Method of going through OWL structure
 */
public void loopxml() {
  Iterator<?> processDescendants = rootNode.getDescendants(new ElementFilter());
  String text = "";

  while (processDescendants.hasNext()) {
    Element e = (Element) processDescendants.next();
    String currentName = e.getName();
    text = e.getTextTrim();
    if ("".equals(text)) {
      LOG.info(currentName);
    } else {
      LOG.info("{} : {}", currentName, text);
    }
  }
}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:19,代码来源:AggregateTriples.java

示例2: findChild

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
/**
 * Method of identifying a specific child given a element name
 *
 * @param str element name
 * @param ele parent element
 * @return the element of child
 */
public Element findChild(String str, Element ele) {
  Iterator<?> processDescendants = ele.getDescendants(new ElementFilter());
  String name = "";
  Element result = null;

  while (processDescendants.hasNext()) {
    Element e = (Element) processDescendants.next();
    name = e.getName();
    if (name.equals(str)) {
      result = e;
      return result;
    }
  }
  return result;

}
 
开发者ID:apache,项目名称:incubator-sdap-mudrod,代码行数:24,代码来源:AggregateTriples.java

示例3: open

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
@Override
public void open(ExecutionContext executionContext) throws ItemStreamException {
    ResponseEntity<String> response = restTemplate.getForEntity(uri, String.class);
    if (!response.getStatusCode().equals(HttpStatus.OK)) {
        throw new ItemStreamException(response.getStatusCode() + " HTTP response is returned");
    }
    ;
    MediaType type = response.getHeaders().getContentType();
    if (MediaType.APPLICATION_XML.equals(type) ||
            MediaType.APPLICATION_ATOM_XML.equals(type) ||
            MediaType.APPLICATION_XHTML_XML.equals(type) ||
            MediaType.APPLICATION_RSS_XML.equals(type) ||
            "text/xml".equals(type.toString())) {
        SAXBuilder jdomBuilder = new SAXBuilder();
        try {
            Document document = jdomBuilder.build(new StringReader(response.getBody()));
            ElementFilter ef = new ElementFilter(aggregateRecordElement);
            aggregateRecordElementItr = document.getRootElement().getDescendants(ef);
        } catch (Exception ex) {
            throw new ItemStreamException(ex);
        }
    }
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:24,代码来源:HttpXmlItemReader.java

示例4: getFirstImageSource

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
private ImageResource getFirstImageSource(Resource CoverPageResource, Resources resources)
{
    try
    {
        Document titlePageDocument = ResourceUtil.getAsDocument(CoverPageResource);
        Filter<Element> imgFilter = new ElementFilter("img");
        List<Element> imageElements = titlePageDocument.getRootElement().getContent(imgFilter);
        for (Element imageElement : imageElements)
        {
            String relativeImageHref = imageElement.getAttributeValue("src");
            String absoluteImageHref = calculateAbsoluteImageHref(relativeImageHref, CoverPageResource.getHref());
            ImageResource imageResource = (ImageResource)resources.getByHref(absoluteImageHref);
            if (imageResource != null)
            {
                return imageResource;
            }
        }
    }
    catch (Exception e)
    {
        log.error(e.getMessage(), e);
    }
    return null;
}
 
开发者ID:finanzer,项目名称:epubfx,代码行数:25,代码来源:CoverpageBookProcessor.java

示例5: shouldRemoveAllLuauConfigurationFromConfig

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
@Test
public void shouldRemoveAllLuauConfigurationFromConfig() throws Exception {
    String configString =
            "<cruise schemaVersion='66'>"
                    + "<server siteUrl='https://hostname'>"
                    + "<security>"
                    + "      <luau url='https://luau.url.com' clientKey='0d010cf97ec505ee3788a9b5b8cf71d482c394ae88d32f0333' authState='authorized' />"
                    + "      <ldap uri='ldap' managerDn='managerDn' encryptedManagerPassword='+XhtUNvVAxJdHGF4qQGnWw==' searchFilter='(sAMAccountName={0})'>"
                    + "        <bases>"
                    + "          <base value='ou=Enterprise,ou=Principal,dc=corporate,dc=thoughtworks,dc=com' />"
                    + "        </bases>"
                    + "      </ldap>"
                    + "      <roles>"
                    + "         <role name='luau-role'><groups><luauGroup>luau-group</luauGroup></groups></role>"
                    + "         <role name='ldap-role'><users><user>some-user</user></users></role>"
                    + "</roles>"
                    + "</security>"
                    + "</server>"
                    + "</cruise>";

    String migratedContent = migrateXmlString(configString, 66);
    Document document = new SAXBuilder().build(new StringReader(migratedContent));

    assertThat(document.getDescendants(new ElementFilter("luau")).hasNext(), is(false));
    assertThat(document.getDescendants(new ElementFilter("groups")).hasNext(), is(false));
}
 
开发者ID:gocd,项目名称:gocd,代码行数:27,代码来源:GoConfigMigrationIntegrationTest.java

示例6: toJSON

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
public JsonArray toJSON(Element rootElement) {
    JsonArray sectionArray = new JsonArray();
    for (Element section : rootElement.getChildren(MyCoReWebPageProvider.XML_SECTION)) {
        // get infos of element
        String title = section.getAttributeValue(MyCoReWebPageProvider.XML_TITLE);
        String lang = section.getAttributeValue(MyCoReWebPageProvider.XML_LANG, Namespace.XML_NAMESPACE);
        String data = null;
        if (section.getContent(new ElementFilter()).size() > 1) {
            Element div = new Element("div");
            while (section.getChildren().size() > 0) {
                div.addContent(section.getChildren().get(0).detach());
            }
            section.addContent(div);
        }
        try {
            data = getContent(section);
        } catch (IOException ioExc) {
            LOGGER.error("while reading section data.", ioExc);
            continue;
        }

        // create json object
        JsonObject jsonObject = new JsonObject();
        if (title != null && !title.equals("")) {
            jsonObject.addProperty(JSON_TITLE, title);
        }
        if (lang != null && !lang.equals("")) {
            jsonObject.addProperty(JSON_LANG, lang);
        }
        String invalidElementName = validateElement(section);
        if (invalidElementName != null) {
            jsonObject.addProperty("hidden", "true");
            jsonObject.addProperty("invalidElement", invalidElementName);
        }
        jsonObject.addProperty(JSON_DATA, data);
        // add to array
        sectionArray.add(jsonObject);
    }
    return sectionArray;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:41,代码来源:MCRWCMSDefaultSectionProvider.java

示例7: buildFormQuery

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
/**
 * Build MCRQuery from editor XML input
 */
public static MCRQuery buildFormQuery(Element root) {
    Element conditions = root.getChild("conditions");

    if (conditions.getAttributeValue("format", "xml").equals("xml")) {
        Element condition = conditions.getChildren().get(0);
        renameElements(condition);

        // Remove conditions without values
        List<Element> empty = new ArrayList<>();
        for (Iterator<Element> it = conditions.getDescendants(new ElementFilter("condition")); it.hasNext();) {
            Element cond = it.next();
            if (cond.getAttribute("value") == null) {
                empty.add(cond);
            }
        }

        // Remove empty sort conditions
        Element sortBy = root.getChild("sortBy");
        if (sortBy != null) {
            for (Element field : sortBy.getChildren("field")) {
                if (field.getAttributeValue("name", "").length() == 0) {
                    empty.add(field);
                }
            }
        }

        for (int i = empty.size() - 1; i >= 0; i--) {
            empty.get(i).detach();
        }

        if (sortBy != null && sortBy.getChildren().size() == 0) {
            sortBy.detach();
        }
    }

    return MCRQuery.parseXML(root.getDocument());
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:41,代码来源:MCRQLSearchUtils.java

示例8: parseNmasUserResponseXML

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
static ChallengeSet parseNmasUserResponseXML( final String str )
        throws IOException, JDOMException, ChaiValidationException
{
    final List<Challenge> returnList = new ArrayList<Challenge>();

    final Reader xmlreader = new StringReader( str );
    final SAXBuilder builder = new SAXBuilder();
    final Document doc = builder.build( xmlreader );

    final Element rootElement = doc.getRootElement();
    final int minRandom = StringHelper.convertStrToInt( rootElement.getAttributeValue( "RandomQuestions" ), 0 );

    final String guidValue;
    {
        final Attribute guidAttribute = rootElement.getAttribute( "GUID" );
        guidValue = guidAttribute == null ? null : guidAttribute.getValue();
    }

    for ( Iterator iter = doc.getDescendants( new ElementFilter( "Challenge" ) ); iter.hasNext(); )
    {
        final Element loopQ = ( Element ) iter.next();
        final int maxLength = StringHelper.convertStrToInt( loopQ.getAttributeValue( "MaxLength" ), 255 );
        final int minLength = StringHelper.convertStrToInt( loopQ.getAttributeValue( "MinLength" ), 2 );
        final String defineStrValue = loopQ.getAttributeValue( "Define" );
        final boolean adminDefined = "Admin".equalsIgnoreCase( defineStrValue );
        final String typeStrValue = loopQ.getAttributeValue( "Type" );
        final boolean required = "Required".equalsIgnoreCase( typeStrValue );
        final String challengeText = loopQ.getText();

        final Challenge challenge = new ChaiChallenge( required, challengeText, minLength, maxLength, adminDefined, 0, false );
        returnList.add( challenge );
    }

    return new ChaiChallengeSet( returnList, minRandom, null, guidValue );
}
 
开发者ID:ldapchai,项目名称:ldapchai,代码行数:36,代码来源:NmasResponseSet.java

示例9: prepareUserInputdata

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
/**
 * Prepares the user input by replacing the variables in the xml (masked
 * values).
 */
public void prepareUserInputdata() {
	IteratorIterable<Element> cIterator = xmlMetaDataDoc
			.getDescendants(new ElementFilter());
	String lineValue;
	String inputRegEx = INPUT_REG_EX;
	if (cIterator != null) {
		while (cIterator.hasNext()) {
			lineValue = cIterator.next().getValue();
			if (lineValue.matches(inputRegEx)) {
				addKeyValueToHashMap(lineValue);
			}
		}
	}
}
 
开发者ID:lbirajdar,项目名称:RaAuto,代码行数:19,代码来源:UserInputContainer.java

示例10: selectElement

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
/****************************************************************************/

    public static Element selectElement(Document doc, String path) {
        XPathExpression<Element> expression =
                XPathFactory.instance().compile(path, new ElementFilter());
        return expression.evaluateFirst(doc);
    }
 
开发者ID:yawlfoundation,项目名称:yawl,代码行数:8,代码来源:JDOMUtil.java

示例11: updateXDSMLDefinitionInExtensionPoint

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
public Element updateXDSMLDefinitionInExtensionPoint(Element extensionPoint, String xDSMLName){
	Element result;
	List<Element> elements = extensionPoint.getContent(new ElementFilter(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT_XDSML_DEF));
	if(elements.size() == 0){
		// create extension point
		result = new Element(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT_XDSML_DEF);
		extensionPoint.addContent(result);
	}
	else{
		result = elements.get(0);
	}
	result.setAttribute("name", xDSMLName);
	return result;
}
 
开发者ID:SiriusLab,项目名称:ModelDebugging,代码行数:15,代码来源:PluginXMLHelper.java

示例12: updateXDSMLDefinitionAttributeInExtensionPoint

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
public Element updateXDSMLDefinitionAttributeInExtensionPoint(Element extensionPoint, String atributeName, String value){
	Element result;
	List<Element> elements = extensionPoint.getContent(new ElementFilter(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT_XDSML_DEF));
	if(elements.size() == 0){
		// create extension point
		result = new Element(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT_XDSML_DEF);
		extensionPoint.addContent(result);
	}
	else{
		result = elements.get(0);
	}
	result.setAttribute(atributeName, value);
	return result;
}
 
开发者ID:SiriusLab,项目名称:ModelDebugging,代码行数:15,代码来源:PluginXMLHelper.java

示例13: getXDSMLDefinitionAttributeInExtensionPointValue

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
public String getXDSMLDefinitionAttributeInExtensionPointValue(Element extensionPoint, String atributeName){
	Element result;
	List<Element> elements = extensionPoint.getContent(new ElementFilter(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT_XDSML_DEF));
	if(elements.size() == 0){
		// create extension point
		result = new Element(LanguageDefinitionExtensionPoint.GEMOC_LANGUAGE_EXTENSION_POINT_XDSML_DEF);
		extensionPoint.addContent(result);
	}
	else{
		result = elements.get(0);
	}
	return result.getAttributeValue(atributeName);
}
 
开发者ID:SiriusLab,项目名称:ModelDebugging,代码行数:14,代码来源:PluginXMLHelper.java

示例14: removeNamespaces

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
protected Map<Element, Namespace> removeNamespaces(Document document) {
    Map<Element, Namespace> namespaces = new HashMap<Element, Namespace>();
    if (ignoreNamespace && document.hasRootElement()) {
        namespaces.put(document.getRootElement(), document.getRootElement().getNamespace());
        document.getRootElement().setNamespace(null);
        for (Element el : document.getRootElement().getDescendants(new ElementFilter())) {
            Namespace nsp = el.getNamespace();
            if (nsp != null) {
                el.setNamespace(null);
                namespaces.put(el, nsp);
            }
        }
    }
    return namespaces;
}
 
开发者ID:JumpMind,项目名称:metl,代码行数:16,代码来源:AbstractXMLComponentRuntime.java

示例15: decodeGSEControlBlock

import org.jdom2.filter.ElementFilter; //导入依赖的package包/类
void decodeGSEControlBlock(String appID_name) throws IEC61850_GOOSE_Exception
{	
	boolean found_GSEControlBlock = false;
	
	// Retrieves all elements named "GSEControl" within IED node
	Filter<Element> elementFilter = new ElementFilter("GSEControl");
	
	// Search for a GSEControl block with a matching appID
	for (Iterator<Element> GSEControl_IT = IED_section.getDescendants(elementFilter);
			GSEControl_IT.hasNext();)
	{
		Element current_element = GSEControl_IT.next();
		
		if(current_element.getAttributeValue("type").equals("GOOSE") && 
				current_element.getAttributeValue("appID").equals(appID_name))
		{
			// We found the right control block
			GSEControl_node =  current_element;
			found_GSEControlBlock = true;
		}
	}
	
	if (found_GSEControlBlock == false)
		throw new IEC61850_GOOSE_Exception("<GSEControl> Block with corresponding appID_name: " + appID_name + " name not found in <IED>");
	
	gseControlBlockAppIDName = GSEControl_node.getAttributeValue("appID");
	gseControlBlockName = GSEControl_node.getAttributeValue("name");
	gseControlBlockConfRev = GSEControl_node.getAttributeValue("confRev");
	gseControlBlockDatSet = GSEControl_node.getAttributeValue("datSet");
	
	ln0ClassName = GSEControl_node.getParentElement().getAttributeValue("lnClass");

	return;
}
 
开发者ID:pvenne,项目名称:jgoose,代码行数:35,代码来源:IEC61850_GOOSE_ICD_file.java


注:本文中的org.jdom2.filter.ElementFilter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。