Java 类org.jdom2.Element 实例源码

项目:wecard-server    文件:ConfigHandler.java   
/**
 * 获取指定名称的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;
}
项目:goobi-viewer-indexer    文件:MetsIndexerTest.java   
/**
 * @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")));
}
项目:ProjectAres    文件:GlobalItemParser.java   
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;
}
项目:qpp-conversion-tool    文件:QrdaXmlDecoder.java   
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;
}
项目:ProjectAres    文件:MobsModule.java   
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);
}
项目:sumo    文件:SumoXPathSafeReader.java   
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]);
    }

}
项目:bibliometrics    文件:UserLoggingServlet.java   
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);
}
项目:goobi-viewer-indexer    文件:JDomXP.java   
/**
 * 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;
    }

}
项目:qpp-conversion-tool    文件:ClinicalDocumentDecoderTest.java   
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;
}
项目:ProjectAres    文件:TimeLimitModule.java   
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;
}
项目:goobi-viewer-indexer    文件:LidoIndexer.java   
/**
 * 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());
}
项目:ProjectAres    文件:GameRulesModule.java   
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);
}
项目:bibliometrics    文件:ExportComparator.java   
/**
 * 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;
}
项目:bibliometrics    文件:InstitutionBuilder.java   
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;
}
项目:qpp-conversion-tool    文件:DefaultDecoder.java   
@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;
}
项目:goobi-viewer-connector    文件:XMLGeneration.java   
/**
 * for the server request ?verb=Identify this method build the xml section in the Identify element
 * 
 * @return the identify Element for the xml tree
 * @throws SolrServerException
 */
