本文整理汇总了Java中org.jdom2.Element.getTextNormalize方法的典型用法代码示例。如果您正苦于以下问题:Java Element.getTextNormalize方法的具体用法?Java Element.getTextNormalize怎么用?Java Element.getTextNormalize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jdom2.Element
的用法示例。
在下文中一共展示了Element.getTextNormalize方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getNormalizedNullableText
import org.jdom2.Element; //导入方法依赖的package包/类
public static String getNormalizedNullableText(Element el) {
String text = el.getTextNormalize();
if(text == null || "".equals(text)) {
return null;
} else {
return text;
}
}
示例2: parseLocalizedText
import org.jdom2.Element; //导入方法依赖的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());
}
}
示例3: parseClass
import org.jdom2.Element; //导入方法依赖的package包/类
@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);
}
示例4: parseMob
import org.jdom2.Element; //导入方法依赖的package包/类
@MethodParser("mob")
public EntityTypeFilter parseMob(Element el) throws InvalidXMLException {
EntityTypeFilter matcher = this.parseEntity(el);
if(!LivingEntity.class.isAssignableFrom(matcher.getEntityType())) {
throw new InvalidXMLException("Unknown mob type: " + el.getTextNormalize(), el);
}
return matcher;
}
示例5: parse
import org.jdom2.Element; //导入方法依赖的package包/类
@Override
public InfoModule parse(MapModuleContext context, Logger logger, Document doc) throws InvalidXMLException {
Element root = doc.getRootElement();
String name = Node.fromRequiredChildOrAttr(root, "name").getValueNormalize();
SemanticVersion version = XMLUtils.parseSemanticVersion(Node.fromRequiredChildOrAttr(root, "version"));
MapDoc.Phase phase = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "phase"), MapDoc.Phase.class, "phase", MapDoc.Phase.PRODUCTION);
MapDoc.Edition edition = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "edition"), MapDoc.Edition.class, "edition", MapDoc.Edition.STANDARD);
// Allow multiple <objective> elements, so include files can provide defaults
final BaseComponent objective = XMLUtils.parseLocalizedText(Node.fromRequiredLastChildOrAttr(root, "objective"));
String slug = root.getChildTextNormalize("slug");
BaseComponent game = XMLUtils.parseFormattedText(root, "game");
MapDoc.Genre genre = XMLUtils.parseEnum(Node.fromNullable(root.getChild("genre")), MapDoc.Genre.class, "genre", MapDoc.Genre.OTHER);
final TreeSet<MapDoc.Gamemode> gamemodes = new TreeSet<>();
for(Element elGamemode : root.getChildren("gamemode")) {
gamemodes.add(XMLUtils.parseEnum(elGamemode, MapDoc.Gamemode.class));
}
List<Contributor> authors = readContributorList(root, "authors", "author");
if(game == null) {
Element blitz = root.getChild("blitz");
if(blitz != null) {
Element title = blitz.getChild("title");
if(title != null) {
if(context.getProto().isNoOlderThan(ProtoVersions.REMOVE_BLITZ_TITLE)) {
throw new InvalidXMLException("<title> inside <blitz> is no longer supported, use <map game=\"...\">", title);
}
game = new Component(title.getTextNormalize());
}
}
}
List<Contributor> contributors = readContributorList(root, "contributors", "contributor");
List<String> rules = new ArrayList<String>();
for(Element parent : root.getChildren("rules")) {
for(Element rule : parent.getChildren("rule")) {
rules.add(rule.getTextNormalize());
}
}
Difficulty difficulty = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "difficulty"), Difficulty.class, "difficulty");
Environment dimension = XMLUtils.parseEnum(Node.fromLastChildOrAttr(root, "dimension"), Environment.class, "dimension", Environment.NORMAL);
boolean friendlyFire = XMLUtils.parseBoolean(Node.fromLastChildOrAttr(root, "friendly-fire", "friendlyfire"), false);
return new InfoModule(new MapInfo(context.getProto(), slug, name, version, edition, phase, game, genre, ImmutableSet.copyOf(gamemodes), objective, authors, contributors, rules, difficulty, dimension, friendlyFire));
}
示例6: parseShapedRecipe
import org.jdom2.Element; //导入方法依赖的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;
}