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


Java Attribute.getValue方法代码示例

本文整理汇总了Java中org.jdom2.Attribute.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.getValue方法的具体用法?Java Attribute.getValue怎么用?Java Attribute.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jdom2.Attribute的用法示例。


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

示例1: parseFormattedText

import org.jdom2.Attribute; //导入方法依赖的package包/类
/**
 * Parse a piece of formatted text, which can be either plain text with legacy
 * formatting codes, or JSON chat components.
 */
public static BaseComponent parseFormattedText(@Nullable Node node, BaseComponent def) throws InvalidXMLException {
    if(node == null) return def;

    // <blah translate="x"/> is shorthand for <blah>{"translate":"x"}</blah>
    if(node.isElement()) {
        final Attribute translate = node.asElement().getAttribute("translate");
        if(translate != null) {
            return new TranslatableComponent(translate.getValue());
        }
    }

    String text = node.getValueNormalize();
    if(looksLikeJson(text)) {
        try {
            return Components.concat(ComponentSerializer.parse(node.getValue()));
        } catch(JsonParseException e) {
            throw new InvalidXMLException(e.getMessage(), node, e);
        }
    } else {
        return Components.concat(TextComponent.fromLegacyText(BukkitUtils.colorize(text)));
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:27,代码来源:XMLUtils.java

示例2: parseString

import org.jdom2.Attribute; //导入方法依赖的package包/类
/**
 * Parses a JDom2 Object into a string
 * @param e
 *            Object (Element, Text, Document or Attribute)
 * @return String
 * @author sholzer (11.05.2015)
 */
public String parseString(Object e) {
    XMLOutputter element2String = new XMLOutputter();
    if (e instanceof Element) {
        return element2String.outputString((Element) e);
    }
    if (e instanceof Text) {
        return element2String.outputString((Text) e);
    }
    if (e instanceof Document) {
        return element2String.outputString((Document) e);
    }
    if (e instanceof org.jdom2.Attribute) {
        Attribute a = (org.jdom2.Attribute) e;
        return a.getName() + "=\"" + a.getValue() + "\"";
    }
    return e.toString();
}
 
开发者ID:maybeec,项目名称:lexeme,代码行数:25,代码来源:JDom2Util.java

示例3: searchFileInGroup

import org.jdom2.Attribute; //导入方法依赖的package包/类
/**
 * Searches a file in a group, which matches a filename.
 *
 * @param mets the mets file to search
 * @param path the path to the alto file (e.g. "alto/alto_file.xml" when searching in DEFAULT_FILE_GROUP_USE or
 *             "image_file.jpg" when searchin in ALTO_FILE_GROUP_USE)
 * @param searchFileGroup
 * @return the id of the matching file or null if there is no matching file
 */
private static String searchFileInGroup(Document mets, String path, String searchFileGroup) {
    XPathExpression<Element> xpath;// first check all files in default file group
    String relatedFileExistPathString = String.format(Locale.ROOT,
        "mets:mets/mets:fileSec/mets:fileGrp[@USE='%s']/mets:file/mets:FLocat", searchFileGroup);
    xpath = XPathFactory.instance().compile(relatedFileExistPathString, Filters.element(), null,
        MCRConstants.METS_NAMESPACE, MCRConstants.XLINK_NAMESPACE);
    List<Element> fileLocList = xpath.evaluate(mets);
    String matchId = null;

    // iterate over all files
    path = getCleanPath(path);

    for (Element fileLoc : fileLocList) {
        Attribute hrefAttribute = fileLoc.getAttribute("href", MCRConstants.XLINK_NAMESPACE);
        String hrefAttributeValue = hrefAttribute.getValue();
        String hrefPath = getCleanPath(removeExtension(hrefAttributeValue));

        if (hrefPath.equals(removeExtension(path))) {
            matchId = ((Element) fileLoc.getParent()).getAttributeValue("ID");
            break;
        }
    }
    return matchId;
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:34,代码来源:MCRMetsSave.java

示例4: parseDyeColor

import org.jdom2.Attribute; //导入方法依赖的package包/类
public static DyeColor parseDyeColor(Attribute attr) throws InvalidXMLException {
    String name = attr.getValue().replace(" ", "_").toUpperCase();
    try {
        return DyeColor.valueOf(name);
    }
    catch(IllegalArgumentException e) {
        throw new InvalidXMLException("Invalid dye color '" + attr.getValue() + "'", attr);
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:10,代码来源:XMLUtils.java

示例5: parseLocalizedText

import org.jdom2.Attribute; //导入方法依赖的package包/类
public static BaseComponent parseLocalizedText(Element el) throws InvalidXMLException {
    final Attribute translate = el.getAttribute("translate");
    if(translate != null) {
        return new TranslatableComponent(translate.getValue());
    } else {
        return new Component(el.getTextNormalize());
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:9,代码来源:XMLUtils.java

示例6: getDefaultSmLink

import org.jdom2.Attribute; //导入方法依赖的package包/类
/**
 * Build the default smLink. The PhysicalSubDiv is simply linked to the root chapter of the mets document.
 *
 * @param mets the mets document
 * @param div  the PhysicalSubDiv which should be linked
 * @return the default smLink
 */
private static SmLink getDefaultSmLink(Document mets, PhysicalSubDiv div) {
    XPathExpression<Attribute> attributeXpath;
    attributeXpath = XPathFactory.instance().compile("mets:mets/mets:structMap[@TYPE='LOGICAL']/mets:div/@ID",
        Filters.attribute(), null, MCRConstants.METS_NAMESPACE);
    Attribute idAttribute = attributeXpath.evaluateFirst(mets);
    String rootID = idAttribute.getValue();
    return new SmLink(rootID, div.getId());
}
 
开发者ID:MyCoRe-Org,项目名称:mycore,代码行数:16,代码来源:MCRMetsSave.java

示例7: parseId

import org.jdom2.Attribute; //导入方法依赖的package包/类
public static String parseId(Element xml) {
    Attribute attribute = xml.getAttribute("id");
    if (attribute != null) {
        return attribute.getValue();
    }

    return RandomStringUtils.randomAlphanumeric(5);
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:XMLTeam.java

示例8: parseName

import org.jdom2.Attribute; //导入方法依赖的package包/类
public static String parseName(Element xml) {
    Attribute attribute = xml.getAttribute("name");
    if (attribute != null) {
        String name = attribute.getValue();
        if (name.length() <= Team.NAME_MAX_LENGTH) {
            return name;
        }
    }

    return RandomStringUtils.randomAlphanumeric(5);
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:12,代码来源:XMLTeam.java

示例9: loadServer

import org.jdom2.Attribute; //导入方法依赖的package包/类
private void loadServer() {
        this.serverSession = new ServerSessionFile(this);
//        try {
//            this.serverSession.deserialize();
//        } catch (IOException io) {
//            this.getLogger().log(Level.SEVERE, "Could not load server-session file: " + io.getMessage(), io);
//        }

        Element serverElement = this.getSettings().getData().getChild("server");
        if (serverElement == null) {
            serverElement = new Element("server");
        }

        Attribute nameAttribute = serverElement.getAttribute("name");
        if (nameAttribute != null && this.serverName.equals(DEFAULT_SERVER_NAME)) {
            this.serverName = nameAttribute.getValue();
        }

        this.registerListenerObject(new BlockTransformListeners(this));
        this.registerListenerObject(new GeneralListeners(this));
        this.registerListenerObject(new ProtectionListeners(this));

        // dead events
        this.registerListenerObject(new DeadListeners(this));

        // permissions
        this.registerListenerObject(new PermissionListeners(this));

        // scoreboards
        this.registerListenerObject(new ScoreboardListeners(this));

        // sessions
        this.registerListenerObject(new Sessions(this));

        // windows
        this.registerListenerObject(new WindowListeners(this));
    }
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:38,代码来源:ArcadePlugin.java

示例10: parseId

import org.jdom2.Attribute; //导入方法依赖的package包/类
private static String parseId(Element xml) {
    Attribute attribute = xml.getAttribute("id");
    if (attribute != null) {
        return attribute.getValue();
    }

    return RandomStringUtils.randomAlphanumeric(5);
}
 
开发者ID:ShootGame,项目名称:Arcade2,代码行数:9,代码来源:XMLRegion.java

示例11: parse

import org.jdom2.Attribute; //导入方法依赖的package包/类
public void parse(Element el) throws InvalidXMLException {
    final Region region;
    if(useId()) {
        // Multiple regions are unioned, but the default is NOT an empty union
        region = regionParser.property(el).optionalUnion(EverywhereRegion.INSTANCE);
    } else {
        region = regionParser.parseReferenceAndChildUnion(el);
    }

    BaseComponent message = XMLUtils.parseFormattedText(el, "message");

    boolean earlyWarning = XMLUtils.parseBoolean(el.getAttribute("early-warning"), false);
    Filter effectFilter = filterParser.parseOptionalProperty(el, "filter").orElse(null);

    kitParser.property(el, "kit").optional().ifPresent(rethrowConsumer(
        kit -> add(el, EventRule.newKitRegion(EventRuleScope.EFFECT, region, effectFilter, kit, false))
    ));

    kitParser.property(el, "lend-kit").validate(RemovableValidation.get()).optional().ifPresent(rethrowConsumer(
        kit -> add(el, EventRule.newKitRegion(EventRuleScope.EFFECT, region, effectFilter, kit, true))
    ));

    Attribute attrVelocity = el.getAttribute("velocity");
    if(attrVelocity != null) {
        // Legacy support
        String velocityText = attrVelocity.getValue();
        if(velocityText.charAt(0) == '@') velocityText = velocityText.substring(1);
        Vector velocity = XMLUtils.parseVector(attrVelocity, velocityText);
        add(el, EventRule.newVelocityRegion(EventRuleScope.EFFECT, region, effectFilter, velocity));
    }

    for(String tag : EventRuleScope.byTag.keySet()) {
        Filter filter;
        if(useId()) {
            filter = filterParser.parseOptionalProperty(el, tag).orElse(null);
        } else {
            // Legacy syntax allows a list of filter names in the attribute
            Node node = Node.fromAttr(el, tag);
            if(node == null) {
                filter = null;
            } else {
                List<Filter> filters = new ArrayList<>();
                for(String name : Splitter.on(" ").split(node.getValue())) {
                    filters.add(filterParser.parseReference(node, name));
                }
                switch(filters.size()) {
                    case 0: filter = null; break;
                    case 1: filter = filters.get(0); break;
                    default: filter = ChainFilter.reverse(filters);
                }
            }
        }

        if(filter != null) {
            for(EventRuleScope scope : EventRuleScope.byTag.get(tag)) {
                add(el, EventRule.newEventFilter(scope, region, filter, message, earlyWarning));
            }
        }
    }
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:61,代码来源:EventRuleParser.java

示例12: parseShapedRecipe

import org.jdom2.Attribute; //导入方法依赖的package包/类
public Recipe parseShapedRecipe(MapModuleContext context, Element elRecipe) throws InvalidXMLException {
    ShapedRecipe recipe = new ShapedRecipe(parseRecipeResult(context, elRecipe));

    Element elShape = XMLUtils.getRequiredUniqueChild(elRecipe, "shape");
    List<String> rows = new ArrayList<>(3);

    for(Element elRow : elShape.getChildren("row")) {
        String row = elRow.getTextNormalize();

        if(rows.size() >= 3) {
            throw new InvalidXMLException("Shape must have no more than 3 rows (" + row + ")", elShape);
        }

        if(rows.isEmpty()) {
            if(row.length() > 3) {
                throw new InvalidXMLException("Shape must have no more than 3 columns (" + row + ")", elShape);
            }
        } else if(row.length() != rows.get(0).length()) {
            throw new InvalidXMLException("All rows must be the same width", elShape);
        }

        rows.add(row);
    }

    if(rows.isEmpty()) {
        throw new InvalidXMLException("Shape must have at least one row", elShape);
    }

    recipe.shape(rows.toArray(new String[rows.size()]));
    Set<Character> keys = recipe.getIngredientMap().keySet(); // All shape symbols are present and mapped to null at this point

    for(Element elIngredient : elRecipe.getChildren("ingredient")) {
        MaterialPattern item = XMLUtils.parseMaterialPattern(elIngredient);
        Attribute attrSymbol = XMLUtils.getRequiredAttribute(elIngredient, "symbol");
        String symbol = attrSymbol.getValue();

        if(symbol.length() != 1) {
            throw new InvalidXMLException("Ingredient key must be a single character from the recipe shape", attrSymbol);
        }

        char key = symbol.charAt(0);
        if(!keys.contains(key)) {
            throw new InvalidXMLException("Ingredient key '" + key + "' does not appear in the recipe shape", attrSymbol);
        }

        if(item.dataMatters()) {
            recipe.setIngredient(key, item.getMaterialData());
        } else {
            recipe.setIngredient(key, item.getMaterial());
        }
    }

    if(recipe.getIngredientMap().isEmpty()) {
        throw new InvalidXMLException("Crafting recipe must have at least one ingredient", elRecipe);
    }

    return recipe;
}
 
开发者ID:OvercastNetwork,项目名称:ProjectAres,代码行数:59,代码来源:CraftingModule.java


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