public Element getIdentifyXML() throws SolrServerException {
    // TODO: optional parameter: compression is not implemented
    // TODO: optional parameter: description is not implemented
    Namespace xmlns = DataManager.getInstance().getConfiguration().getStandardNameSpace();
    Map<String, String> identifyTags = DataManager.getInstance().getConfiguration().getIdentifyTags();
    Element identify = new Element("Identify", xmlns);

    Element repositoryName = new Element("repositoryName", xmlns);
    repositoryName.setText(identifyTags.get("repositoryName"));
    identify.addContent(repositoryName);

    Element baseURL = new Element("baseURL", xmlns);
    baseURL.setText(identifyTags.get("baseURL"));
    identify.addContent(baseURL);

    Element protocolVersion = new Element("protocolVersion", xmlns);
    protocolVersion.setText(identifyTags.get("protocolVersion"));
    identify.addContent(protocolVersion);

    // TODO: protocol definition allow more than one email adress, change away from HashMap
    Element adminEmail = new Element("adminEmail", xmlns);
    adminEmail.setText(identifyTags.get("adminEmail")); //
    identify.addContent(adminEmail);

    Element earliestDatestamp = new Element("earliestDatestamp", xmlns);
    earliestDatestamp.setText(solr.getEarliestRecordDatestamp());
    identify.addContent(earliestDatestamp);

    Element deletedRecord = new Element("deletedRecord", xmlns);
    deletedRecord.setText(identifyTags.get("deletedRecord"));
    identify.addContent(deletedRecord);

    Element granularity = new Element("granularity", xmlns);
    granularity.setText(identifyTags.get("granularity"));
    identify.addContent(granularity);

    return identify;
}
项目:ProjectAres    文件:TutorialParser.java   
private List<String> parseMessage(Element stageEl) {
    ImmutableList.Builder<String> builder = ImmutableList.builder();

    Element messageEl = stageEl.getChild("message");
    if(messageEl != null) {
        for(Element lineEl : messageEl.getChildren("line")) {
            builder.add(BukkitUtils.colorize(lineEl.getText()));
        }
    }

    return builder.build();
}
项目:ProjectAres    文件:XMLUtils.java   
public static String getNullableAttribute(Element el, String...attrs) {
    String text = null;
    for(String attr : attrs) {
        text = el.getAttributeValue(attr);
        if(text != null) break;
    }
    return text;
}
项目:ProjectAres    文件:XMLUtils.java   
public static Pair<org.bukkit.attribute.Attribute, AttributeModifier> parseAttributeModifier(Element el) throws InvalidXMLException {
    return Pair.create(
        parseAttribute(new Node(el)),
        new AttributeModifier(
            "FromXML",
            parseNumber(Node.fromRequiredAttr(el, "amount"), Double.class),
            parseAttributeOperation(Node.fromAttr(el, "operation"), AttributeModifier.Operation.ADD_NUMBER)
        )
    );
}
项目:ProjectAres    文件:FeatureDefinitionContext.java   
public <T extends FeatureDefinition> T define(@Nullable Element source, @Nullable String id, Class<T> type, T impl) throws InvalidXMLException {
    if(id != null && !type.isInterface()) {
        // Can't proxy a non-interface type, so no references and no IDs
        throw new IllegalArgumentException("Cannot assign an ID to a " + impl.getFeatureName());
    }
    return define(source, id, impl).direct();
}
项目:ctsms    文件:ClamlImporter.java   
private void parseModifiers(Element root) {
    Iterator<Element> it = root.getChildren(ClamlConstants.MODIFIER_ELEMENT).iterator();
    long count = 0l;
    while (it.hasNext()) {
        String code = it.next().getAttributeValue(ClamlConstants.CODE_ATTR);
        if (!CommonUtil.isEmptyString(code)) {
            modifierClasses.put(code, new HashMap<String, Element>());
            count++;
        } else {
            throw new IllegalArgumentException(ClamlConstants.MODIFIER_ELEMENT + " " + ClamlConstants.CODE_ATTR + " empty");
        }
    }
    jobOutput.println(ClamlConstants.MODIFIER_ELEMENT + ": " + count + " elements");
}
项目:ProjectAres    文件:FilterDefinitionParser.java   
@MethodParser("class")
public PlayerClassFilter parseClass(Element el) throws InvalidXMLException {
    final PlayerClass playerClass = StringUtils.bestFuzzyMatch(el.getTextNormalize(), classModule.get().getPlayerClasses(), 0.9);
    if (playerClass == null) {
        throw new InvalidXMLException("Could not find player-class: " + el.getTextNormalize(), el);
    }

    return new PlayerClassFilter(playerClass);
}
项目:ProjectAres    文件:WorldBorderModule.java   
public static WorldBorderModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
    List<WorldBorder> borders = new ArrayList<>();
    for(Element el : XMLUtils.flattenElements(doc.getRootElement(), "world-borders", "world-border")) {
        Filter filter = context.needModule(FilterParser.class).property(el, "when").optional(StaticFilter.ALLOW);

        Duration after = XMLUtils.parseDuration(Node.fromAttr(el, "after"));
        if(after != null) {
            if(!StaticFilter.ALLOW.equals(filter)) {
                throw new InvalidXMLException("Cannot combine a filter and an explicit time for a world border", el);
            }
            filter = MonostableFilter.after(context.features(), after);
        }

        WorldBorder border = new WorldBorder(
            filter,
            XMLUtils.parse2DVector(Node.fromRequiredAttr(el, "center")),
            XMLUtils.parseNumber(Node.fromRequiredAttr(el, "size"), Double.class),
            XMLUtils.parseDuration(Node.fromAttr(el, "duration"), Duration.ZERO),
            XMLUtils.parseNumber(Node.fromAttr(el, "damage"), Double.class, 0.2d),
            XMLUtils.parseNumber(Node.fromAttr(el, "buffer"), Double.class, 5d),
            XMLUtils.parseNumber(Node.fromAttr(el, "warning-distance"), Double.class, 5d),
            XMLUtils.parseDuration(Node.fromAttr(el, "warning-time"), Duration.ofSeconds(15))
        );

        borders.add(border);
    }

    if(borders.isEmpty()) {
        return null;
    } else {
        return new WorldBorderModule(ImmutableList.copyOf(borders));
    }
}
项目:ProjectAres    文件:FilterDefinitionParser.java   
@MethodParser("captured")
public Filter parseCaptured(Element el) throws InvalidXMLException {
    final GoalFilter goal = goalFilter(el);
    final Optional<TeamFactory> team = teamParser.property(el).optional();
    return team.isPresent() ? new TeamFilterAdapter(team, goal)
                            : goal;
}
项目:he-rss-poll    文件:RssUtils.java   
public static List<JsonObject> toJson(Document doc) {

        List<JsonObject> entries = new ArrayList<JsonObject>();

        List<Element> list = doc.getRootElement().getChild(CHANNEL).getChildren(ITEM);

        for (Element el : list) {

            JsonObject obj = new JsonObject();
            obj.put(GUID, el.getChildText(GUID));
            obj.put(TITLE, el.getChildText(TITLE));
            obj.put(PUBLISH_DATE, el.getChildText(PUBLISH_DATE));
            obj.put(ROAD, el.getChildText(ROAD));
            obj.put(REGION, el.getChildText(REGION));
            obj.put(COUNTY, el.getChildText(COUNTY));

            JsonArray categories = new JsonArray();
            for (Element cat : el.getChildren(CATEGORY)) {
                categories.add(new JsonObject().put(CATEGORY, cat.getText()));
            }
            obj.put(CATEGORIES, categories);

            obj.put(DESCRIPTION, el.getChildText(DESCRIPTION));

            entries.add(obj);
        }

        return entries;

    }
项目:ProjectAres    文件:StaminaModule.java   
private static void parseOptions(MapModuleContext context, Element el, StaminaOptions options) throws InvalidXMLException {
    options.mutators.sneak = parseMutator(el, "sneak");
    options.mutators.stand = parseMutator(el, "stand");
    options.mutators.walk = parseMutator(el, "walk");
    options.mutators.run = parseMutator(el, "run");

    options.mutators.jump = parseMutator(el, "jump");
    options.mutators.runJump = parseMutator(el, "run-jump");
    options.mutators.injury = parseMutator(el, "injury");
    options.mutators.meleeMiss = parseMutator(el, "melee-miss");
    options.mutators.meleeHit = parseMutator(el, "melee-hit");
    options.mutators.archery = parseMutator(el, "archery");

    for(Element elSymptoms : XMLUtils.flattenElements(el, "symptoms")) {
        switch(elSymptoms.getName()) {
            case "potion":
                options.symptoms.add(parsePotionSymptom(elSymptoms));
                break;

            case "melee":
                options.symptoms.add(parseMeleeSymptom(elSymptoms));
                break;

            case "archery":
                options.symptoms.add(parseArcherySymptom(elSymptoms));
                break;

            default:
                throw new InvalidXMLException("Invalid symptom type", elSymptoms);
        }
    }
}
项目:ProjectAres    文件:FeatureParser.java   
/**
 * Parse the given {@link Element} as a {@link T} of some kind (reference or definition).
 */
@Override
public T parseElement(Element el) throws InvalidXMLException {
    if(isReference(el)) {
        return parseReferenceElement(el);
    } else {
        return parseDefinition(el);
    }
}
项目:bibliometrics    文件:GeneralStatistics.java   
public Element preparePublicationList() {
    Element pubList = new Element("mods:collection");
    for (Element mods : modsList) {
        if (mods.getChild("mods:extension") != null)
            mods.removeChild("mods:extension");
        pubList.addContent(mods);
    }
    return pubList;
}
项目:ProjectAres    文件:FilterParser.java   
@Override
public Filter parseElement(Element el) throws InvalidXMLException {
    // If we find something unparseable, try parsing it as a region before giving up
    if(super.isParseable(el)) {
        return super.parseElement(el);
    } else if(regionParser.isParseable(el)) {
        return regionParser.parseElement(el);
    } else {
        throw new UnrecognizedXMLException(propertyName(), el);
    }
}
项目:ctsms    文件:OpsSystClassProcessor.java   
private OpsSyst createOpsSyst(
        Element chapterClassElement,
        ArrayList<Element> blockClassElements,
        ArrayList<Element> categoryClassElements,
        String modifiedCode,
        ArrayList<Element> modifierClasses,
        int hash,
        String lang) {
    OpsSyst opsSyst = OpsSyst.Factory.newInstance();
    opsSyst.setChapterCode(getCode(chapterClassElement));
    opsSyst.setChapterPreferredRubricLabel(getPreferredRubricLabel(chapterClassElement, lang));
    HashSet<OpsSystBlock> blocks = new HashSet<OpsSystBlock>(blockClassElements.size()); // LinkedHashSet
    int i = INITIAL_LEVEL;
    Iterator<Element> it = blockClassElements.iterator();
    while (it.hasNext()) {
        blocks.add(createOpsSystBlock(it.next(), i, !it.hasNext(), lang));
        i++;
    }
    opsSyst.setBlocks(blocks);
    HashSet<OpsSystCategory> categories = new HashSet<OpsSystCategory>(categoryClassElements.size()); // LinkedHashSet
    i = INITIAL_LEVEL;
    it = categoryClassElements.iterator();
    while (it.hasNext()) {
        categories.add(createOpsSystCategory(it.next(), i, !it.hasNext(), modifiedCode, modifierClasses, lang));
        i++;
    }
    opsSyst.setCategories(categories);
    opsSyst.setHash(hash);
    opsSyst.setRevision(revision);
    opsSyst = opsSystDao.create(opsSyst);
    return opsSyst;
}
项目:ProjectAres    文件:ItemParser.java   
@Override
public void parseCustomNBT(Element el, ItemMeta meta) throws InvalidXMLException {
    super.parseCustomNBT(el, meta);

    Node.tryAttr(el, "projectile").ifPresent(rethrowConsumer(node -> {
        fdc.reference(node, ProjectileDefinition.class);
        Projectiles.setProjectileId(meta, node.getValue());
    }));
}
项目:goobi-viewer-indexer    文件:TextHelper.java   
/**
 * @param tag
 * @return
 */
