Example usage for org.springframework.ide.eclipse.core StringUtils isQuoted

List of usage examples for org.springframework.ide.eclipse.core StringUtils isQuoted

Introduction

In this page you can find the example usage for org.springframework.ide.eclipse.core StringUtils isQuoted.

Prototype

public static boolean isQuoted(String string) 

Source Link

Document

Returns true if given string has a leading and trailing single or double quote character.

Usage

From source file:org.dozer.eclipse.plugin.sourcepage.hyperlink.DozerClassHyperlinkDetector.java

@SuppressWarnings("restriction")
protected final IRegion getHyperlinkRegion(Node node) {
    if (node != null) {
        switch (node.getNodeType()) {
        case Node.DOCUMENT_TYPE_NODE:
        case Node.TEXT_NODE:
            IDOMNode docNode = (IDOMNode) node;
            return new Region(docNode.getStartOffset(), docNode.getEndOffset() - docNode.getStartOffset());

        case Node.ELEMENT_NODE:
            IDOMElement element = (IDOMElement) node;
            int endOffset;
            if (element.hasEndTag() && element.isClosed()) {
                endOffset = element.getStartEndOffset();
            } else {
                endOffset = element.getEndOffset();
            }//from ww w  .  ja v a 2 s. c  om
            return new Region(element.getStartOffset(), endOffset - element.getStartOffset());

        case Node.ATTRIBUTE_NODE:
            IDOMAttr att = (IDOMAttr) node;
            // do not include quotes in attribute value region
            int regOffset = att.getValueRegionStartOffset();
            int regLength = att.getValueRegionText().length();
            String attValue = att.getValueRegionText();
            if (StringUtils.isQuoted(attValue)) {
                regOffset += 1;
                regLength = regLength - 2;
            }
            return new Region(regOffset, regLength);
        }
    }
    return null;
}