org.jdom2.Attribute - java examples

Here are the examples of the java api org.jdom2.Attribute taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

133 Examples 7

19 View Complete Implementation : MCRXPathBuilder.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
/**
 * Builds an absolute XPath expression for the given attribute within a JDOM XML structure.
 * In case any ancestor element in context is not the first one, the XPath will also contain position predicates.
 * For all namespaces commonly used in MyCoRe, their namespace prefixes will be used.
 *
 * @param attribute a JDOM attribute
 * @return absolute XPath of that attribute. In case there is a root Doreplacedent, it will begin with a "/".
 */
public static String buildXPath(Attribute attribute) {
    String parentXPath = buildXPath(attribute.getParent());
    if (!parentXPath.isEmpty()) {
        parentXPath += "/";
    }
    return parentXPath + "@" + attribute.getQualifiedName();
}

19 View Complete Implementation : MCRChangeData.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
private static String attribute2text(Attribute attribute) {
    Element x = new Element("x").setAttribute(attribute.clone());
    String text = element2text(x);
    return text.substring(3, text.length() - 2).trim();
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static <T extends Number> T parseNumber(Attribute attr, Clreplaced<T> type, T def) throws InvalidXMLException {
    if (attr == null) {
        return def;
    } else {
        return parseNumber(attr, type);
    }
}

19 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public String getDescription() {
    if (node instanceof Element) {
        return describe((Element) node);
    } else {
        Attribute attr = (Attribute) node;
        return "'" + attr.getName() + "' attribute of " + describe(attr.getParent());
    }
}

19 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : OvercastNetwork
public static Node of(Attribute attribute) {
    return new Node(attribute);
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static <T extends Number & Comparable<T>> T parseNumber(Attribute attr, Clreplaced<T> type, Range<T> range) throws InvalidXMLException {
    T value = parseNumber(attr, type);
    if (!range.contains(value)) {
        throw new InvalidXMLException(value + " is not in the range " + range, attr);
    }
    return value;
}

19 View Complete Implementation : MCRMerger.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
/**
 * Copies those attributes from the other's element into this' element that do not exist in this' element.
 */
protected void mergeAttributes(MCRMerger other) {
    for (Attribute attribute : other.element.getAttributes()) {
        if (this.element.getAttribute(attribute.getName(), attribute.getNamespace()) == null) {
            this.element.setAttribute(attribute.clone());
        }
    }
}

19 View Complete Implementation : LegacyRegionParser.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public Region parseReference(Attribute attr) throws InvalidXMLException {
    String name = attr.getValue();
    Region region = this.regionContext.get(name);
    if (region == null) {
        throw new InvalidXMLException("Unknown region '" + name + "'", attr);
    } else {
        return region;
    }
}

19 View Complete Implementation : MCRSetAttributeValue.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
public static MCRChangeData setValue(Attribute attribute, String value) {
    MCRChangeData data = new MCRChangeData("set-attribute", attribute);
    attribute.setValue(value);
    return data;
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static <T extends Enum<T>> T parseEnum(Attribute attr, Clreplaced<T> type, String readableType) throws InvalidXMLException {
    return parseEnum(new Node(attr), type, readableType);
}

19 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
@Nullable
public static Node fromNullable(Attribute attr) {
    return attr == null ? null : new Node(attr);
}

19 View Complete Implementation : DatasetScanConfigBuilder.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : Unidata
/*
   * <xsd:complexType name="addLatestType">
   * <xsd:attribute name="name" type="xsd:string"/>
   * <xsd:attribute name="top" type="xsd:boolean"/>
   * <xsd:attribute name="serviceName" type="xsd:string"/>
   * <xsd:attribute name="lastModifiedLimit" type="xsd:float"/> <!-- minutes -->
   * </xsd:complexType>
   */
private DatasetScanConfig.AddLatest readDatasetScanAddLatest(Element addLatestElem) {
    String latestName = "latest.xml";
    String serviceName = "Resolver";
    boolean latestOnTop = true;
    boolean isResolver = true;
    String tmpLatestName = addLatestElem.getAttributeValue("name");
    if (tmpLatestName != null)
        latestName = tmpLatestName;
    String tmpserviceName = addLatestElem.getAttributeValue("serviceName");
    if (tmpserviceName != null)
        serviceName = tmpserviceName;
    // Does latest go on top or bottom of list.
    Attribute topAtt = addLatestElem.getAttribute("top");
    if (topAtt != null) {
        try {
            latestOnTop = topAtt.getBooleanValue();
        } catch (DataConversionException e) {
            latestOnTop = true;
        }
    }
    // Get lastModifed limit.
    String lastModLimitVal = addLatestElem.getAttributeValue("lastModifiedLimit");
    long lastModLimit = -1;
    if (lastModLimitVal != null)
        // convert minutes to millisecs
        lastModLimit = Long.parseLong(lastModLimitVal) * 60 * 1000;
    return new DatasetScanConfig.AddLatest(latestName, serviceName, latestOnTop, lastModLimit);
}

19 View Complete Implementation : FeatureRegionParser.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
@Override
public Region parseReference(Attribute attr) throws InvalidXMLException {
    return context.features().addReference(new XMLRegionReference(context.features(), new Node(attr), RegionDefinition.clreplaced));
}

19 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static List<Node> fromAttrs(List<Node> nodes, Element el, String name, String... aliases) throws InvalidXMLException {
    aliases = ArrayUtils.append(aliases, name);
    for (String alias : aliases) {
        Attribute attr = el.getAttribute(alias);
        if (attr != null)
            nodes.add(new Node(attr));
    }
    return nodes;
}

19 View Complete Implementation : LegacyKitParser.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
@Override
public Kit parse(Element el) throws InvalidXMLException {
    Kit kit;
    Attribute attrName = el.getAttribute("name");
    if (attrName != null && maybeReference(el)) {
        kit = parseReference(new Node(el), attrName.getValue());
    } else {
        kit = parseDefinition(el);
        if (attrName != null) {
            try {
                kitContext.add(attrName.getValue(), kit);
            } catch (IllegalArgumentException e) {
                // Probably a duplicate name
                throw new InvalidXMLException(e.getMessage(), el);
            }
        } else {
            kitContext.add(kit);
        }
    }
    return kit;
}

19 View Complete Implementation : MCRXPathBuilderTest.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
@Test
public void testXPath() {
    Element root = new Element("root");
    Element replacedle1 = new Element("replacedle");
    Element replacedle2 = new Element("replacedle");
    Element author = new Element("contributor");
    Attribute role = new Attribute("role", "author");
    Attribute lang = new Attribute("lang", "de", Namespace.XML_NAMESPACE);
    author.setAttribute(role);
    author.setAttribute(lang);
    root.addContent(replacedle1);
    root.addContent(author);
    root.addContent(replacedle2);
    new Doreplacedent(root);
    replacedertEquals("/root", MCRXPathBuilder.buildXPath(root));
    replacedertEquals("/root/contributor", MCRXPathBuilder.buildXPath(author));
    replacedertEquals("/root/replacedle", MCRXPathBuilder.buildXPath(replacedle1));
    replacedertEquals("/root/replacedle[2]", MCRXPathBuilder.buildXPath(replacedle2));
    replacedertEquals("/root/contributor/@role", MCRXPathBuilder.buildXPath(role));
    replacedertEquals("/root/contributor/@xml:lang", MCRXPathBuilder.buildXPath(lang));
    root.detach();
    replacedertEquals("root", MCRXPathBuilder.buildXPath(root));
    replacedertEquals("root/contributor", MCRXPathBuilder.buildXPath(author));
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Boolean parseBoolean(@Nullable Attribute attr, Boolean def) throws InvalidXMLException {
    return attr == null ? def : parseBoolean(new Node(attr));
}

19 View Complete Implementation : MCRAddedAttribute.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
public static MCRChangeData added(Attribute attribute) {
    return new MCRChangeData("added-attribute", attribute);
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Vector parseVector(Attribute attr) throws InvalidXMLException {
    return attr == null ? null : parseVector(attr, attr.getValue());
}

19 View Complete Implementation : MCRRemoveAttribute.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
public static MCRChangeData remove(Attribute attribute) {
    MCRChangeData data = new MCRChangeData("removed-attribute", attribute);
    attribute.detach();
    return data;
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Duration parseDuration(Attribute attr) throws InvalidXMLException {
    return parseDuration(attr, null);
}

19 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : OvercastNetwork
public String describe() {
    if (node instanceof Element) {
        return describe((Element) node);
    } else {
        Attribute attr = (Attribute) node;
        return "'" + attr.getName() + "' attribute of " + describe(attr.getParent());
    }
}

19 View Complete Implementation : XmlAttribute.java
Copyright MIT License
Author : Avicus
private static Optional<String> getValue(XmlElement element, String name) {
    Attribute jdom = element.getJdomElement().getAttribute(name);
    return jdom == null ? Optional.empty() : Optional.of(jdom.getValue());
}

19 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : OvercastNetwork
@Nullable
public static Node fromNullable(Attribute attr) {
    return attr == null ? null : Node.of(attr);
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static SingleMaterialMatcher parseMaterialPattern(Attribute attr) throws InvalidXMLException {
    return parseMaterialPattern(new Node(attr));
}

19 View Complete Implementation : Utils.java
Copyright GNU Lesser General Public License v3.0
Author : yawlfoundation
public static String attribute2String(Attribute a) {
    if (a == null)
        return null;
    else
        return a.getName() + "=" + a.getValue();
}

19 View Complete Implementation : CourseWaypoint.java
Copyright GNU General Public License v3.0
Author : yankee42
public static CourseWaypoint fromElement(final Element element) {
    double x = 0, y = 0;
    Double height = null;
    final Map<String, String> properties = new HashMap<>();
    for (final Attribute attribute : element.getAttributes()) {
        if (attribute.getName().equals("pos")) {
            final String[] values = attribute.getValue().split(" ");
            if (values.length != 2 && values.length != 3) {
                throw new RuntimeException("Cannot parse position <" + attribute.getValue() + "> in element <" + element.getName() + ">");
            }
            x = Double.parseDouble(values[0]);
            y = Double.parseDouble(values[values.length - 1]);
            if (values.length == 3) {
                height = Double.parseDouble(values[1]);
            }
        } else {
            properties.put(attribute.getName(), attribute.getValue());
        }
    }
    return new CourseWaypoint(x, y, height, properties);
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Vector parseVector(Attribute attr, String value) throws InvalidXMLException {
    return attr == null ? null : parseVector(new Node(attr), value);
}

19 View Complete Implementation : PointParser.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
AngleProvider parseStaticAngleProvider(Attribute attr) throws InvalidXMLException {
    Float angle = XMLUtils.parseNumber(attr, Float.clreplaced, (Float) null);
    return angle == null ? null : new StaticAngleProvider(angle);
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static <T extends Number> T parseNumber(Attribute attr, Clreplaced<T> type) throws InvalidXMLException {
    return parseNumber(new Node(attr), type);
}

19 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static DyeColor parseDyeColor(Attribute attr, DyeColor def) throws InvalidXMLException {
    return attr == null ? def : parseDyeColor(attr);
}

19 View Complete Implementation : YAttributeMap.java
Copyright GNU Lesser General Public License v3.0
Author : yawlfoundation
/**
 * Replace the stored attributes (if any) with the JDOM attributes specified.
 * @param jdomAttributes a List of JDOM Attribute objects to convert to key=value
 * pairs and place in this map, replacing any previous contents.
 */
public void fromJDOM(List<Attribute> jdomAttributes) {
    if (jdomAttributes != null) {
        clear();
        for (Attribute attribute : jdomAttributes) {
            put(attribute.getName(), attribute.getValue());
        }
    }
}

18 View Complete Implementation : ConditionalsFactory.java
Copyright GNU General Public License v3.0
Author : AustinLMayes
public static Conditional parseConditional(Element element) throws XmlException {
    List<Attribute> attributes = element.getAttributes();
    if (attributes.size() != 1) {
        throw new XmlException(new XmlElement(element), "Conditionals must have 1 and only 1 variable.");
    }
    Attribute variable = attributes.get(0);
    switch(variable.getName()) {
        case "season":
        case "month":
        case "holiday":
            return new DateConditional(variable.getName(), variable.getValue(), element.getChildren());
        default:
            return new ConfigValueConditional(variable.getName(), variable.getValue(), element.getChildren());
    }
}

18 View Complete Implementation : RegionParser.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
@Nullable
public Region parseRegionProperty(Element rootElement, @Nullable FeatureValidation<RegionDefinition> validation, Region def, String... names) throws InvalidXMLException {
    Attribute propertyAttribute = null;
    Element propertyElement = null;
    for (String name : names) {
        if (rootElement.getAttribute(name) != null && rootElement.getChild(name) != null) {
            throw new InvalidXMLException("Multiple defined region properties for " + name, rootElement);
        }
        if ((rootElement.getAttribute(name) != null || rootElement.getChild(name) != null) && (propertyAttribute != null || propertyElement != null)) {
            throw new InvalidXMLException("Multiple defined region properties for " + Arrays.toString(names), rootElement);
        }
        if (rootElement.getAttribute(name) != null) {
            propertyAttribute = rootElement.getAttribute(name);
        } else if (rootElement.getChild(name) != null) {
            propertyElement = rootElement.getChild(name);
        }
    }
    Region region = def;
    Node node = null;
    if (propertyAttribute != null) {
        region = this.parseReference(propertyAttribute);
        node = new Node(propertyAttribute);
    } else if (propertyElement != null) {
        region = this.parseChildren(propertyElement);
        node = new Node(propertyElement);
    }
    if (region != null && validation != null) {
        validate(region, validation, node);
    }
    return region;
}

18 View Complete Implementation : TeamModule.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
// ---------------------
// ---- XML Parsing ----
// ---------------------
public TeamFactory parseTeam(Attribute attr, MapModuleContext context) throws InvalidXMLException {
    if (attr == null) {
        return null;
    }
    String name = attr.getValue();
    TeamFactory team = Teams.getTeam(name, context);
    if (team == null) {
        throw new InvalidXMLException("unknown team '" + name + "'", attr);
    }
    return team;
}

18 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
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);
    }
}

18 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Vector parseVector(Attribute attr, Vector def) throws InvalidXMLException {
    return attr == null ? def : parseVector(attr);
}

18 View Complete Implementation : ConfigUtil.java
Copyright Apache License 2.0
Author : gocd
public String getAttribute(Element e, String attribute) {
    Attribute attr = e.getAttribute(attribute);
    if (attr == null) {
        throw bomb("Error finding attribute '" + attribute + "' in config: " + configFile + elementOutput(e));
    }
    return attr.getValue();
}

18 View Complete Implementation : MCRAddedAttribute.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
public void undo(MCRChangeData data) {
    Attribute attribute = data.getAttribute();
    data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace());
}

18 View Complete Implementation : MCRSetAttributeValue.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
public void undo(MCRChangeData data) {
    Attribute attribute = data.getAttribute();
    data.getContext().removeAttribute(attribute.getName(), attribute.getNamespace());
    data.getContext().setAttribute(attribute);
}

18 View Complete Implementation : ProximityAlarmModule.java
Copyright GNU Affero General Public License v3.0
Author : OvercastNetwork
public static ProximityAlarmDefinition parseDefinition(MapModuleContext context, Element elAlarm) throws InvalidXMLException {
    ProximityAlarmDefinition definition = new ProximityAlarmDefinition();
    FilterParser filterParser = context.needModule(FilterParser.clreplaced);
    definition.detectFilter = filterParser.parseProperty(elAlarm, "detect");
    definition.alertFilter = filterParser.property(elAlarm, "notify").optionalGet(() -> new InverseFilter(definition.detectFilter));
    definition.detectRegion = context.needModule(RegionParser.clreplaced).property(elAlarm, "region").required();
    // null = no message
    definition.alertMessage = elAlarm.getAttributeValue("message");
    if (definition.alertMessage != null) {
        definition.alertMessage = ChatColor.translateAlternateColorCodes('`', definition.alertMessage);
    }
    Attribute attrFlareRadius = elAlarm.getAttribute("flare-radius");
    definition.flares = attrFlareRadius != null;
    if (definition.flares) {
        definition.flareRadius = XMLUtils.parseNumber(attrFlareRadius, Double.clreplaced);
    }
    return definition;
}

18 View Complete Implementation : Node.java
Copyright GNU Affero General Public License v3.0
Author : OvercastNetwork
private static boolean equals(Attribute a, Attribute b) {
    if (a == null || b == null)
        return false;
    if (a == b)
        return true;
    if (!a.getName().equals(b.getName()))
        return false;
    return equals(a.getParent(), b.getParent());
}

17 View Complete Implementation : WhileLoopRules.java
Copyright Apache License 2.0
Author : cerner
@Override
protected Set<Violation> doMeasuredreplacedysis() throws JDOMException {
    final Set<Violation> violations = new HashSet<Violation>();
    final List<Element> whileLoops = selectNodesByName("WHILE.");
    // Potential false positives:
    // condition value is preplaceded by reference into a function or subroutine in the condition or the body.
    // condition calls a subroutine that references higher scope variables that are set in the body.
    for (final Element whileLoop : whileLoops) {
        // The way I am going to do this check is pretty good but not perfect. Basically I will look at the
        // conditional portion of the while loop and locate all NAME variables. At least one of those name variables
        // will be by conditional, so I will then scan the body of the while loop looking for instances where the
        // conditional is referenced on the left hand side of an operator to ensure that something in the
        // conditional is getting a new value periodically.
        List<Attribute> nameAttributes = selectAttributes(whileLoop, "./*[1]/descendant-or-self::NAME/@text");
        boolean found = false;
        for (Attribute nameAttribute : nameAttributes) {
            // Search for this name within a Z_SET command to see if it's used there
            if (!selectNodes(whileLoop, "./COMMA.//Z_SET./NAME[1][@text = '" + nameAttribute.getValue() + "']").isEmpty()) {
                found = true;
                break;
            }
            // Search for this name within a IS. command to see if it's used within a report writer section
            if (!selectNodes(whileLoop, "./COMMA.//IS./NAME[1][@text = '" + nameAttribute.getValue() + "']").isEmpty()) {
                found = true;
                break;
            }
        }
        if (!found) {
            violations.add(new InfiniteLoopViolation(getLineNumber(whileLoop)));
        }
    }
    return violations;
}

17 View Complete Implementation : PortalModule.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
private static DoubleProvider parseDoubleProvider(Element el, String attributeName, DoubleProvider def) throws InvalidXMLException {
    Attribute attr = el.getAttribute(attributeName);
    if (attr == null) {
        return def;
    }
    String text = attr.getValue();
    try {
        if (text.startsWith("@")) {
            double value = Double.parseDouble(text.substring(1));
            return new StaticDoubleProvider(value);
        } else {
            double value = Double.parseDouble(text);
            return new RelativeDoubleProvider(value);
        }
    } catch (NumberFormatException e) {
        throw new InvalidXMLException("Invalid portal coordinate", attr, e);
    }
}

17 View Complete Implementation : ProximityAlarmModule.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static ProximityAlarmDefinition parseDefinition(MapModuleContext context, Element elAlarm) throws InvalidXMLException {
    ProximityAlarmDefinition definition = new ProximityAlarmDefinition();
    FilterParser filterParser = context.getFilterParser();
    definition.detectFilter = filterParser.parseRequiredFilterProperty(elAlarm, "detect");
    definition.alertFilter = filterParser.parseFilterProperty(elAlarm, "notify", new InverseFilter(definition.detectFilter));
    definition.detectRegion = context.getRegionParser().parseRequiredRegionProperty(elAlarm, "region");
    // null = no message
    definition.alertMessage = elAlarm.getAttributeValue("message");
    if (definition.alertMessage != null) {
        definition.alertMessage = ChatColor.translateAlternateColorCodes('`', definition.alertMessage);
    }
    Attribute attrFlareRadius = elAlarm.getAttribute("flare-radius");
    definition.flares = attrFlareRadius != null;
    if (definition.flares) {
        definition.flareRadius = XMLUtils.parseNumber(attrFlareRadius, Double.clreplaced);
    }
    return definition;
}

17 View Complete Implementation : TimeLimitModule.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
private static VictoryCondition parseVictoryCondition(MapModuleContext context, Attribute attr) throws InvalidXMLException {
    if (attr == null)
        return null;
    try {
        return VictoryConditions.parse(context, attr.getValue());
    } catch (IllegalArgumentException e) {
        throw new InvalidXMLException(e.getMessage(), attr);
    }
}

17 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Duration parseDuration(Attribute attr, Duration def) throws InvalidXMLException {
    return parseDuration(Node.fromNullable(attr), def);
}

17 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
public static Attribute getRequiredAttribute(Element el, String name, String... aliases) throws InvalidXMLException {
    aliases = ArrayUtils.append(aliases, name);
    Attribute attr = null;
    for (String alias : aliases) {
        Attribute a = el.getAttribute(alias);
        if (a != null) {
            if (attr == null) {
                attr = a;
            } else {
                throw new InvalidXMLException("attributes '" + attr.getName() + "' and '" + alias + "' are aliases for the same thing, and cannot be combined", el);
            }
        }
    }
    if (attr == null) {
        throw new InvalidXMLException("attribute '" + name + "' is required", el);
    }
    return attr;
}

17 View Complete Implementation : XMLUtils.java
Copyright GNU Affero General Public License v3.0
Author : Electroid
/**
 * Parse a numeric range from attributes on the given element specifying the bounds of the range,
 * specifically:
 *
 * <p>gt gte lt lte
 */
public static <T extends Number & Comparable<T>> Range<T> parseNumericRange(Element el, Clreplaced<T> type) throws InvalidXMLException {
    Attribute lt = el.getAttribute("lt");
    Attribute lte = el.getAttribute("lte");
    Attribute gt = el.getAttribute("gt");
    Attribute gte = el.getAttribute("gte");
    if (lt != null && lte != null)
        throw new InvalidXMLException("Conflicting upper bound for numeric range", el);
    if (gt != null && gte != null)
        throw new InvalidXMLException("Conflicting lower bound for numeric range", el);
    BoundType lowerBoundType, upperBoundType;
    T lowerBound, upperBound;
    if (gt != null) {
        lowerBound = parseNumber(gt, type, (T) null);
        lowerBoundType = BoundType.OPEN;
    } else {
        lowerBound = parseNumber(gte, type, (T) null);
        lowerBoundType = BoundType.CLOSED;
    }
    if (lt != null) {
        upperBound = parseNumber(lt, type, (T) null);
        upperBoundType = BoundType.OPEN;
    } else {
        upperBound = parseNumber(lte, type, (T) null);
        upperBoundType = BoundType.CLOSED;
    }
    if (lowerBound == null) {
        if (upperBound == null) {
            return Range.all();
        } else {
            return Range.upTo(upperBound, upperBoundType);
        }
    } else {
        if (upperBound == null) {
            return Range.downTo(lowerBound, lowerBoundType);
        } else {
            return Range.range(lowerBound, lowerBoundType, upperBound, upperBoundType);
        }
    }
}

17 View Complete Implementation : MCRBinding.java
Copyright GNU General Public License v3.0
Author : MyCoRe-Org
private void trackNodeCreated(Object node) {
    if (node instanceof Element) {
        Element element = (Element) node;
        MCRChangeTracker.removeChangeTracking(element);
        track(MCRAddedElement.added(element));
    } else {
        Attribute attribute = (Attribute) node;
        track(MCRAddedAttribute.added(attribute));
    }
}