IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
IKVM.CoreLib.Modules.Identifer Class Reference

Provides various methods for working with Java identifiers. More...

Static Public Member Functions

static bool IsPackageName (string name)
 Returns true if the given name is a legal package name.
 
static bool IsPackageName (ReadOnlySpan< char > name)
 Returns true if the given name is a legal package name.
 
static bool IsClassName (string name)
 Returns true if the given name is a legal class name.
 
static bool IsClassName (ReadOnlySpan< char > name)
 Returns true if the given name is a legal class name.
 
static bool IsTypeName (ReadOnlySpan< char > name)
 Returns true if name is a valid Java type name.
 
static bool IsJavaIdentifier (ReadOnlySpan< char > value)
 Returns true if the given string is a legal Java identifier, otherwise false.
 

Detailed Description

Provides various methods for working with Java identifiers.

Definition at line 10 of file Identifer.cs.

Member Function Documentation

◆ IsClassName() [1/2]

static bool IKVM.CoreLib.Modules.Identifer.IsClassName ( ReadOnlySpan< char > name)
static

Returns true if the given name is a legal class name.

Parameters
name
Returns

Definition at line 57 of file Identifer.cs.

58 {
59 return IsTypeName(name);
60 }
static bool IsTypeName(ReadOnlySpan< char > name)
Returns true if name is a valid Java type name.
Definition Identifer.cs:67

◆ IsClassName() [2/2]

static bool IKVM.CoreLib.Modules.Identifer.IsClassName ( string name)
static

Returns true if the given name is a legal class name.

Parameters
name
Returns

Definition at line 47 of file Identifer.cs.

48 {
49 return IsClassName(name.AsSpan());
50 }
static bool IsClassName(string name)
Returns true if the given name is a legal class name.
Definition Identifer.cs:47

◆ IsJavaIdentifier()

static bool IKVM.CoreLib.Modules.Identifer.IsJavaIdentifier ( ReadOnlySpan< char > value)
static

Returns true if the given string is a legal Java identifier, otherwise false.

Definition at line 86 of file Identifer.cs.

87 {
88 if (value.IsWhiteSpace())
89 return false;
90
91 foreach (var i in RESERVED)
92 if (value.SequenceEqual(i))
93 return false;
94
95 // TODO this isn't fully implemented
96 return true;
97
98 //int first = Rune.GetRuneAt(value, 0);
99 //if (!Character.isJavaIdentifierStart(first))
100 // return false;
101
102 //int i = Character.charCount(first);
103 //while (i < value.length())
104 //{
105 // int cp = Character.codePointAt(value, i);
106 // if (!Character.isJavaIdentifierPart(cp))
107 // return false;
108 // i += Character.charCount(cp);
109 //}
110
111 //return true;
112 }

◆ IsPackageName() [1/2]

static bool IKVM.CoreLib.Modules.Identifer.IsPackageName ( ReadOnlySpan< char > name)
static

Returns true if the given name is a legal package name.

Parameters
name
Returns

Definition at line 37 of file Identifer.cs.

38 {
39 return IsTypeName(name);
40 }

◆ IsPackageName() [2/2]

static bool IKVM.CoreLib.Modules.Identifer.IsPackageName ( string name)
static

Returns true if the given name is a legal package name.

Parameters
name
Returns

Definition at line 27 of file Identifer.cs.

28 {
29 return IsPackageName(name.AsSpan());
30 }
static bool IsPackageName(string name)
Returns true if the given name is a legal package name.
Definition Identifer.cs:27

◆ IsTypeName()

static bool IKVM.CoreLib.Modules.Identifer.IsTypeName ( ReadOnlySpan< char > name)
static

Returns true if name is a valid Java type name.

Parameters
name
Returns

Definition at line 67 of file Identifer.cs.

68 {
69 int next;
70 int off = 0;
71 while ((next = name[off..].IndexOf(['.'])) != -1)
72 {
73 var id = name.Slice(off, next);
74 if (IsJavaIdentifier(id) == false)
75 return false;
76
77 off = next + 1;
78 }
79
80 return IsJavaIdentifier(name[off..]);
81 }
static bool IsJavaIdentifier(ReadOnlySpan< char > value)
Returns true if the given string is a legal Java identifier, otherwise false.
Definition Identifer.cs:86

The documentation for this class was generated from the following file: