Example usage for org.dom4j Element addElement

List of usage examples for org.dom4j Element addElement

Introduction

In this page you can find the example usage for org.dom4j Element addElement.

Prototype

Element addElement(String name);

Source Link

Document

Adds a new Element node with the given name to this branch and returns a reference to the new node.

Usage

From source file:com.amalto.workbench.utils.MDMServerHelper.java

License:Open Source License

private static void addServerElement(Element root, MDMServerDef serverDef) {
    Element prop = root.addElement(MDMServerHelper.PROPERTIES);
    addServerProperties(prop, serverDef);
    Element name = prop.element(MDMServerHelper.NAME);
    if (name == null) {
        name = prop.addElement(MDMServerHelper.NAME);
    }/*  w ww.  jav  a 2 s  .c  o  m*/
    name.setText(serverDef.getName());
}

From source file:com.amalto.workbench.utils.MDMServerHelper.java

License:Open Source License

private static void addServerProperties(Element prop, MDMServerDef serverDef) {
    Element url = prop.element(MDMServerHelper.URL);
    if (url == null) {
        url = prop.addElement(MDMServerHelper.URL);
    }//from  w  w  w  .  ja va2  s . c  o  m
    url.setText(serverDef.getUrl());

    Element user = prop.element(MDMServerHelper.USER);
    if (user == null) {
        user = prop.addElement(MDMServerHelper.USER);
    }
    user.setText(serverDef.getUser());

    Element password = prop.element(MDMServerHelper.PASSWORD);
    if (password == null) {
        password = prop.addElement(MDMServerHelper.PASSWORD);
    }
    password.setText(PasswordUtil.encryptPassword(serverDef.getPasswd()));

}

From source file:com.apicloud.commons.model.Config.java

License:Open Source License

private static void createGenralElement(Element rootElement, Config config) {

    Element nameElement = rootElement.addElement("name");
    nameElement.setText(config.getName());

    Element descriptionElement = rootElement.addElement("description");
    descriptionElement.setText(config.getDesc());

    Element authorElement = rootElement.addElement("author");
    authorElement.addAttribute("email", config.getAuthorEmail());
    authorElement.addAttribute("href", config.getAuthorHref());
    authorElement.setText(config.getAuthorName());

    Element contentElement = rootElement.addElement("content");
    contentElement.addAttribute("src", config.getContentSrc());

}

From source file:com.apicloud.commons.model.Config.java

License:Open Source License

private static void createPreferenceElement(Element rootElement, Config config) {
    for (Preference preference : config.getPreferences()) {
        Element preferenceElement = rootElement.addElement("preference");
        preferenceElement.addAttribute("name", preference.getName());
        preferenceElement.addAttribute("value", preference.getValue());
    }//from ww w.  ja  va 2  s.  c o  m
}

From source file:com.apicloud.commons.model.Config.java

License:Open Source License

private static void createAccessElement(Element rootElement, Config config) {
    for (Access access : config.getAccesses()) {
        Element accessElement = rootElement.addElement("access");
        accessElement.addAttribute("origin", access.getOrigin());
    }//from w  w  w .j  a v a 2 s.co m

}

From source file:com.apicloud.commons.model.Config.java

License:Open Source License

private static void createPermissionElement(Element rootElement, Config config) {
    for (Permission permission : config.getPermissions()) {
        Element permissionElement = rootElement.addElement("permission");
        permissionElement.addAttribute("name", permission.getName());
    }/*  ww  w  . ja va 2s  . c  o m*/
}

From source file:com.apicloud.commons.model.Config.java

License:Open Source License

private static void createFeatureElement(Element rootElement, Config config) {
    for (Feature feature : config.getFeatures()) {
        Element featureElement = rootElement.addElement("feature");
        featureElement.addAttribute("name", feature.getName());
        createParamElement(featureElement, feature);
    }//from  w  ww.  j a  va 2  s.  c om
}

From source file:com.apicloud.commons.model.Config.java

License:Open Source License

private static void createParamElement(Element featureElement, Feature feature) {
    for (Param param : feature.getParams()) {
        Element paramElement = featureElement.addElement("param");
        paramElement.addAttribute("name", param.getName());
        paramElement.addAttribute("value", param.getValue());
    }//from www . java  2 s .c  o  m

}

From source file:com.apicloud.commons.model.Feature.java

License:Open Source License

private static void createFeatureElement(Element rootElement, List<Feature> features) {
    for (Feature feature : features) {
        Element FeatureElement = rootElement.addElement("feature");
        FeatureElement.addAttribute("name", feature.getName());
        FeatureElement.addAttribute("desc", feature.getDesc());
        FeatureElement.addAttribute("isAndroid", feature.isAndroid() + "");
        FeatureElement.addAttribute("isIOS", feature.isIos() + "");
        FeatureElement.addAttribute("type", feature.getType());
    }/*from  w w w  .  j ava 2 s  . c  om*/

}

From source file:com.apicloud.commons.model.Feature.java

License:Open Source License

private static void createFeatureElement2(Element rootElement, List<Feature> features) {
    for (Feature feature : features) {
        Element featureElement = rootElement.addElement("feature");
        featureElement.addAttribute("name", feature.getName());
        featureElement.addAttribute("desc", feature.getDesc());
        featureElement.addAttribute("isAndroid", feature.isAndroid() + "");
        featureElement.addAttribute("isIOS", feature.isIos() + "");
        featureElement.addAttribute("type", feature.getType());
        for (Param param : feature.getParams()) {
            Element paramElement = featureElement.addElement("param");
            paramElement.addAttribute("name", param.getName());
            paramElement.addAttribute("value", param.getValue());
        }/*from   w  w w .ja v a 2s .  c  om*/
    }

}