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


Java Element类代码示例

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


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

示例1: getConfig

import org.jdom2.Element; //导入依赖的package包/类
/**
 * 获取指定名称的Config配置
 * @return
 */
public Map<String,String> getConfig(String name) {
    Element rootEle = doc.getRootElement();
    Element elements = rootEle.getChild(name);

    Map<String,String> configMap = new HashMap<String, String>();
    if (elements != null) {
        List<Element> childElementList = elements.getChildren();
        for(Element childElement : childElementList) {
            String lname = childElement.getName();
            String lvalue = childElement.getValue();

            configMap.put(lname, lvalue);
        }
    }

    return configMap;
}
 
开发者ID:ninelook,项目名称:wecard-server,代码行数:22,代码来源:ConfigHandler.java

示例2: generatePageDocument_shouldCreateALTOFileFromTEICorrectly

import org.jdom2.Element; //导入依赖的package包/类
/**
 * @see MetsIndexer#generatePageDocument(Element,String,Integer,ISolrWriteStrategy,Map)
 * @verifies create ALTO file from TEI correctly
 */
@Test
public void generatePageDocument_shouldCreateALTOFileFromTEICorrectly() throws Exception {
    Map<String, Path> dataFolders = new HashMap<>();
    Path altoPath = Paths.get("build/viewer/alto/PPN517154005");
    Utils.checkAndCreateDirectory(altoPath);
    Assert.assertTrue(Files.isDirectory(altoPath));
    dataFolders.put(DataRepository.PARAM_ALTO_CONVERTED, altoPath);
    dataFolders.put(DataRepository.PARAM_TEIWC, Paths.get("resources/test/METS/kleiuniv_PPN517154005/kleiuniv_PPN517154005_wc"));

    MetsIndexer indexer = new MetsIndexer(hotfolder);
    indexer.initJDomXP(metsFile);
    String xpath = "/mets:mets/mets:structMap[@TYPE=\"PHYSICAL\"]/mets:div/mets:div";
    List<Element> eleStructMapPhysicalList = indexer.xp.evaluateToElements(xpath, null);
    ISolrWriteStrategy writeStrategy = new LazySolrWriteStrategy(solrHelper);
    IDataRepositoryStrategy dataRepositoryStrategy = new SingleRepositoryStrategy(Configuration.getInstance());

    int page = 1;
    Assert.assertTrue(indexer.generatePageDocument(eleStructMapPhysicalList.get(page - 1), String.valueOf(MetsIndexer.getNextIddoc(hotfolder
            .getSolrHelper())), PI, page, writeStrategy, dataFolders, dataRepositoryStrategy.selectDataRepository(PI, metsFile, dataFolders,
                    solrHelper)[0]));
    SolrInputDocument doc = writeStrategy.getPageDocForOrder(page);
    Assert.assertNotNull(doc);

    Assert.assertTrue(Files.isRegularFile(Paths.get(altoPath.toAbsolutePath().toString(), "00000001.xml")));
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:30,代码来源:MetsIndexerTest.java

示例3: parsePotionEffects

import org.jdom2.Element; //导入依赖的package包/类
public List<PotionEffect> parsePotionEffects(Element el) throws InvalidXMLException {
    List<PotionEffect> effects = new ArrayList<>();

    Node attr = Node.fromAttr(el, "effect", "effects", "potions");
    if(attr != null) {
        for(String piece : attr.getValue().split(";")) {
            effects.add(checkPotionEffect(XMLUtils.parseCompactPotionEffect(attr, piece), attr));
        }
    }

    for(Element elPotion : XMLUtils.getChildren(el, "effect", "potion")) {
        effects.add(parsePotionEffect(elPotion));
    }

    return effects;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:GlobalItemParser.java

示例4: containsClinicalDocumentTemplateId

import org.jdom2.Element; //导入依赖的package包/类
private boolean containsClinicalDocumentTemplateId(Element rootElement) {
	boolean containsTemplateId = false;

	List<Element> clinicalDocumentChildren = rootElement.getChildren(TEMPLATE_ID,
																		rootElement.getNamespace());

	for (Element currentChild : clinicalDocumentChildren) {
		final String root = currentChild.getAttributeValue(ROOT_STRING);
		final String extension = currentChild.getAttributeValue(EXTENSION_STRING);

		if (TemplateId.getTemplateId(root, extension, context) == TemplateId.CLINICAL_DOCUMENT) {
			containsTemplateId = true;
			break;
		}
	}
	return containsTemplateId;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:18,代码来源:QrdaXmlDecoder.java

示例5: parse

import org.jdom2.Element; //导入依赖的package包/类
public static MobsModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    FilterParser filterParser = context.needModule(FilterParser.class);
    Element mobsEl = doc.getRootElement().getChild("mobs");
    Filter mobsFilter = StaticFilter.DENY;
    if(mobsEl != null) {
        if(context.getProto().isNoOlderThan(ProtoVersions.FILTER_FEATURES)) {
            mobsFilter = filterParser.parseProperty(mobsEl, "filter");
        } else {
            Element filterEl = XMLUtils.getUniqueChild(mobsEl, "filter");
            if(filterEl != null) {
                mobsFilter = filterParser.parseElement(filterEl);
            }
        }
    }
    return new MobsModule(mobsFilter);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:17,代码来源:MobsModule.java

示例6: readMesasurementFilesFromSafe

import org.jdom2.Element; //导入依赖的package包/类
public void readMesasurementFilesFromSafe() {
	XPathExpression<Element> expr = xFactory
			.compile(
					"/xfdu:XFDU/dataObjectSection/dataObject[@repID='s1Level1ProductSchema']/byteStream/fileLocation",
					Filters.element(), null, xfdu);

	List<Element> values = expr.evaluate(safe);
	this.measurements=new File[values.size()];
	
	String measurementPath = safefile.getParent() + "/measurement";

	for (int i = 0; i < values.size(); i++) {
		Element e = values.get(i);
		String href = e.getAttributeValue("href");
		if (href.startsWith("./"))
			href = href.substring(2);
		measurements[i] = new File(measurementPath + "/" + href);
		System.out.println(measurements[i]);
	}

}
 
开发者ID:ec-europa,项目名称:sumo,代码行数:22,代码来源:SumoXPathSafeReader.java

示例7: doPost

import org.jdom2.Element; //导入依赖的package包/类
public void doPost(MCRServletJob job) throws Exception {
	Element output = new Element("userLogging");
	String username = getParameter(job, "username");
	String password = getParameter(job, "password");
	boolean rememberMe = "true".equals(getParameter(job, "rememberMe"));

	boolean b = false;
	if (username == null)
		output.addContent((new Element("message")).addContent("login.message.noUserGiven"));

	else if (password == null)
		output.addContent((new Element("message")).addContent("login.message.noPasswordGiven"));

	else {
		b = tryLogin(username, password, rememberMe);
		if (b) {
			SavedRequest savedRequest = WebUtils.getAndClearSavedRequest(job.getRequest());
			if (savedRequest != null)
				job.getResponse().sendRedirect(savedRequest.getRequestUrl());
			else
				job.getResponse().sendRedirect("analysis/start");
		} else
			output.addContent((new Element("message")).addContent("login.message.loginFailed"));
	}
	sendOutput(job, output);
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:27,代码来源:UserLoggingServlet.java

示例8: objectToString

import org.jdom2.Element; //导入依赖的package包/类
/**
 * Returns the string value of the given XML node object, depending on its type.
 * 
 * @param object
 * @return String
 */
public static String objectToString(Object object) {
    if (object instanceof Element) {
        return ((Element) object).getText();
    } else if (object instanceof Attribute) {
        return ((Attribute) object).getValue();
    } else if (object instanceof Text) {
        return ((Text) object).getText();
    } else if (object instanceof CDATA) {
        return ((CDATA) object).getText();
    } else if (object instanceof Comment) {
        return ((Comment) object).getText();
    } else if (object instanceof Double) {
        return String.valueOf(object);
    } else if (object instanceof Boolean) {
        return String.valueOf(object);
    } else if (object instanceof String) {
        return (String) object;
    } else if (object != null) {
        logger.error("Unknown object type: {}", object.getClass().getName());
        return null;
    } else {
        return null;
    }

}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:32,代码来源:JDomXP.java

示例9: prepareDocumentationElement

import org.jdom2.Element; //导入依赖的package包/类
private Element prepareDocumentationElement(Namespace rootns) {
	Element documentationOf = new Element("documentationOf", rootns);
	Element serviceEvent = new Element("serviceEvent", rootns);
	Element performer = new Element("performer", rootns);
	Element assignedEntity = new Element("assignedEntity", rootns);
	Element nationalProviderIdentifier = new Element("id", rootns)
			.setAttribute("root", "2.16.840.1.113883.4.6")
			.setAttribute("extension", "2567891421");

	Element representedOrganization = prepareRepOrgWithTaxPayerId(rootns);
	assignedEntity.addContent(representedOrganization);
	assignedEntity.addContent(nationalProviderIdentifier);
	performer.addContent(assignedEntity);
	serviceEvent.addContent(performer);
	documentationOf.addContent(serviceEvent);
	return documentationOf;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:18,代码来源:ClinicalDocumentDecoderTest.java

示例10: parseLegacyTimeLimit

import org.jdom2.Element; //导入依赖的package包/类
private @Nullable TimeLimitDefinition parseLegacyTimeLimit(MapModuleContext context, Element el, String legacyTag, TimeLimitDefinition oldTimeLimit) throws InvalidXMLException {
    el = el.getChild(legacyTag);
    if(el != null) {
        TimeLimitDefinition newTimeLimit = parseTimeLimit(el);
        if(newTimeLimit != null) {
            if(context.getProto().isNoOlderThan(ProtoVersions.REMOVE_SCORE_TIME_LIMIT)) {
                throw new InvalidXMLException("<time> inside <" + legacyTag + "> is no longer supported, use root <time> instead", el);
            }
            if(oldTimeLimit != null) {
                throw new InvalidXMLException("Time limit conflicts with another one that is already defined", el);
            }
            return newTimeLimit;
        }
    }

    return oldTimeLimit;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:18,代码来源:TimeLimitModule.java

示例11: setSimpleData

import org.jdom2.Element; //导入依赖的package包/类
/**
 * Sets TYPE and LABEL from the LIDO document.
 * 
 * @param indexObj {@link IndexObject}
 * @throws FatalIndexerException
 */
private void setSimpleData(IndexObject indexObj) throws FatalIndexerException {
    Element structNode = indexObj.getRootStructNode();

    // Set type
    List<String> values = xp.evaluateToStringList(
            "lido:descriptiveMetadata/lido:objectClassificationWrap/lido:objectWorkTypeWrap/lido:objectWorkType/lido:term/text()", structNode);
    if (values != null && !values.isEmpty()) {
        indexObj.setType(MetadataConfigurationManager.mapDocStrct((values.get(0)).trim()));
    }
    logger.trace("TYPE: {}", indexObj.getType());

    // Set label
    {
        String value = structNode.getAttributeValue("LABEL");
        if (value != null) {
            indexObj.setLabel(value);
        }
    }
    logger.trace("LABEL: {}", indexObj.getLabel());
}
 
开发者ID:intranda,项目名称:goobi-viewer-indexer,代码行数:27,代码来源:LidoIndexer.java

示例12: parse

import org.jdom2.Element; //导入依赖的package包/类
public static GameRulesModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    Map<GameRule, Boolean> gameRules = new HashMap<>();

    for (Element gameRulesElement : doc.getRootElement().getChildren("gamerules")) {
        for (Element gameRuleElement : gameRulesElement.getChildren()) {
            GameRule gameRule = GameRule.forName(gameRuleElement.getName());
            String value = gameRuleElement.getValue();

            if (gameRule == null) {
                throw new InvalidXMLException(gameRuleElement.getName() + " is not a valid gamerule", gameRuleElement);
            }
            if (value == null) {
                throw new InvalidXMLException("Missing value for gamerule " + gameRule.getValue(), gameRuleElement);
            } else if (!(value.equalsIgnoreCase("true") || value.equalsIgnoreCase("false"))) {
                throw new InvalidXMLException(gameRuleElement.getValue() + " is not a valid gamerule value", gameRuleElement);
            }
            if (gameRules.containsKey(gameRule)){
                throw new InvalidXMLException(gameRule.getValue() + " has already been specified", gameRuleElement);
            }

            gameRules.put(gameRule, Boolean.valueOf(value));
        }
    }
    return new GameRulesModule(gameRules);
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:26,代码来源:GameRulesModule.java

示例13: createArticleFromCrossRefSingle

import org.jdom2.Element; //导入依赖的package包/类
/**
 * this is called if singleElement consists of one crossRef element
 *
 * @param crossRefElement the element that every one of multipleResults is
 * compared with
 * @return Article created from crossRefElement
 */
private Article createArticleFromCrossRefSingle(Element crossRefElement) {
    Article art = new Article();
    // extract title
    String title = crossRefElement.getChild("mods", modsNS)
            .getChild("titleInfo", modsNS)
            .getChild("title", modsNS)
            .getText();
    art.setTitle(title);

    // extract authors
    // format: SURNAME, GIVEN-NAME
    List<Element> authorElements = crossRefElement.getChild("mods", modsNS)
            .getChildren("name", modsNS);
    for (Element authorElement : authorElements) {
        art.addAuthor(authorElement.getChild("displayForm", modsNS).getText());
    }
    return art;
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:26,代码来源:ExportComparator.java

示例14: buildByAffilID

import org.jdom2.Element; //导入依赖的package包/类
public static Institution buildByAffilID(String id) {
	if (!id.isEmpty()) {
	Institution institution = new Institution(id);
	
	//prepare the file of exported data
	File outputFile = new File(affiliationsDir, "scopus_affiliationExport_" + id + ".xml");
	
	//get the affiliation export from scopus, either from a file on disk or from the api.
	Element affilData;
	try {
		affilData = new SAXBuilder().build(outputFile).detachRootElement().clone();
	} catch (JDOMException | IOException e) {
		ScopusConnector connector = new ScopusConnector();
		LOGGER.info("Retrieving AffilData for affilID" + id + " from Scopus.");
		try {
			affilData = connector.getAffiliationProfile(id).asXML().detachRootElement().clone();
		} catch (JDOMException | IOException | SAXException e1) {
			LOGGER.info("could not get scopus response.");
			affilData = new Element("error")
					.addContent(new Element("status").setText("could not get scopus response"));
		}
	}
	
	//if no errors occurred, build the institution from the obtained data.
	if (affilData.getChild("status") == null) {
		//build institution with the scopus data
		//if geo-coordinates are present, they have been transferred into the institution as well. 
		addDataFromScopusProfile(affilData, "full", institution);
	}
	return institution;
	} else return null;
}
 
开发者ID:ETspielberg,项目名称:bibliometrics,代码行数:33,代码来源:InstitutionBuilder.java

示例15: internalDecode

import org.jdom2.Element; //导入依赖的package包/类
@Override
protected DecodeResult internalDecode(Element element, Node thisnode) {
	DEV_LOG.debug("Default decoder {} is handling templateId {} and is described as '{}' ",
			getClass(), thisnode.getType().name(), description);
	thisnode.putValue("DefaultDecoderFor", description);
	return DecodeResult.TREE_CONTINUE;
}
 
开发者ID:CMSgov,项目名称:qpp-conversion-tool,代码行数:8,代码来源:DefaultDecoder.java


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