Example usage for org.dom4j Attribute getValue

List of usage examples for org.dom4j Attribute getValue

Introduction

In this page you can find the example usage for org.dom4j Attribute getValue.

Prototype

String getValue();

Source Link

Document

Returns the value of the attribute.

Usage

From source file:com.thoughtworks.go.server.JUnitReportGenerator.java

License:Apache License

private static void setAttr(int i, Element test, final String attr) {
    Attribute classname = test.attribute(attr);
    classname.setValue(classname.getValue() + i);
}

From source file:com.tustar.utils.NSGenerate.java

License:Apache License

/**
 * Translate element to component./*  w  w  w  .  j  av a 2 s.  c  o  m*/
 * 
 * @param root
 * @return
 */
public static List<Component> element2Components(Element root) {

    List<Component> components = new LinkedList<Component>();
    // Root component
    List<Attribute> attributes = root.attributes();
    for (Attribute attribute : attributes) {

        String name = attribute.getName();
        String value = attribute.getValue();

        if (name.equals("id")) {
            Component component = new Component();
            String id = "";
            if (LayoutUtils.isAndroidId(value)) {
                id = "android.R.id." + LayoutUtils.getIdInR(value);
            } else {
                id = "R.id." + LayoutUtils.getIdInR(value);
            }
            component.setId(id);
            component.setName("m" + LayoutUtils.cameId(value));
            component.setType(root.getName());
            components.add(component);
        }
    }

    // Elements
    List<Element> elements = root.elements();
    for (Element element : elements) {

        // Container component
        String type = element.getName();
        if (LayoutUtils.isContainerLayout(type)) {
            components.addAll(element2Components(element));
            continue;
        }

        // Include view component
        if (LayoutUtils.isIncludeLayout(type)) {
            List<Attribute> stubAttributes = element.attributes();
            String id = "";
            String cName = "";
            String stubLayout = "";
            for (Attribute attribute : stubAttributes) {

                String name = attribute.getName();
                String value = attribute.getValue();

                if (name.equals("id")) {
                    if (LayoutUtils.isAndroidId(value)) {
                        id = "android.R.id." + LayoutUtils.getIdInR(value);
                    } else {
                        id = "R.id." + LayoutUtils.getIdInR(value);
                    }
                    cName = value;
                    continue;
                }

                if (name.equals("layout")) {
                    stubLayout = LayoutUtils.getStubLayout(value);
                }
            }

            if (id == null || id.length() == 0) {
                Log.o(TAG, "element2Components :: ", type + " " + stubLayout + " id is empty");
                components.addAll(layout2Components(stubLayout));
            } else {
                Log.o(TAG, "element2Components :: ", type + " " + stubLayout + " id is normal");
                Component component = new Component();
                component.setId(id);
                component.setName("m" + LayoutUtils.cameId(cName));
                component.setType(LayoutUtils.xmlName2ClassName(CLASS_NAME_PREFIX, stubLayout));
                component.setInclude(true);
                components.add(component);
            }
            continue;
        }

        // ViewStub view component
        if (LayoutUtils.isViewStubLayout(type)) {
            List<Attribute> stubAttributes = element.attributes();
            String id = "";
            String cName = "";
            String stubLayout = "";
            for (Attribute attribute : stubAttributes) {

                String name = attribute.getName();
                String value = attribute.getValue();

                if (name.equals("id")) {
                    if (LayoutUtils.isAndroidId(value)) {
                        id = "android.R.id." + LayoutUtils.getIdInR(value);
                    } else {
                        id = "R.id." + LayoutUtils.getIdInR(value);
                    }
                    cName = value;
                    continue;
                }

                if (name.equals("layout")) {
                    stubLayout = LayoutUtils.getStubLayout(value);
                }
            }

            if (id == null || id.length() == 0) {
                Log.o(TAG, "element2Components :: ", type + " " + stubLayout + " id is empty");
                components.addAll(layout2Components(stubLayout));
            } else {
                Log.o(TAG, "element2Components :: ", type + " " + stubLayout + " id is normal");
                // ViewStub
                Component viewStub = new Component();
                viewStub.setId(id);
                viewStub.setName("m" + LayoutUtils.cameId(cName));
                viewStub.setType(type);
                components.add(viewStub);

                // Layout
                Component component = new Component();
                component.setId("m" + LayoutUtils.cameId(cName));
                component.setName("m" + LayoutUtils.cameId(cName) + "Layout");
                component.setType(LayoutUtils.xmlName2ClassName(CLASS_NAME_PREFIX, stubLayout));
                component.setStubView(true);
                components.add(component);
            }

            continue;
        }

        // Normal
        List<Attribute> stubAttributes = element.attributes();
        for (Attribute attribute : stubAttributes) {

            String name = attribute.getName();
            String value = attribute.getValue();
            if (name.equals("id")) {
                Component component = new Component();
                String id = "";
                if (LayoutUtils.isAndroidId(value)) {
                    id = "android.R.id." + LayoutUtils.getIdInR(value);
                } else {
                    id = "R.id." + LayoutUtils.getIdInR(value);
                }
                component.setId(id);
                component.setName("m" + LayoutUtils.cameId(value));
                component.setType(element.getName());
                components.add(component);
            }
        }
    }

    return components;
}

