1 5 package com.teamkonzept.publishing.markups; 6 7 public class TKMarkupIdentifierParamClass extends TKMarkupParamClass { 8 9 private static final String identifierFirstCodes = "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; 10 private static final String identifierCodes = identifierFirstCodes+"0123456789"; 11 12 public String checkValue (String raw) { 13 14 if (raw == null) return raw; 15 16 String 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 text, int pos, StringBuffer 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 wrapValue (String value) { 52 53 return value; 54 } 55 } 56 57 | Popular Tags |