code: public static String toWellFormed(String value) {
          if (value == null) {
              return LogicalValue.ANY.getAbbreviation();
          }
          if (LogicalValue.ANY.getAbbreviation().equals(value)
                  || LogicalValue.NA.getAbbreviation().equals(value)) {
              return value;
          }
          //return value.replaceAll("([^0-9A-Za-z])", "\\\\$1");
          StringBuilder buffer = new StringBuilder(value);
          for (int x = 0; x < buffer.length(); x++) {
              char c = buffer.charAt(x);
              if (!((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9'))) {
                  buffer.insert(x++, '\\');
              }
          }
          return buffer.toString();
      }
docs: Transforms the given string into a "well formed string". A well formed
  string has all non-alphanumeric characters escaped with a backslash. If a
  <code>null</code> value is passed in the default {@link LogicalValue#ANY}
  will be returned.
  
  @param value the string to format
  @return the well formed string