From source file:com.wabacus.config.xml.XmlAssistant.java

License:Open Source License

public XmlElementBean parseXmlValueToXmlBean(Element element) {
    if (element == null)
        return null;
    if (!isLegalNamespaceElement(element)) {
        throw new WabacusConfigLoadingException("namespace" + element.getNamespacePrefix() + "??");
    }//from  w w  w.j  av a2 s . c  o  m
    XmlElementBean xebean = new XmlElementBean(element.getName());
    String tagContent = element.getText();
    xebean.setContent(tagContent == null ? "" : tagContent.trim());
    Iterator itAttributes = element.attributeIterator();
    Map<String, String> mProps = new HashMap<String, String>();
    xebean.setMProperties(mProps);
    Attribute eleProps;
    while (itAttributes.hasNext()) {
        eleProps = (Attribute) itAttributes.next();
        mProps.put(eleProps.getName(), eleProps.getValue());
    }
    List<XmlElementBean> lstChildren = null;
    List lstChildElements = element.elements();
    if (lstChildElements != null && lstChildElements.size() > 0) {
        lstChildren = new ArrayList<XmlElementBean>();
        XmlElementBean eleTmp;
        for (Object eleObj : lstChildElements) {
            if (eleObj == null)
                continue;
            eleTmp = parseXmlValueToXmlBean((Element) eleObj);
            if (eleTmp == null)
                continue;
            eleTmp.setParentElement(xebean);
            lstChildren.add(eleTmp);
        }
        xebean.setLstChildElements(lstChildren);
    }
    return xebean;
}

From source file:com.webslingerz.jpt.PageTemplateImpl.java

License:Open Source License

