litesoft
Diff Revisions
969
vs
970
for /trunk/DeviceDesktopTest/src/org/litesoft/language/model/Key.java
|
@@ -2,7 +2,7 @@ |
2 |
2 |
|
|
3 |
3 |
|
import org.litesoft.commonfoundation.annotations.*; |
4 |
4 |
|
import org.litesoft.commonfoundation.base.*; |
5 |
|
- |
import org.litesoft.commonfoundation.issues.*; |
|
5 |
+ |
import org.litesoft.commonfoundation.problems.*; |
6 |
6 |
|
import org.litesoft.commonfoundation.typeutils.*; |
7 |
7 |
|
|
8 |
8 |
|
/** |
|
@@ -10,6 +10,8 @@ |
10 |
10 |
|
* dots ('.'). |
11 |
11 |
|
*/ |
12 |
12 |
|
public class Key { |
|
13 |
+ |
enum Code {Empty, Invalid} |
|
14 |
+ |
|
13 |
15 |
|
public Key( @SignificantText String pKey ) { |
14 |
16 |
|
Problem zProblem = validate( key = pKey ); |
15 |
17 |
|
if ( zProblem != null ) { |
|
@@ -23,13 +25,13 @@ |
23 |
25 |
|
|
24 |
26 |
|
public static @Nullable Problem validate( String pKey ) { |
25 |
27 |
|
if ( Currently.isNullOrEmpty( pKey ) ) { |
26 |
|
- |
return new Problem( "Empty" ); |
|
28 |
+ |
return new Problem( Code.Empty ); |
27 |
29 |
|
} |
28 |
30 |
|
String[] zParts = Strings.parseChar( pKey, '.' ); |
29 |
31 |
|
for ( int i = 0; i < zParts.length; i++ ) { |
30 |
32 |
|
String zPart = zParts[i]; |
31 |
33 |
|
if ( !Strings.isConstrainedAsciiIdentifier( zPart ) ) { |
32 |
|
- |
return new Problem.Builder( "Invalid" ) |
|
34 |
+ |
return new Problem.Builder( Code.Invalid ) |
33 |
35 |
|
.add( "Part", i ) |
34 |
36 |
|
.add( "At", pKey.indexOf( zPart ) ) |
35 |
37 |
|
.build(); |