public static String serialize(Expression expr, Map prefixMapping) { FastStringBuffer result = new FastStringBuffer(64); final Map<String, String> reversePrefixMapping = new HashMap<String, String>(); for (Iterator<Map.Entry<String, String>> it = prefixMapping.entrySet().iterator(); it.hasNext(); ) { Map.Entry<String, String> entry = it.next(); reversePrefixMapping.put(entry.getValue(), entry.getKey()); } serialize(result, expr, reversePrefixMapping); return result.toString(); }
public String getStringValue() { FastStringBuffer sb = new FastStringBuffer(16); sb.append("--"); DateTimeValue.appendString(sb, calendar.get(Calendar.MONTH) + 1, 2); sb.append('-'); DateTimeValue.appendString(sb, calendar.get(Calendar.DATE), 2); if (zoneSpecified) { DateTimeValue.appendTimezone(tzOffset, sb); } return sb.toString(); }
private static String fixPreFixes(String xpath, Map<String, String> reversePrefixMapping) { FastStringBuffer result = new FastStringBuffer(xpath.length()); Matcher m = Pattern.compile("\\{[^\\}]+\\}").matcher(xpath); int iLast = 0; while (m.find()) { result.append(xpath.substring(iLast, m.start())); final String match = m.group(); result.append(reversePrefixMapping.get(match.substring(1, match.length() - 1))); result.append(':'); iLast = m.end(); } result.append(xpath.substring(iLast)); return result.toString(); }