Search in sources :

Example 21 with Element

use of org.osate.aadl2.Element in project palladian by palladian.

the class RawDateParserModule method parse.

@Override
public Module parse(Element element, Locale locale) {
    RawDateModule rawDateModule = new RawDateModuleImpl();
    List<Element> children = element.getChildren();
    for (Element childElement : children) {
        // search for a node containing "date" in its name
        if (childElement.getName().toLowerCase().contains("date")) {
            // LOGGER.debug("found " + childElement.getName() + " in element " + element.getTextNormalize());
            rawDateModule.setRawDate(childElement.getText());
            break;
        }
    }
    return rawDateModule;
}
Also used : Element(org.jdom2.Element)

Example 22 with Element

use of org.osate.aadl2.Element in project sonar-cxx by SonarOpenCommunity.

the class CxxSquidConfiguration method add.

/**
 * Add a single key/value pair (property) to the database.
 *
 * @param level The level parameter defines the level on which the data should be inserted. For level a predefined
 * name can be used or a new one can be defined. <br>
 * - If level is an identifier, the information is created in an element with the level-name directly under root.<br>
 * - If level is a path, the information is stored on Files level. In that case the level-string is normalized and
 * converted to lower case letters to simplify the following search.
 * @param key the key to be placed into the database.
 * @param value the value corresponding to key. Several values can be assigned to one key. Internally a value-list for
 * key is created. The method can be called several times for this, but more effective is the method
 * {@code add(String, String, List<String>)}.
 */
public void add(String level, String key, @Nullable String value) {
    if (value != null && !value.isEmpty()) {
        Element eKey = getKey(level, key);
        setValue(eKey, value);
    }
}
Also used : Element(org.jdom2.Element)

Example 23 with Element

use of org.osate.aadl2.Element in project sonar-cxx by SonarOpenCommunity.

the class CxxSquidConfiguration method getChildrenValues.

/**
 * Used to read multi-valued properties.
 *
 * Collects all found values over all children. Further found values in parent levels are added to the end of the
 * list. The method can return an empty list if the property is not set.
 *
 * @param level start level from which the values of all children are returned
 * @param key property key that is searched for in all children
 * @return the values with the specified key value
 */
public List<String> getChildrenValues(String level, String key) {
    List<String> result = new ArrayList<>();
    Element eLevel = findLevel(level, parentList.getFirst());
    if (eLevel != null) {
        for (var child : eLevel.getChildren()) {
            Element eKey = child.getChild(key);
            if (eKey != null) {
                for (var value : eKey.getChildren("Value")) {
                    result.add(value.getText());
                }
            }
        }
    }
    // add content of shared parents only once at the end
    eLevel = getParentElement(eLevel);
    if (eLevel != null) {
        result.addAll(getValues(eLevel.getName(), key));
    }
    return result;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList)

Example 24 with Element

use of org.osate.aadl2.Element in project sonar-cxx by SonarOpenCommunity.

the class CxxSquidConfiguration method getLevelValues.

/**
 * Used to read multi-valued properties from one level.
 *
 * The method can return an empty list if the property is not set.
 *
 * @param level level to read
 * @param property key that is searched for
 * @return the values with the specified key value
 */
public List<String> getLevelValues(String level, String key) {
    List<String> result = new ArrayList<>();
    Element eLevel = findLevel(level, null);
    if (eLevel != null) {
        Element eKey = eLevel.getChild(key);
        if (eKey != null) {
            for (var value : eKey.getChildren("Value")) {
                result.add(value.getText());
            }
        }
    }
    return result;
}
Also used : Element(org.jdom2.Element) ArrayList(java.util.ArrayList)

Example 25 with Element

use of org.osate.aadl2.Element in project sonar-cxx by SonarOpenCommunity.

the class CxxSquidConfiguration method add.

/**
 * Add a single key/value pair (property) to the database.
 *
 * Same as {@code add(String, String, String)} for an {@code Optional<String>}.
 *
 * @param level defines the level on which the data should be inserted
 * @param key the key to be placed into the database
 * @param value the value corresponding to key
 */
public void add(String level, String key, Optional<String> value) {
    if (value.isPresent()) {
        Element eKey = getKey(level, key);
        setValue(eKey, value.get());
    }
}
Also used : Element(org.jdom2.Element)

Aggregations

Element (org.jdom2.Element)3601 Document (org.jdom2.Document)589 Test (org.junit.Test)470 ArrayList (java.util.ArrayList)393 IOException (java.io.IOException)320 JDOMException (org.jdom2.JDOMException)230 Attribute (org.jdom2.Attribute)217 SAXBuilder (org.jdom2.input.SAXBuilder)169 Namespace (org.jdom2.Namespace)157 List (java.util.List)156 File (java.io.File)143 Element (org.osate.aadl2.Element)143 NamedElement (org.osate.aadl2.NamedElement)138 XMLOutputter (org.jdom2.output.XMLOutputter)136 HashMap (java.util.HashMap)134 Test (org.junit.jupiter.api.Test)134 XConfiguration (org.apache.oozie.util.XConfiguration)98 Configuration (org.apache.hadoop.conf.Configuration)96 StringReader (java.io.StringReader)85 Iterator (java.util.Iterator)73