KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > teamkonzept > publishing > markups > TKMarkupIdentifierParamClass


1 /*
2  * $Header: /cvsroot/webman-cms/source/webman/com/teamkonzept/publishing/markups/TKMarkupIdentifierParamClass.java,v 1.5 2000/05/22 15:01:28 careck Exp $
3  *
4  */

5 package com.teamkonzept.publishing.markups;
6
7 public class TKMarkupIdentifierParamClass extends TKMarkupParamClass {
8
9     private static final String JavaDoc identifierFirstCodes = "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
10     private static final String JavaDoc identifierCodes = identifierFirstCodes+"0123456789";
11
12     public String JavaDoc checkValue (String JavaDoc raw) {
13
14         if (raw == null) return raw;
15         
16         String JavaDoc value = raw.trim();
17
18         int pos = 0;
19         while (pos < value.length()) {
20         
21             char chr = value.charAt (pos++);
22             
23             if (pos == 1) {
24                 if (identifierFirstCodes.indexOf(chr) == -1) return null;
25             } else if (identifierCodes.indexOf(chr) == -1) return null;
26         }
27
28         return value;
29     }
30
31     public int parseUnquotedValue (String JavaDoc text, int pos, StringBuffer JavaDoc value)
32         throws TKMarkupParserException {
33     
34         if (value != null) value.setLength (0);
35         
36         while (pos < text.length()) {
37         
38             char chr = text.charAt (pos);
39
40             if ((pos == 0) && (identifierFirstCodes.indexOf(chr) == -1)) break;
41             else if ((pos != 0) && (identifierCodes.indexOf(chr) == -1)) break;
42             
43             if (value != null) value.append (chr);
44
45             pos++;
46         }
47
48         return pos;
49     }
50
51     public String JavaDoc wrapValue (String JavaDoc value) {
52
53         return value;
54     }
55 }
56
57
Popular Tags