AttributesImpl getAttributes(Element element, Expressions expressions) throws PageTemplateException {
    AttributesImpl attributes = new AttributesImpl();
    for (Iterator i = element.attributeIterator(); i.hasNext();) {
        Attribute attribute = (Attribute) i.next();
        Namespace namespace = attribute.getNamespace();
        Namespace elementNamespace = element.getNamespace();
        if (!namespace.hasContent() && elementNamespace.hasContent())
            namespace = elementNamespace;
        // String prefix = namespace.getPrefix();
        // System.err.println( "attribute: name=" + attribute.getName() +
        // "\t" +
        // "qualified name=" + attribute.getQualifiedName() + "\t" +
        // "ns prefix=" + namespace.getPrefix() + "\t" +
        // "ns uri=" + namespace.getURI() );
        // String qualifiedName = attribute.getName();
        // String name = qualifiedName;
        // if ( qualifiedName.startsWith( prefix + ":" ) ) {
        // name = qualifiedName.substring( prefix.length() + 1 );
        // }/*w  w w.  j ava 2s. co m*/
        String name = attribute.getName();

        // Handle JPT attributes
        // if ( prefix.equals( talNamespacePrefix ) ) {
        if (TAL_NAMESPACE_URI.equals(namespace.getURI())
                || (!strict && TAL_NAMESPACE_PREFIX.equals(namespace.getPrefix()))) {

            // tal:define
            if (name.equals("define")) {
                expressions.define = attribute.getValue();
            }

            // tal:condition
            else if (name.equals("condition")) {
                expressions.condition = attribute.getValue();
            }

            // tal:repeat
            else if (name.equals("repeat")) {
                expressions.repeat = attribute.getValue();
            }

            // tal:content
            else if (name.equals("content")) {
                expressions.content = attribute.getValue();
            }

            // tal:replace
            else if (name.equals("replace")) {
                if (expressions.omitTag == null) {
                    expressions.omitTag = "";
                }
                expressions.content = attribute.getValue();
            }

            // tal:attributes
            else if (name.equals("attributes")) {
                expressions.attributes = attribute.getValue();
            }

            // tal:omit-tag
            else if (name.equals("omit-tag")) {
                expressions.omitTag = attribute.getValue();
            }

            // error
            else {
                throw new PageTemplateException("unknown tal attribute: " + name);
            }
        }
        // else if ( prefix.equals( metalNamespacePrefix ) )
        else if (METAL_NAMESPACE_URI.equals(namespace.getURI())
                || (!strict && METAL_NAMESPACE_PREFIX.equals(namespace.getPrefix()))) {

            // metal:use-macro
            if (name.equals("use-macro")) {
                expressions.useMacro = attribute.getValue();
            }

            // metal:define-slot
            else if (name.equals("define-slot")) {
                expressions.defineSlot = attribute.getValue();
            }

            // metal:define-macro
            else if (name.equals("define-macro")) {
                //System.out.println("Defining macro: " + attribute.getValue());
                Element el = element.createCopy();
                el.remove(attribute);
                macros.put(attribute.getValue(), new MacroImpl(el));
                expressions.macro = true;
            }

            // metal:fill-slot
            else if (name.equals("fill-slot")) {
                // these are ignored here, as they don't affect processing
                // of current template, but are called from other templates
            }

            // error
            else {
                throw new PageTemplateException("unknown metal attribute: " + name);
            }
        }

        // Pass on all other attributes
        else {
            String nsURI = namespace.getURI();
            // String qualifiedName = namespace.getPrefix() + ":" + name;
            attributes.addAttribute(nsURI, name, attribute.getQualifiedName(), "CDATA", attribute.getValue());
            if (nsURI != "" && namespace != elementNamespace) {
                String prefix = namespace.getPrefix();
                String qName = "xmlns:" + prefix;
                if (attributes.getIndex(qName) == -1) {
                    // add xmlns for this attribute
                    attributes.addAttribute("", prefix, qName, "CDATA", nsURI);
                }
            }
            // attributes.addAttribute( getNamespaceURIFromPrefix(prefix),
            // name, qualifiedName, "CDATA", attribute.getValue() );
        }
    }
    return attributes;
}

From source file:com.xebia.mojo.dashboard.util.HtmlUtil.java

License:Apache License

/**
 * Adds a "style" {@link Attribute} containing the passed in styles to an {@link Element}.
 *
 * @param element The {@link Element} to stylize with the styles passed in.
 * @param styles  The value of the "style" {@link Attribute} that needs to be applied to the {@link Element}.
 *///ww  w . j  av  a 2  s.com
public static final void addStyles(Element element, String styles) {
    if (element != null) {
        Attribute attribute = element.attribute("style");

        if (attribute != null) {
            styles += attribute.getValue();
        }

        element.addAttribute("style", styles);
    }
}

From source file:com.zimbra.common.soap.Element.java

License:Open Source License

private org.dom4j.Element toXML(org.dom4j.Element d4parent) {
    org.dom4j.Element d4elt = (d4parent == null ? org.dom4j.DocumentHelper.createElement(getQName())
            : d4parent.addElement(getQName()));
    for (Attribute attr : listAttributes()) {
        d4elt.addAttribute(attr.getKey(), attr.getValue());
    }//  www.  j  av  a  2  s .  co  m
    for (Element elt : listElements()) {
        elt.toXML(d4elt);
    }
    d4elt.setText(getText());
    return d4elt;
}

From source file:com.zimbra.common.soap.Element.java

