Package eu.bandm.tools.util.java
Class Identifiers
java.lang.Object
eu.bandm.tools.util.java.Identifiers
Auxiliary methods for identifiers.
- Since:
- 1.3
-
Field Summary
FieldsModifier and TypeFieldDescriptionAll Java contextual keywords according to Java language specification 2.2, section 3.9.All Java reserved keywords according to Java language specification 2.2, section 3.9. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Opt PreMessagehasValidIdentifierStructure(String identifier) Return whether the given string has the structure of a a valid Java identifier.static @Opt PreMessageisValidIdentifier(String identifier) Return whether the given string is a valid Java identifier.static @Opt PreMessageisValidIdentifierAndNoKeyword(String identifier) Return whether the given string is a valid java identifier and additionally not a contextual keyword.
-
Field Details
-
reservedKeyWords
All Java reserved keywords according to Java language specification 2.2, section 3.9. -
contextualKeyWords
All Java contextual keywords according to Java language specification 2.2, section 3.9.
-
-
Method Details
-
hasValidIdentifierStructure
Return whether the given string has the structure of a a valid Java identifier. This is determined according to the Java language specification 2.2, sections 3.8, not considerung the requirment of not being a reserved word.This implementation uses
Character.isJavaIdentifierStart(char)andCharacter.isJavaIdentifierPart(char).- Parameters:
identifier- to test- Returns:
- an error message or null on success
- See Also:
-
isValidIdentifier
Return whether the given string is a valid Java identifier. This is determined according to the Java language specification 2.2, sections 3.8 and 3.9: Return whether the identifier is accepted byhasValidIdentifierStructure(java.lang.String)and is not a reserved word.- Parameters:
identifier- to test- Returns:
- an error message or null on success
-
isValidIdentifierAndNoKeyword
Return whether the given string is a valid java identifier and additionally not a contextual keyword. This is determined according to the Java language specification 2.2, sections 3.8 and 3.9. Returns whetherisValidIdentifier(String)accepts the identifier, and it is not contained incontextualKeyWords.- Parameters:
identifier- to test- Returns:
- an error message or null on success
-