private static String createSimpleNamedEntityTag(Element tag) {
    String neLabel = tag.getAttributeValue("LABEL");
    String neType = tag.getAttributeValue("TYPE");

    StringBuilder sb = new StringBuilder();
    sb.append(neType);
    sb.append('_');
    sb.append(neLabel);

    return sb.toString();
}
项目:ctsms    文件:ClamlClassProcessor.java   
private static Element getBlock(Element categoryClassElement, Map<String, Map<String, Element>> classKinds) throws Exception {
    Element superClass = categoryClassElement.getChild(ClamlConstants.SUPERCLASS_ELEMENT); // single parent assumed
    if (superClass == null) {
        throw new IllegalArgumentException(getKind(categoryClassElement) + " " + getCode(categoryClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT);
    }
    String code = getCode(superClass);
    if (!CommonUtil.isEmptyString(code)) {
        return classKinds.get(ClamlConstants.CLASS_KIND_BLOCK_ATTR).get(code);
    } else {
        throw new IllegalArgumentException(getKind(categoryClassElement) + " " + getCode(categoryClassElement) + ": no " + ClamlConstants.SUPERCLASS_ELEMENT + " code");
    }
}
项目:Supreme-Bot    文件:XMLEditor.java   
public final XMLEditor add(Element element, int index) {
    if (index < 0 || index > path.size() + 1) {
        return this;
    }
    path.add(index, element);
    return this;
}
项目:goobi-viewer-connector    文件:ErrorCode.java   
/**
 * the verb argument is missing or has invalid value
 * 
 * @return
 */
public Element getBadVerb() {
    Element error = new Element("error", xmlns);
    error.setAttribute("code", "badVerb");
    error.setText("Value of the verb argument is not a legal OAI-PMH verb, the verb argument is missing, or the verb argument is repeated. ");
    return error;
}
项目:Supreme-Bot    文件:XMLEditor.java   
public final Element goUp() {
    if (getLast() == null || path.size() < 1) { //FIXME good?
        return null;
    }
    removeLast();
    return getLast();
}
项目:qpp-conversion-tool    文件:ClinicalDocumentDecoderTest.java   
private Element prepareParticipant(Namespace rootns) {
    Element participant = new Element("participant", rootns);
    Element associatedEntity = new Element("associatedEntity", rootns);

    Element entityId = new Element("id", rootns)
        .setAttribute("root", "2.16.840.1.113883.3.249.5.1")
        .setAttribute("extension", ENTITY_ID_VALUE)
        .setAttribute("assigningAuthorityName", "CMS-CMMI");
    Element addr = new Element("addr", rootns)
        .setText("testing123");
    associatedEntity.addContent(entityId);
    associatedEntity.addContent(addr);
    participant.addContent(associatedEntity);
    return participant;
}
项目:ProjectAres    文件:Node.java   
public String getName() {
    if(this.node instanceof Attribute) {
        return ((Attribute) this.node).getName();
    } else {
        return ((Element) this.node).getName();
    }
}
项目:qpp-conversion-tool    文件:ClinicalDocumentDecoderTest.java   
private Element prepareComponentElement(Namespace rootns) {
    Element component = new Element("component", rootns);
    Element structuredBody = new Element("structuredBody", rootns);
    Element componentTwo = new Element("component", rootns);
    Element aciSectionElement = new Element("templateId", rootns);
    aciSectionElement.setAttribute("root", TemplateId.ACI_SECTION.getRoot());
    aciSectionElement.setAttribute("extension", TemplateId.ACI_SECTION.getExtension());

    componentTwo.addContent(aciSectionElement);
    structuredBody.addContent(componentTwo);
    component.addContent(structuredBody);
    return component;
}
项目:ProjectAres    文件:MagicMethodFeatureParser.java   
/**
 * Parse a {@link T} defined by the given {@link Element}.
 *
 * @throws InvalidXMLException if no {@link MethodParser} exists for the given element
 */
@Override
public T parseElement(Element el) throws InvalidXMLException {
    if(methodParsers.canParse(el)) {
        return methodParsers.parse(el);
    }
    throw new UnrecognizedXMLException(featureName, el);
}