License:Open Source License

private org.w3c.dom.Node toW3cDom(org.w3c.dom.Document doc, org.w3c.dom.Element parent) {
    String uri = getNamespaceURI(mPrefix);
    if ((uri != null) && uri.equals("urn:zimbraSoap")) {
        uri = null;//from  ww  w .j a  v  a 2s  .  c  o  m
    }
    org.w3c.dom.Element elem;
    elem = doc.createElementNS(uri, getQualifiedName());
    elem.setTextContent(getText());
    if (parent != null) {
        parent.appendChild(elem);
    }

    for (Attribute attr : listAttributes()) {
        elem.setAttribute(attr.getKey(), attr.getValue());
    }
    for (Element elt : listElements()) {
        elt.toW3cDom(doc, elem);
    }
    return elem;
}

From source file:com.zimbra.common.soap.Element.java

License:Open Source License

public static Element convertDOM(org.dom4j.Element d4root, ElementFactory factory) {
    Element elt = factory.createElement(d4root.getQName());
    for (Iterator<?> it = d4root.attributeIterator(); it.hasNext();) {
        org.dom4j.Attribute d4attr = (org.dom4j.Attribute) it.next();
        elt.addAttribute(d4attr.getQualifiedName(), d4attr.getValue());
    }/*from  www.j av a2s.c o  m*/

    for (Iterator<?> it = d4root.elementIterator(); it.hasNext();) {
        org.dom4j.Element d4elt = (org.dom4j.Element) it.next();
        if (XHTML_NS_URI.equalsIgnoreCase(d4elt.getNamespaceURI()) && !d4elt.elements().isEmpty()) {
            // need to treat XHTML as text
            return flattenDOM(d4root, factory);
        } else {
            elt.addNonUniqueElement(convertDOM(d4elt, factory));
        }
    }
    String content = d4root.getText();
    if (content != null && !content.trim().equals("")) {
        try {
            elt.setText(content);
        } catch (ContainerException ce) {
            // can't hold both children and text on a single node, so flatten contents to text
            return flattenDOM(d4root, factory);
        }
    }
    return elt;
}

From source file:com.zimbra.common.soap.Element.java

License:Open Source License

private static Element flattenDOM(org.dom4j.Element d4root, ElementFactory factory) {
    Element elt = factory.createElement(d4root.getQName());
    for (Iterator<?> it = d4root.attributeIterator(); it.hasNext();) {
        org.dom4j.Attribute d4attr = (org.dom4j.Attribute) it.next();
        elt.addAttribute(d4attr.getQualifiedName(), d4attr.getValue());
    }/*from   ww w . j  a  va  2  s .  c om*/

    StringBuilder content = new StringBuilder();
    for (int i = 0, size = d4root.nodeCount(); i < size; i++) {
        org.dom4j.Node node = d4root.node(i);
        switch (node.getNodeType()) {
        case org.dom4j.Node.TEXT_NODE:
            content.append(node.getText());
            break;
        case org.dom4j.Node.ELEMENT_NODE:
            content.append(((org.dom4j.Element) node).asXML());
            break;
        }
    }
    return elt.setText(content.toString());
}

From source file:com.zimbra.cs.account.AttributeManager.java

License:Open Source License

