1 5 package com.teamkonzept.publishing.markups; 6 7 public class TKMarkupCharParamClass extends TKMarkupParamClass { 8 9 public String checkValue (String raw) { 10 11 if (raw == null) return raw; 12 13 String value = raw.trim(); 14 15 if (value.length() == 1) return value; 16 else return null; 17 } 18 19 public int parseUnquotedValue (String text, int pos, StringBuffer value) 20 throws TKMarkupParserException { 21 22 if (value != null) value.setLength (0); 23 24 int oldPos = pos; 25 pos = parsePattern (text,pos,null,"'"); 26 if (pos <= oldPos) return oldPos; 27 28 if (pos < text.length()) { 29 30 char chr = text.charAt (pos); 31 32 if ((chr == '\\') && (pos+1 < text.length())) { 33 34 if (value == null) pos++; 35 else value.append (text.charAt (++pos)); 36 37 } else if (value != null) value.append (chr); 38 39 pos++; 40 } 41 42 int nextOldPos = pos; 43 pos = parsePattern (text,pos,null,"'"); 44 45 if (pos <= nextOldPos) return oldPos; 46 else return pos; 47 } 48 49 public String wrapValue (String value) { 50 51 if ((value == null) || (value.length() == 0)) return null; 52 53 StringBuffer buf = new StringBuffer (); 54 55 char chr = value.charAt(0); 56 57 if (chr == '\'') return "'\\''"; 58 else if (chr == '\'') return "'\\\\'"; 59 60 buf.append ('\'').append(chr).append('\''); 61 62 return buf.toString(); 63 } 64 } 65 66 | Popular Tags |