Example usage for org.dom4j Namespace getText

List of usage examples for org.dom4j Namespace getText

Introduction

In this page you can find the example usage for org.dom4j Namespace getText.

Prototype

public String getText() 

Source Link

Usage

From source file:com.cladonia.xml.viewer.XmlElementNode.java

License:Mozilla Public License

private StyledElement formatNamespace(Namespace n) {
    StyledElement styledNamespace = null;

    String prefix = n.getPrefix();
    String value = n.getText();

    if (value != null && value.length() > 0) {
        styledNamespace = new StyledElement();
        styledNamespace.addString(NAMESPACE_NAME);

        if (prefix != null && prefix.length() > 0) {
            styledNamespace.addString(NAMESPACE_COLON);
            styledNamespace.addString(new NamespacePrefix(prefix));
        }//from ww w .ja v a2  s.  c o  m

        styledNamespace.addString(NAMESPACE_ASIGN);
        styledNamespace.addString(new NamespaceURI(value));
    }

    return styledNamespace;
}

From source file:com.cladonia.xml.xdiff.XmlElementNode.java

License:Open Source License

private StyledElement formatNamespace(Namespace n) {
    StyledElement styledNamespace = null;

    String prefix = n.getPrefix();
    String value = n.getText();
    String name = "xmlns:" + prefix;

    boolean localInsertNamespace = false;
    boolean localDeleteNamespace = false;

    if (findAttribute(name, insertAttributes) || insideInsertChain(this)) {
        localInsertNamespace = true;/* w  ww  . j  a  va 2s .  c o  m*/
        currentColor = COLOR_GREEN;
    } else if (findAttribute(name, deleteAttributes) || insideDeleteChain(this)) {
        localDeleteNamespace = true;
        currentColor = Color.RED;
    } else if (merged || insideInsertMergeChain(getXmlElementNodeParent())) {
        currentColor = COLOR_MERGED;
    } else {
        currentColor = Color.BLACK;
    }

    if (value != null && value.length() > 0) {
        styledNamespace = new StyledElement();

        if (localInsertNamespace) {
            styledNamespace.addString(INSERT_NAMESPACE_NAME);
        } else if (localDeleteNamespace) {
            styledNamespace.addString(DELETE_NAMESPACE_NAME);
        } else if (merged || insideInsertMergeChain(getXmlElementNodeParent())) {
            styledNamespace.addString(MERGED_NAMESPACE_NAME);
        } else {
            styledNamespace.addString(NAMESPACE_NAME);
        }

        if (prefix != null && prefix.length() > 0) {

            if (localInsertNamespace) {
                styledNamespace.addString(INSERT_NAMESPACE_COLON);
            } else if (localDeleteNamespace) {
                styledNamespace.addString(DELETE_NAMESPACE_COLON);
            } else if (merged || insideInsertMergeChain(getXmlElementNodeParent())) {
                styledNamespace.addString(MERGED_NAMESPACE_COLON);
            } else {
                styledNamespace.addString(NAMESPACE_COLON);
            }

            styledNamespace.addString(new NamespacePrefix(prefix));
        }

        if (localInsertNamespace) {
            styledNamespace.addString(INSERT_NAMESPACE_ASIGN);
            styledNamespace.addString(INSERT_NAMESPACE_QUOTE);
        } else if (localDeleteNamespace) {
            styledNamespace.addString(DELETE_NAMESPACE_ASIGN);
            styledNamespace.addString(DELETE_NAMESPACE_QUOTE);
        } else if (merged || insideInsertMergeChain(getXmlElementNodeParent())) {
            styledNamespace.addString(MERGED_NAMESPACE_ASIGN);
            styledNamespace.addString(MERGED_NAMESPACE_QUOTE);
        } else {
            styledNamespace.addString(NAMESPACE_ASIGN);
            styledNamespace.addString(NAMESPACE_QUOTE);
        }

        String namespacePrevious = findUpdatedAttribute(name, updateAttributes);
        if (namespacePrevious != null) {
            StyledString updatedValue = new AttributePreviousValue(namespacePrevious);
            updatedValue.setStrikeThrough(true);
            styledNamespace.addString(updatedValue);

            currentColor = Color.BLUE;
        }

        styledNamespace.addString(new NamespaceURI(value));

        if (localInsertNamespace) {
            styledNamespace.addString(INSERT_NAMESPACE_QUOTE);
        } else if (localDeleteNamespace) {
            styledNamespace.addString(DELETE_NAMESPACE_QUOTE);
        } else if (merged || insideInsertMergeChain(getXmlElementNodeParent())) {
            styledNamespace.addString(MERGED_NAMESPACE_QUOTE);
        } else {
            styledNamespace.addString(NAMESPACE_QUOTE);
        }
    }

    currentColor = Color.BLACK;
    return styledNamespace;
}

From source file:org.lushlife.guicexml.internal.property.PropertyManagement.java

License:Apache License

public Class<?> toClass(Namespace namespace, String className) {
    String packageName = this.namespace.get(namespace.getText());
    if (packageName == null) {
        throw new IllegalArgumentException("don't bind namespace " + namespace);
    }//ww  w.j  ava2  s . c om
    return toClass(packageName, className);
}

From source file:org.lushlife.guicexml.XmlModule.java

License:Apache License

@Override
protected void configure() {
    InputStream stream = null;//from  www.  java  2  s . c  o m
    try {
        log.log(GuiceXmlLogMessage.READ_XML_FILE, url);
        if (url == null) {
            return;
        }
        stream = url.openStream();
        if (stream == null) {
            return;
        }
        Element rootElement = XML.getRootElement(stream);
        for (Object obj : rootElement.elements()) {
            Element element = (Element) obj;

            if (Boolean.valueOf(element.attributeValue("disabled"))) {
                log.log(GuiceXmlLogMessage.DISABLED, element.asXML());
                configure();
            }

            Namespace namespace = element.getNamespace();
            // no namespace
            if (namespace.getText().isEmpty()) {
                configureDefaultNameSpace(element);
                continue;
            }
            // default namespace
            if ("http://code.google.com/p/guice-xml".equals(namespace.getStringValue())) {
                configureDefaultNameSpace(element);
                continue;
            }
            // urn import
            if (namespace.getText().startsWith("urn:import:")) {
                String packageName = namespace.getText().substring("urn:import:".length());
                String className = element.getName();
                ComponentXmlReader.create(packageName, className, element, propertyManagement)
                        .bind(this.binder());
                continue;
            }
            // NameSpaceBinding
            ComponentXmlReader.create(namespace, element.getName(), element, propertyManagement)
                    .bind(this.binder());

        }
    } catch (Exception e) {
        addError(e);
    } finally {
        if (stream != null) {
            try {
                stream.close();
            } catch (IOException e) {
            }
        }
    }
}