private void loadAttrs(File file, Document doc) {
    Element root = doc.getRootElement();

    if (!root.getName().equals(E_ATTRS)) {
        error(null, file, "root tag is not " + E_ATTRS);
        return;/*from   ww w  .  jav a2 s .  c o  m*/
    }

    Map<Integer, String> idsSeen = new HashMap<Integer, String>();

    String group = root.attributeValue(A_GROUP);
    String groupIdStr = root.attributeValue(A_GROUP_ID);

    if (group == null ^ groupIdStr == null) {
        error(null, file, A_GROUP + " and " + A_GROUP_ID + " both have to be both specified");
    }
    int groupId = -1;
    if (group != null) {
        try {
            groupId = Integer.valueOf(groupIdStr);
        } catch (NumberFormatException nfe) {
            error(null, file, A_GROUP_ID + " is not a number: " + groupIdStr);
        }
    }
    if (groupId == 2) {
        error(null, file, A_GROUP_ID + " is not valid (used by ZimbraObjectClass)");
    } else if (groupId > 0) {
        if (mGroupMap.containsKey(groupId)) {
            error(null, file, "duplicate group id: " + groupId);
        } else if (mGroupMap.containsValue(group)) {
            error(null, file, "duplicate group: " + group);
        } else {
            mGroupMap.put(groupId, group);
        }
    }

    NEXT_ATTR: for (Iterator iter = root.elementIterator(); iter.hasNext();) {
        Element eattr = (Element) iter.next();
        if (!eattr.getName().equals(E_ATTR)) {
            error(null, file, "unknown element: " + eattr.getName());
            continue;
        }

        AttributeCallback callback = null;
        AttributeType type = null;
        AttributeOrder order = null;
        String value = null;
        String min = null;
        String max = null;
        boolean immutable = false;
        //            boolean ignore = false;
        int id = -1;
        String parentOid = null;
        AttributeCardinality cardinality = null;
        Set<AttributeClass> requiredIn = null;
        Set<AttributeClass> optionalIn = null;
        Set<AttributeFlag> flags = null;

        String canonicalName = null;
        String name = eattr.attributeValue(A_NAME);
        if (name == null) {
            error(null, file, "no name specified");
            continue;
        }
        canonicalName = name.toLowerCase();

        List<AttributeServerType> requiresRestart = null;
        Version deprecatedSinceVer = null;
        List<Version> sinceVer = null;
        Boolean ephemeral = false;

        for (Iterator attrIter = eattr.attributeIterator(); attrIter.hasNext();) {
            Attribute attr = (Attribute) attrIter.next();
            String aname = attr.getName();
            if (aname.equals(A_NAME)) {
                // nothing to do - already processed
            } else if (aname.equals(A_CALLBACK)) {
                callback = loadCallback(attr.getValue());
            } else if (aname.equals(A_IMMUTABLE)) {
                immutable = "1".equals(attr.getValue());
            } else if (aname.equals(A_MAX)) {
                max = attr.getValue();
            } else if (aname.equals(A_MIN)) {
                min = attr.getValue();
            } else if (aname.equals(A_TYPE)) {
                type = AttributeType.getType(attr.getValue());
                if (type == null) {
                    error(name, file, "unknown <attr> type: " + attr.getValue());
                    continue NEXT_ATTR;
                }
            } else if (aname.equals(A_VALUE)) {
                value = attr.getValue();
            } else if (aname.equals(A_PARENT_OID)) {
                parentOid = attr.getValue();
                if (!parentOid.matches("^\\d+(\\.\\d+)+"))
                    error(name, file, "invalid parent OID " + parentOid + ": must be an OID");
            } else if (aname.equals(A_ID)) {
                try {
                    id = Integer.parseInt(attr.getValue());
                    if (id < 0) {
                        error(name, file, "invalid id " + id + ": must be positive");
                    }
                } catch (NumberFormatException nfe) {
                    error(name, file, aname + " is not a number: " + attr.getValue());
                }
            } else if (aname.equals(A_CARDINALITY)) {
                try {
                    cardinality = AttributeCardinality.valueOf(attr.getValue());
                } catch (IllegalArgumentException iae) {
                    error(name, file, aname + " is not valid: " + attr.getValue());
                }
            } else if (aname.equals(A_REQUIRED_IN)) {
                requiredIn = parseClasses(name, file, attr.getValue());
            } else if (aname.equals(A_OPTIONAL_IN)) {
                optionalIn = parseClasses(name, file, attr.getValue());
            } else if (aname.equals(A_FLAGS)) {
                flags = parseFlags(name, file, attr.getValue());
            } else if (aname.equals(A_ORDER)) {
                try {
                    order = AttributeOrder.valueOf(attr.getValue());
                } catch (IllegalArgumentException iae) {
                    error(name, file, aname + " is not valid: " + attr.getValue());
                }
            } else if (aname.equals(A_REQUIRES_RESTART)) {
                requiresRestart = parseRequiresRestart(name, file, attr.getValue());

            } else if (aname.equals(A_DEPRECATED_SINCE)) {
                String depreSince = attr.getValue();
                if (depreSince != null) {
                    try {
                        deprecatedSinceVer = new Version(depreSince);
                    } catch (ServiceException e) {
                        error(name, file,
                                aname + " is not valid: " + attr.getValue() + " (" + e.getMessage() + ")");
                    }
                }

            } else if (aname.equals(A_SINCE)) {
                String since = attr.getValue();
                if (since != null) {
                    try {
                        String[] versions = since.split(",");
                        sinceVer = new ArrayList<Version>();
                        for (String verStr : versions) {
                            sinceVer.add(new Version(verStr.trim()));
                        }
                    } catch (ServiceException e) {
                        error(name, file,
                                aname + " is not valid: " + attr.getValue() + " (" + e.getMessage() + ")");
                    }
                }
            } else {
                error(name, file, "unknown <attr> attr: " + aname);
            }
        }

        List<String> globalConfigValues = new LinkedList<String>();
        List<String> globalConfigValuesUpgrade = null; // note: init to null instead of empty List
        List<String> defaultCOSValues = new LinkedList<String>();
        List<String> defaultExternalCOSValues = new LinkedList<String>();
        List<String> defaultCOSValuesUpgrade = null; // note: init to null instead of empty List
        String description = null;
        String deprecateDesc = null;

        for (Iterator elemIter = eattr.elementIterator(); elemIter.hasNext();) {
            Element elem = (Element) elemIter.next();
            if (elem.getName().equals(E_GLOBAL_CONFIG_VALUE)) {
                globalConfigValues.add(elem.getText());
            } else if (elem.getName().equals(E_GLOBAL_CONFIG_VALUE_UPGRADE)) {
                if (globalConfigValuesUpgrade == null)
                    globalConfigValuesUpgrade = new LinkedList<String>();
                globalConfigValuesUpgrade.add(elem.getText());
            } else if (elem.getName().equals(E_DEFAULT_COS_VALUE)) {
                defaultCOSValues.add(elem.getText());
            } else if (elem.getName().equals(E_DEFAULT_EXTERNAL_COS_VALUE)) {
                defaultExternalCOSValues.add(elem.getText());
            } else if (elem.getName().equals(E_DEFAULT_COS_VALUE_UPGRADE)) {
                if (defaultCOSValuesUpgrade == null)
                    defaultCOSValuesUpgrade = new LinkedList<String>();
                defaultCOSValuesUpgrade.add(elem.getText());
            } else if (elem.getName().equals(E_DESCRIPTION)) {
                if (description != null) {
                    error(name, file, "more than one " + E_DESCRIPTION);
                }
                description = elem.getText();
            } else if (elem.getName().equals(E_DEPRECATE_DESC)) {
                if (deprecateDesc != null) {
                    error(name, file, "more than one " + E_DEPRECATE_DESC);
                }
                deprecateDesc = elem.getText();
            } else {
                error(name, file, "unknown element: " + elem.getName());
            }
        }

        if (deprecatedSinceVer != null && deprecateDesc == null)
            error(name, file, "missing element " + E_DEPRECATE_DESC);
        else if (deprecatedSinceVer == null && deprecateDesc != null)
            error(name, file, "missing attr " + A_DEPRECATED_SINCE);

        if (deprecatedSinceVer != null) {
            String deprecateInfo = "Deprecated since: " + deprecatedSinceVer.toString() + ".  " + deprecateDesc;
            if (description == null)
                description = deprecateInfo;
            else
                description = deprecateInfo + ".  Orig desc: " + description;
        }

        // since is required after(inclusive) oid 525 - first attribute in 5.0
        if (sinceVer == null && id >= 525) {
            error(name, file, "missing since (required after(inclusive) oid 710)");
        }

        // Check that if id is specified, then cardinality is specified.
        if (id > 0 && cardinality == null) {
            error(name, file, "cardinality not specified");
        }

        // Check that if id is specified, then at least one object class is defined
        if (id > 0 && (optionalIn != null && optionalIn.isEmpty())
                && (requiredIn != null && requiredIn.isEmpty())) {
            error(name, file,
                    "atleast one of " + A_REQUIRED_IN + " or " + A_OPTIONAL_IN + " must be specified");
        }

        // Check that if id is specified, it must be unique
        if (id > 0) {
            String idForAttr = idsSeen.get(Integer.valueOf(id));
            if (idForAttr != null) {
                error(name, file, "duplicate id: " + id + " is already used for " + idForAttr);
            } else {
                idsSeen.put(Integer.valueOf(id), name);
            }
        }

        // Check that if it is COS inheritable it is in account and COS classes
        checkFlag(name, file, flags, AttributeFlag.accountInherited, AttributeClass.account, AttributeClass.cos,
                null, requiredIn, optionalIn);

        // Check that if it is COS-domain inheritable it is in account and COS and domain classes
        checkFlag(name, file, flags, AttributeFlag.accountCosDomainInherited, AttributeClass.account,
                AttributeClass.cos, AttributeClass.domain, requiredIn, optionalIn);

        // Check that if it is domain inheritable it is in domain and global config
        checkFlag(name, file, flags, AttributeFlag.domainInherited, AttributeClass.domain,
                AttributeClass.globalConfig, null, requiredIn, optionalIn);

        // Check that if it is server inheritable it is in server and global config
        checkFlag(name, file, flags, AttributeFlag.serverInherited, AttributeClass.server,
                AttributeClass.globalConfig, null, requiredIn, optionalIn);

        // Check that if it is serverPreferAlwaysOn it is in server and alwaysOnCluster
        checkFlag(name, file, flags, AttributeFlag.serverPreferAlwaysOn, AttributeClass.server,
                AttributeClass.alwaysOnCluster, null, requiredIn, optionalIn);

        // Check that is cardinality is single, then not more than one
        // default value is specified
        if (cardinality == AttributeCardinality.single) {
            if (globalConfigValues.size() > 1) {
                error(name, file, "more than one global config value specified for cardinality "
                        + AttributeCardinality.single);
            }
            if (defaultCOSValues.size() > 1 || defaultExternalCOSValues.size() > 1) {
                error(name, file, "more than one default COS value specified for cardinality "
                        + AttributeCardinality.single);
            }
        }

        checkEphemeralFlags(name, file, flags, min, max, cardinality);

        AttributeInfo info = createAttributeInfo(name, id, parentOid, groupId, callback, type, order, value,
                immutable, min, max, cardinality, requiredIn, optionalIn, flags, globalConfigValues,
                defaultCOSValues, defaultExternalCOSValues, globalConfigValuesUpgrade, defaultCOSValuesUpgrade,
                mMinimize ? null : description, requiresRestart, sinceVer, deprecatedSinceVer);

        if (mAttrs.get(canonicalName) != null) {
            error(name, file, "duplicate definiton");
        }
        mAttrs.put(canonicalName, info);

        if (flags != null) {
            for (AttributeFlag flag : flags) {
                mFlagToAttrsMap.get(flag).add(name);
                if (flag == AttributeFlag.accountCosDomainInherited)
                    mFlagToAttrsMap.get(AttributeFlag.accountInherited).add(name);
            }
        }

        if (requiredIn != null || optionalIn != null) {
            if (requiredIn != null) {
                for (AttributeClass klass : requiredIn) {
                    mClassToAttrsMap.get(klass).add(name);
                    mClassToLowerCaseAttrsMap.get(klass).add(name.toLowerCase());
                }
            }
            if (optionalIn != null) {
                for (AttributeClass klass : optionalIn) {
                    mClassToAttrsMap.get(klass).add(name);
                    mClassToLowerCaseAttrsMap.get(klass).add(name.toLowerCase());
                }
            }
        }

        if (isBinaryType(type)) {
            mBinaryAttrs.add(canonicalName);
        } else if (isBinaryTransferType(type)) {
            mBinaryTransferAttrs.add(canonicalName);
        }

        if (flags != null && flags.contains(AttributeFlag.ephemeral)) {
            mEphemeralAttrs.put(canonicalName, info);
            mEphemeralAttrsSet.add(name);
            if (!info.isDynamic()) {
                addNonDynamicEphemeralAttr(info);
            }
        }
    }
}