Code example for Attr

Methods: getNamegetValue

0
     */ 
    public static int getAttributeValueRangeStart( 
            @NonNull Attr attr,
            @NonNull IDocument document) {
        IndexedRegion region = (IndexedRegion) attr;
        int potentialStart = attr.getName().length() + 2; // + 2: add ="
        String text;
        try { 
            text = document.get(region.getStartOffset(),
                    region.getEndOffset() - region.getStartOffset());
        } catch (BadLocationException e) {
            return -1; 
        } 
        String value = attr.getValue();
        int index = text.indexOf(value, potentialStart);
        if (index != -1) {
            return region.getStartOffset() + index;
        } else { 
            return -1; 
        }