1 package net.sf.saxon; 2 3 6 7 public class Err { 8 9 public static final int ELEMENT = 1; 10 public static final int ATTRIBUTE = 2; 11 public static final int FUNCTION = 3; 12 public static final int VALUE = 4; 13 public static final int VARIABLE = 5; 14 public static final int GENERAL = 6; 15 16 21 public static String wrap(CharSequence cs) { 22 return wrap(cs, GENERAL); 23 } 24 25 31 public static String wrap(CharSequence cs, int valueType) { 32 if (cs == null) { 33 return "(NULL)"; 34 } 35 String s = cs.toString(); 36 s = s.replace('\n', ' '); 37 s = s.replace('\t', ' '); 38 s = s.replace('\r', ' '); 39 if (s.length() > 30) { 40 s = s.substring(0, 30) + "..."; 41 } 42 switch (valueType) { 43 case ELEMENT: 44 return "<" + s + ">"; 45 case ATTRIBUTE: 46 return "@" + s; 47 case FUNCTION: 48 return s + "()"; 49 case VARIABLE: 50 return "$" + s; 51 case VALUE: 52 return "\"" + s + "\""; 53 default: 54 return "{" + s + "}"; 55 } 56 } 57 58 } 59 | Popular Tags |