01: /*
02: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
03: *
04: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
05: *
06: * The contents of this file are subject to the terms of either the GNU
07: * General Public License Version 2 only ("GPL") or the Common
08: * Development and Distribution License("CDDL") (collectively, the
09: * "License"). You may not use this file except in compliance with the
10: * License. You can obtain a copy of the License at
11: * http://www.netbeans.org/cddl-gplv2.html
12: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13: * specific language governing permissions and limitations under the
14: * License. When distributing the software, include this License Header
15: * Notice in each file and include the License file at
16: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
17: * particular file as subject to the "Classpath" exception as provided
18: * by Sun in the GPL Version 2 section of the License file that
19: * accompanied this code. If applicable, add the following below the
20: * License Header, with the fields enclosed by brackets [] replaced by
21: * your own identifying information:
22: * "Portions Copyrighted [year] [name of copyright owner]"
23: *
24: * Contributor(s):
25: *
26: * Portions Copyrighted 2007 Sun Microsystems, Inc.
27: */
28: package org.netbeans.spi.editor.highlighting;
29:
30: import javax.swing.text.Document;
31: import javax.swing.text.JTextComponent;
32:
33: /**
34: * Lazy evaluator for attribute values. It is up to each particular attribute
35: * to declare if its values can be lazily evaluated. Attributes that declare
36: * themselvs as supporting lazy evaluation can have their values specified either
37: * directly or through <code>HighlightAttributeValue</code>. All users of such an attribute
38: * must check for both the direct value and the lazy evaluator and use them
39: * accordingly.
40: *
41: * <p class="nonnormative">If an attribute supports
42: * lazy evaluation the result of <code>getValue</code> call should have the same
43: * type as if the attribute value were specified directly. For example, the
44: * <code>EditorStyleConstants.Tooltip</code> attribute supports lazy evaluation
45: * and its value can either be <code>String</code> or <code>HighlightAttributeValue<String></code>.
46: *
47: * @author Vita Stejskal
48: * @since 1.5
49: */
50: public interface HighlightAttributeValue<T> {
51:
52: /**
53: * Gets value of an attribute.
54: *
55: * @param component The text component, which highlighting layer supplied a highlight
56: * with an attribute using this evaluator as its value.
57: * @param document The document, which highlighting layer supplied a highlight
58: * with an attribute using this evaluator as its value.
59: * @param attributeKey The key of the attribute.
60: * @param startOffset The start offset of the original highlight or any other offset
61: * inside the highlight. Always less than <code>endOffset</code>.
62: * @param endOffset The end offset of the original highlight or any other offset
63: * inside the highlight. Always greater than <code>startOffset</code>.
64: *
65: * @return The value of the <code>attributeKey</code> attribute.
66: */
67: T getValue(JTextComponent component, Document document,
68: Object attributeKey, int startOffset, int endOffset);
69:
70: }
|