站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc (Current Development Version)

InputAttributes (Lexer) - NetBeans API Javadoc (Current Development Version)

org.netbeans.modules.lexer/2 1.19.0 1

org.netbeans.api.lexer
Class InputAttributes

java.lang.Object
  extended by org.netbeans.api.lexer.InputAttributes

public final class InputAttributes
extends Object

Supplementary information about particular input that may be used to influence the lexer's operation.
For example there may be a version of the language to be used when lexing the input. The following code will interpret the "assert" as an identifier:

  InputAttributes attrs = new InputAttributes();
  attrs.setValue(JavaTokenId.language(), "version", "1.3", true);
  TokenHierarchy.create("assert", false, JavaTokenId.language(), null, attrs);
 

The properties are attached to a concrete language path only or they may be applied globally to all of the occurrences of the given path as a sub-path of the target path.
See the "global" argument of setValue(Language,Object,Object,boolean).

This class may safely be operated by multiple threads.


Constructor Summary
InputAttributes()
           
 
Method Summary
 Object getValue(LanguagePath languagePath, Object attributeKey)
          Get value for the given key for the particular language path.
 void setValue(Language<? extends TokenId> language, Object attributeKey, Object attributeValue, boolean global)
          Assign a new value to a property for the language path constructed from the given language.
 void setValue(LanguagePath languagePath, Object attributeKey, Object attributeValue, boolean global)
          Assign a new value to a property for the given language path.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InputAttributes

public InputAttributes()
Method Detail

getValue

public Object getValue(LanguagePath languagePath,
                       Object attributeKey)
Get value for the given key for the particular language path.
If (for the given key) there was an explicit value set directly for the given language path then it will be returned.
If not and there was a global value set for one of the sub-paths (from the largest to the smallest) then it will be returned.

Parameters:
languagePath - non-null language path.
attributeKey - non-null key of the attribute.
Returns:
value of the key for the given language path (or a global value for one of the subpaths).

setValue

public void setValue(Language<? extends TokenId> language,
                     Object attributeKey,
                     Object attributeValue,
                     boolean global)
Assign a new value to a property for the language path constructed from the given language.

See Also:
setValue(LanguagePath, Object, Object, boolean)

setValue

public void setValue(LanguagePath languagePath,
                     Object attributeKey,
                     Object attributeValue,
                     boolean global)
Assign a new value to a property for the given language path.

Parameters:
languagePath - non-null language path.
attributeKey - non-null key of the attribute.
attributeValue - value of the key for the given language path.
global - if set to true then the value will be used not only for the given language path but also as a default value (if the value is not overwritten explicitly) for all the cases where the given path is embedded into the target language path.
The following code
  attrs.setValue(LanguagePath.get(JavaTokenId.language()),
      "version", Integer.valueOf(5), true);
  
sets the version 5 (it means java 1.5) to all the java code snipets regardless of where they are embedded in the token hierarchy.

org.netbeans.modules.lexer/2 1.19.0 1

Built on May 28 2007.  |  Portions Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.