Example usage for java.lang StringBuffer setCharAt

List of usage examples for java.lang StringBuffer setCharAt

Introduction

In this page you can find the example usage for java.lang StringBuffer setCharAt.

Prototype

@Override
public synchronized void setCharAt(int index, char ch) 

Source Link

Usage

From source file:org.josso.selfservices.password.generator.PasswordGeneratorImpl.java

/**
 * The real password generation is performed in this method
 *
 * @param size     the length of the password
 * @param pw_flags the settings for the password
 * @return the newly created password/*from  w  ww .  j  a va2s  .c o  m*/
 */
private String phonemes(int size, int pw_flags) {
    int c, i, len, flags, feature_flags;
    int prev, should_be;
    boolean first;
    String str;
    char ch;
    StringBuffer buf = new StringBuffer();

    do {
        buf.delete(0, buf.length());
        feature_flags = pw_flags;
        c = 0;
        prev = 0;
        should_be = 0;
        first = true;
        should_be = random.nextBoolean() ? VOWEL : CONSONANT;

        while (c < size) {

            i = random.nextInt(PW_ELEMENTS.length);
            str = PW_ELEMENTS[i].getValue();
            len = str.length();
            flags = PW_ELEMENTS[i].getType();
            /* Filter on the basic type of the next element */
            if ((flags & should_be) == 0) {
                continue;
            }
            /* Handle the NOT_FIRST flag */
            if (first && ((flags & NOT_FIRST) != 0))
                continue;
            /* Don't allow VOWEL followed a Vowel/Dipthong pair */
            if (((prev & VOWEL) != 0) && ((flags & VOWEL) != 0) && ((flags & DIPTHONG) != 0))
                continue;
            /* Don't allow us to overflow the buffer */
            if (len > size - c)
                continue;
            /*
             * OK, we found an element which matches our criteria, let's do
             * it!
             */
            buf.append(str);

            /* Handle PW_UPPERS */
            if ((pw_flags & PW_UPPERS) != 0) {
                if ((first || ((flags & CONSONANT) != 0)) && (random.nextInt(10) < 2)) {
                    int lastChar = buf.length() - 1;
                    buf.setCharAt(lastChar, Character.toUpperCase(buf.charAt(lastChar)));
                    feature_flags &= ~PW_UPPERS;
                }
            }

            c += len;
            /* Handle the AMBIGUOUS flag */
            if ((pw_flags & PW_AMBIGUOUS) != 0) {
                int k = -1;
                for (int j = 0; j < PW_AMBIGUOUS_SYMBOLS.length(); j++) {
                    k = buf.indexOf(String.valueOf(PW_AMBIGUOUS_SYMBOLS.charAt(j)));
                    if (k != -1)
                        break;
                }
                if (k != -1) {
                    buf.delete(k, buf.length());
                    c = buf.length();
                }
            }

            /* Time to stop? */
            if (c >= size)
                break;

            /*
             * Handle PW_DIGITS
             */
            if ((pw_flags & PW_DIGITS) != 0) {
                if (!first && (random.nextInt(10) < 3)) {
                    do {
                        ch = (new Integer(random.nextInt(10))).toString().charAt(0);
                    } while (((pw_flags & PW_AMBIGUOUS) != 0) && (PW_AMBIGUOUS_SYMBOLS.indexOf(ch) != -1));
                    c++;
                    buf = buf.append(ch);
                    feature_flags &= ~PW_DIGITS;

                    first = true;
                    prev = 0;
                    should_be = random.nextBoolean() ? VOWEL : CONSONANT;
                    continue;
                }
            }

            /*
             * OK, figure out what the next element should be
             */
            if (should_be == CONSONANT) {
                should_be = VOWEL;
            } else { /* should_be == VOWEL */
                if (((prev & VOWEL) != 0) || ((flags & DIPTHONG) != 0) || (random.nextInt(10) > 3))
                    should_be = CONSONANT;
                else
                    should_be = VOWEL;
            }
            prev = flags;
            first = false;

            /* Handle PW_SYMBOLS */
            if ((pw_flags & PW_SYMBOLS) != 0) {
                if (!first && (random.nextInt(10) < 2)) {
                    do {
                        ch = PW_SPECIAL_SYMBOLS.charAt(random.nextInt(PW_SPECIAL_SYMBOLS.length()));
                    } while (((pw_flags & PW_AMBIGUOUS) != 0) && (PW_AMBIGUOUS_SYMBOLS.indexOf(ch) != -1));
                    c++;
                    buf = buf.append(ch);
                    feature_flags &= ~PW_SYMBOLS;
                }
            }

        }
    } while ((feature_flags & (PW_UPPERS | PW_DIGITS | PW_SYMBOLS)) != 0);

    return buf.toString();
}

From source file:org.apache.poi.ss.format.CellNumberFormatter.java

private void writeInteger(StringBuffer result, StringBuffer output, List<Special> numSpecials,
        Set<StringMod> mods, boolean showCommas) {

    int pos = result.indexOf(".") - 1;
    if (pos < 0) {
        if (exponent != null && numSpecials == integerSpecials)
            pos = result.indexOf("E") - 1;
        else//from  w w  w . java  2s . c  om
            pos = result.length() - 1;
    }

    int strip;
    for (strip = 0; strip < pos; strip++) {
        char resultCh = result.charAt(strip);
        if (resultCh != '0' && resultCh != ',')
            break;
    }

    ListIterator<Special> it = numSpecials.listIterator(numSpecials.size());
    boolean followWithComma = false;
    Special lastOutputIntegerDigit = null;
    int digit = 0;
    while (it.hasPrevious()) {
        char resultCh;
        if (pos >= 0)
            resultCh = result.charAt(pos);
        else {
            // If result is shorter than field, pretend there are leading zeros
            resultCh = '0';
        }
        Special s = it.previous();
        followWithComma = showCommas && digit > 0 && digit % 3 == 0;
        boolean zeroStrip = false;
        if (resultCh != '0' || s.ch == '0' || s.ch == '?' || pos >= strip) {
            zeroStrip = s.ch == '?' && pos < strip;
            output.setCharAt(s.pos, (zeroStrip ? ' ' : resultCh));
            lastOutputIntegerDigit = s;
        }
        if (followWithComma) {
            mods.add(insertMod(s, zeroStrip ? " " : ",", StringMod.AFTER));
            followWithComma = false;
        }
        digit++;
        --pos;
    }
    StringBuffer extraLeadingDigits = new StringBuffer();
    if (pos >= 0) {
        // We ran out of places to put digits before we ran out of digits; put this aside so we can add it later
        ++pos; // pos was decremented at the end of the loop above when the iterator was at its end
        extraLeadingDigits = new StringBuffer(result.substring(0, pos));
        if (showCommas) {
            while (pos > 0) {
                if (digit > 0 && digit % 3 == 0)
                    extraLeadingDigits.insert(pos, ',');
                digit++;
                --pos;
            }
        }
        mods.add(insertMod(lastOutputIntegerDigit, extraLeadingDigits, StringMod.BEFORE));
    }
}

From source file:org.i3xx.step.uno.impl.service.builtin.ContextPropertiesService.java

/**
 * Writes the key value map to a JSON String
 * /*ww  w.j  a v  a  2  s .c o  m*/
 * @param names The names of the properties to be put into the JSON
 *       (or null for all properties).
 * @return The JSON
 * @throws Exception
 */
public String toJSON(String[] names) throws Exception {
    Gson gson = new Gson();
    StringBuffer buffer = new StringBuffer();

    Map<String, Object> values = context.getValues();

    if (names == null)
        names = values.keySet().toArray(new String[values.size()]);

    if (logger.isDebugEnabled()) {
        for (String key : names) {
            Object val = values.get(key);
            logger.debug("JSON object key:{}, value:{}, class:{}", key, val,
                    val == null ? "null" : val.getClass());
        }
    }

    Context jscx = Context.getCurrentContext();
    boolean jsf = jscx != null;
    if (!jsf)
        jscx = Context.enter();

    for (String key : names) {

        buffer.append(',');
        buffer.append(gson.toJson(key));
        buffer.append(':');

        Object val = values.get(key);

        if (val == null) {
            buffer.append(gson.toJson(null));
        } else if (val instanceof Number) {
            buffer.append(gson.toJson(val));
        } else if (val instanceof String) {
            buffer.append(gson.toJson(val));
        } else if (val instanceof Scriptable) {
            Scriptable scope = context.getScope();
            Scriptable object = (Scriptable) val;
            String stmt = (String) NativeJSON.stringify(Context.getCurrentContext(), scope, object, null, null);

            buffer.append('{');

            buffer.append(gson.toJson("Scriptable"));
            buffer.append(':');

            buffer.append(gson.toJson(stmt));

            buffer.append('}');
        } else if (val instanceof Serializable) {

            buffer.append('{');

            buffer.append(gson.toJson("Object"));
            buffer.append(':');

            byte[] buf = readValue(val);
            if (buf == null)
                continue;
            String stmt = Base64.encodeBase64URLSafeString(buf);
            buffer.append(gson.toJson(stmt));

            buffer.append('}');
        } else {
            //Not serializable field to skip
        } //fi
    }

    if (buffer.length() > 0) {
        buffer.setCharAt(0, '{');
    } else {
        buffer.append('{');
    }
    buffer.append('}');

    if (!jsf)
        Context.exit();

    return buffer.toString();
}

From source file:org.pentaho.di.core.Const.java

/**
 * Sets the first character of each word in upper-case.
 *
 * @param string//  w ww  .  j  a  v a  2s.c  om
 *          The strings to convert to initcap
 * @return the input string but with the first character of each word converted to upper-case.
 */
public static final String initCap(String string) {
    StringBuffer change = new StringBuffer(string);
    boolean new_word;
    int i;
    char lower, upper, ch;

    new_word = true;
    for (i = 0; i < string.length(); i++) {
        lower = change.substring(i, i + 1).toLowerCase().charAt(0); // Lowercase is default.
        upper = change.substring(i, i + 1).toUpperCase().charAt(0); // Uppercase for new words.
        ch = upper;

        if (new_word) {
            change.setCharAt(i, upper);
        } else {
            change.setCharAt(i, lower);
        }

        new_word = false;

        // Cast to (int) is required for extended characters (SB)
        if (!Character.isLetterOrDigit((int) ch) && ch != '_') {
            new_word = true;
        }
    }

    return change.toString();
}

From source file:com.projity.field.Field.java

private final void setAccessorMethods() {
    if (clazz != null && property != null) {
        StringBuffer javaName = new StringBuffer(property);
        javaName.setCharAt(0, Character.toUpperCase(javaName.charAt(0)));

        // First look for a getter that has a context (indexed or not)
        methodGet = MethodUtils.getAccessibleMethod(clazz, "get" + javaName,
                (isIndexed() ? getterIndexedContextParams : getterContextParams));
        if (methodGet == null) // try is instead of get
            methodGet = MethodUtils.getAccessibleMethod(clazz, "is" + javaName,
                    (isIndexed() ? getterIndexedContextParams : getterContextParams));

        // If not found, then use standard getter (indexed or not)
        if (methodGet == null) {
            getHasNoContext = true;//  w  w w  . java2  s  .c o m
            methodGet = MethodUtils.getAccessibleMethod(clazz, "get" + javaName,
                    (isIndexed() ? getterIndexedParams : getterParams));
            if (methodGet == null) // try is instead of get
                methodGet = MethodUtils.getAccessibleMethod(clazz, "is" + javaName,
                        (isIndexed() ? getterIndexedParams : getterParams));
        }
        if (methodGet != null)
            internalType = methodGet.getReturnType();
        else
            log.error("Not getter found for field " + getId());

        // First look for a setter that has a context (indexed or not)
        methodSet = MethodUtils.getAccessibleMethod(clazz, "set" + javaName,
                (isIndexed() ? new Class[] { int.class, internalType, FieldContext.class }
                        : new Class[] { internalType, FieldContext.class }));

        // If not found, then use standard setter (indexed or not)
        if (methodSet == null) {
            setHasNoContext = true;
            methodSet = MethodUtils.getAccessibleMethod(clazz, "set" + javaName,
                    (isIndexed() ? new Class[] { int.class, internalType } : new Class[] { internalType }));
        }
        if (methodSet == null && !readOnly) {
            log.warn("No setter found for non-read-only field: " + getId());
        }
        methodReset = MethodUtils.getAccessibleMethod(clazz, "fieldReset" + javaName, getterContextParams);

        if (resetHasNoContext = (methodReset == null))
            methodReset = MethodUtils.getAccessibleMethod(clazz, "fieldReset" + javaName, getterParams);

        methodReadOnly = MethodUtils.getAccessibleMethod(clazz, "isReadOnly" + javaName, getterContextParams);
        if (readOnlyHasNoContext = (methodReadOnly == null))
            methodReadOnly = MethodUtils.getAccessibleMethod(clazz, "isReadOnly" + javaName, getterParams);
        //lc
        //         methodObjectReadOnly = MethodUtils.getAccessibleMethod(clazz, "isReadOnly", getterParams);

        methodHide = MethodUtils.getAccessibleMethod(clazz, "fieldHide" + javaName,
                (isIndexed() ? getterIndexedContextParams : getterContextParams));
        if (hideHasNoContext = (methodHide == null))
            methodHide = MethodUtils.getAccessibleMethod(clazz, "fieldHide" + javaName,
                    (isIndexed() ? getterIndexedParams : getterParams));
        methodOptions = MethodUtils.getAccessibleMethod(clazz, "fieldOptions" + javaName, getterContextParams);
        if (optionsHasNoContext = (methodOptions == null))
            methodOptions = MethodUtils.getAccessibleMethod(clazz, "fieldOptions" + javaName, getterParams);
    }
}

From source file:org.zanata.ZanataInit.java

private static void list(Context ctx, String indent, StringBuffer buffer, boolean verbose) {
    ClassLoader loader = Thread.currentThread().getContextClassLoader();
    try {/*from w  ww.j a  v a2  s.  c  o  m*/
        NamingEnumeration<NameClassPair> ne = ctx.list("");
        while (ne.hasMore()) {
            NameClassPair pair = ne.next();
            String name = pair.getName();
            String className = pair.getClassName();
            boolean recursive = false;
            boolean isLinkRef = false;
            boolean isProxy = false;
            Class<?> c = null;
            try {
                c = loader.loadClass(className);
                if (Context.class.isAssignableFrom(c)) {
                    recursive = true;
                }
                if (LinkRef.class.isAssignableFrom(c)) {
                    isLinkRef = true;
                }
                isProxy = Proxy.isProxyClass(c);
            } catch (ClassNotFoundException cnfe) {
                // If this is a $Proxy* class its a proxy
                if (className.startsWith("$Proxy")) {
                    isProxy = true;
                    // We have to get the class from the binding
                    try {
                        Object p = ctx.lookup(name);
                        c = p.getClass();
                    } catch (NamingException e) {
                        Throwable t = e.getRootCause();
                        if (t instanceof ClassNotFoundException) {
                            // Get the class name from the exception msg
                            String msg = t.getMessage();
                            if (msg != null) {
                                // Reset the class name to the CNFE class
                                className = msg;
                            }
                        }
                    }
                }
            }
            buffer.append(indent).append(" +- ").append(name);
            // Display reference targets
            if (isLinkRef) {
                // Get the
                try {
                    Object obj = ctx.lookupLink(name);
                    LinkRef link = (LinkRef) obj;
                    buffer.append("[link -> ");
                    buffer.append(link.getLinkName());
                    buffer.append(']');
                } catch (Throwable t) {
                    buffer.append("invalid]");
                }
            }
            // Display proxy interfaces
            if (isProxy) {
                buffer.append(" (proxy: ").append(pair.getClassName());
                if (c != null) {
                    Class<?>[] ifaces = c.getInterfaces();
                    buffer.append(" implements ");
                    for (Class<?> iface : ifaces) {
                        buffer.append(iface);
                        buffer.append(',');
                    }
                    buffer.setCharAt(buffer.length() - 1, ')');
                } else {
                    buffer.append(" implements ").append(className).append(")");
                }
            } else if (verbose) {
                buffer.append(" (class: ").append(pair.getClassName()).append(")");
            }
            buffer.append('\n');
            if (recursive) {
                try {
                    Object value = ctx.lookup(name);
                    if (value instanceof Context) {
                        Context subctx = (Context) value;
                        list(subctx, indent + " |  ", buffer, verbose);
                    } else {
                        buffer.append(indent).append(" |   NonContext: ").append(value);
                        buffer.append('\n');
                    }
                } catch (Throwable t) {
                    buffer.append("Failed to lookup: ").append(name).append(", errmsg=").append(t.getMessage());
                    buffer.append('\n');
                }
            }
        }
        ne.close();
    } catch (NamingException ne) {
        buffer.append("error while listing context ").append(ctx.toString()).append(": ")
                .append(ne.toString(true));
    }
}

From source file:org.i3xx.step.uno.impl.service.builtin.ContextAdministrationService.java

/**
 * Writes the key value map to a JSON String
 * /*from   ww w . j  a v  a2s  . c  o  m*/
 * @return The JSON String
 * @throws Exception
 */
public String toJSON() throws Exception {
    Gson gson = new Gson();
    StringBuffer buffer = new StringBuffer();

    Map<String, Object> values = context.getValues();

    if (logger.isDebugEnabled()) {
        Iterator<Map.Entry<String, Object>> tempI = context.getValues().entrySet().iterator();
        while (tempI.hasNext()) {
            Map.Entry<String, Object> e = tempI.next();
            logger.debug("JSON object key:{}, value:{}, class:{}", e.getKey(), e.getValue(),
                    e.getValue() == null ? "null" : e.getValue().getClass());
        }
    }

    Context jscx = Context.getCurrentContext();
    boolean jsf = jscx != null;
    if (!jsf)
        jscx = Context.enter();

    Iterator<String> keys = values.keySet().iterator();
    while (keys.hasNext()) {
        String key = keys.next();

        buffer.append(',');
        buffer.append(gson.toJson(key));
        buffer.append(':');

        Object val = values.get(key);

        if (val == null) {
            buffer.append(gson.toJson(null));
        } else if (val instanceof Number) {
            buffer.append(gson.toJson(val));
        } else if (val instanceof String) {
            buffer.append(gson.toJson(val));
        } else if (val instanceof Scriptable) {
            Scriptable scope = context.getScope();
            Scriptable object = (Scriptable) val;
            String stmt = (String) NativeJSON.stringify(Context.getCurrentContext(), scope, object, null, null);

            buffer.append('{');

            buffer.append(gson.toJson("Scriptable"));
            buffer.append(':');

            buffer.append(gson.toJson(stmt));

            buffer.append('}');
        } else if (val instanceof Serializable) {

            buffer.append('{');

            buffer.append(gson.toJson("Object"));
            buffer.append(':');

            byte[] buf = readValue(val);
            if (buf == null)
                continue;
            String stmt = Base64.encodeBase64URLSafeString(buf);
            buffer.append(gson.toJson(stmt));

            buffer.append('}');
        } else {
            //error
        } //fi
    }

    if (buffer.length() > 0) {
        buffer.setCharAt(0, '{');
    } else {
        buffer.append('{');
    }
    buffer.append('}');

    if (!jsf)
        Context.exit();

    return buffer.toString();
}

From source file:org.pentaho.di.core.database.DatabaseMeta.java

public String stripCR(StringBuffer sbsql) {
    // DB2 Can't handle \n in SQL Statements...
    if (!supportsNewLinesInSQL()) {
        // Remove CR's
        for (int i = sbsql.length() - 1; i >= 0; i--) {
            if (sbsql.charAt(i) == '\n' || sbsql.charAt(i) == '\r')
                sbsql.setCharAt(i, ' ');
        }//from   w  w w.j ava 2  s . c o m
    }

    return sbsql.toString();
}

From source file:org.zkoss.poi.ss.format.CellNumberFormatter.java

private void writeInteger(StringBuffer result, StringBuffer output, List<Special> numSpecials,
        Set<StringMod> mods, boolean showCommas, boolean fraction) {//20100924, henrichen@zkoss.org: fraction has special treatment about zero
    //20100914, henrichen@zkoss.org: repect the current locale
    final char comma = Formatters.getGroupingSeparator(locale);
    final String commaStr = "" + comma;
    final String dot = "" + Formatters.getDecimalSeparator(locale);
    int pos = result.indexOf(dot) - 1;
    if (pos < 0) {
        if (exponent != null && numSpecials == integerSpecials)
            pos = result.indexOf("E") - 1;
        else//from w w  w.  jav  a 2s.  c o m
            pos = result.length() - 1;
    }

    int strip;
    for (strip = 0; strip < pos; strip++) {
        char resultCh = result.charAt(strip);
        if (resultCh != '0' && resultCh != comma)
            break;
    }
    //20100924, henrichen@zkoss.org: handle all zero case
    final char posCh = !fraction && strip == pos && pos >= 0 ? result.charAt(pos) : '\000';
    final boolean allZeros = posCh == '0' || posCh == comma;

    ListIterator<Special> it = numSpecials.listIterator(numSpecials.size());
    boolean followWithComma = false;
    Special lastOutputIntegerDigit = null;
    int digit = 0;
    while (it.hasPrevious()) {
        char resultCh;
        if (pos >= 0)
            resultCh = result.charAt(pos);
        else {
            // If result is shorter than field, pretend there are leading zeros
            resultCh = '0';
        }
        Special s = it.previous();
        followWithComma = showCommas && digit > 0 && digit % 3 == 0;
        boolean zeroStrip = false;
        if (resultCh != '0' || s.ch == '0' || s.ch == '?' || pos >= strip) {
            zeroStrip = s.ch == '?' && (pos < strip || allZeros); //20100924, henrichen@zkoss.org: handle all zero case
            output.setCharAt(s.pos, (zeroStrip ? ' ' : resultCh));
            lastOutputIntegerDigit = s;
        }
        if (followWithComma) {
            //20100914, henrichen@zkoss.org: repect the current locale
            //mods.add(insertMod(s, zeroStrip ? " " : ",", StringMod.AFTER));
            mods.add(insertMod(s, zeroStrip ? " " : commaStr, StringMod.AFTER));
            followWithComma = false;
        }
        digit++;
        --pos;
    }
    StringBuffer extraLeadingDigits = new StringBuffer();
    if (pos >= 0) {
        // We ran out of places to put digits before we ran out of digits; put this aside so we can add it later
        ++pos; // pos was decremented at the end of the loop above when the iterator was at its end
        extraLeadingDigits = new StringBuffer(result.substring(0, pos));
        if (showCommas) {
            while (pos > 0) {
                if (digit > 0 && digit % 3 == 0)
                    //20100914, henrichen@zkoss.org: repect the current locale
                    //extraLeadingDigits.insert(pos, ',');
                    extraLeadingDigits.insert(pos, comma);
                digit++;
                --pos;
            }
        }
        mods.add(insertMod(lastOutputIntegerDigit, extraLeadingDigits, StringMod.BEFORE));
    }
}

From source file:org.medici.bia.common.search.AdvancedSearchDocument.java

/**
 * {@inheritDoc}//from w w w.j av  a2 s .  c  o m
 */
@Override
public void initFromAdvancedSearchCommand(AdvancedSearchCommand command) {
    //Words
    if ((command.getWord() != null) && (command.getWord().size() > 0)) {
        wordsTypes = new ArrayList<WordType>(command.getWord().size());
        words = new ArrayList<String>(command.getWord().size());

        for (String singleWord : command.getWord()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleWord = singleWord.replace("+", "%20");
            singleWord = singleWord.replace("\"", "%22");
            singleWord = singleWord.replace("'", "%27");
            //RR: And this is for replacing special characters with unicode values
            singleWord = URLTransformer.decode(singleWord);
            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 2) {
                    wordsTypes.add(WordType.valueOf(stringTokenizer.nextToken()));
                    StringBuffer tempString = new StringBuffer(
                            URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                    if (StringUtils.countMatches(tempString.toString(), "\"") % 2 != 0) {
                        tempString.setCharAt(tempString.lastIndexOf("\""), ' ');
                    }
                    words.add(tempString.toString());

                } else {
                    continue;
                }
            } catch (URIException uriException) {
                logger.debug(uriException);
                wordsTypes.remove(wordsTypes.size() - 1);
            }
        }
    } else {
        wordsTypes = new ArrayList<WordType>(0);
        words = new ArrayList<String>(0);
    }

    // Person
    if ((command.getPerson() != null) && (command.getPerson().size() > 0)) {
        personId = new ArrayList<Integer>(command.getPerson().size());
        person = new ArrayList<String>(command.getPerson().size());

        for (String singleWord : command.getPerson()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleWord = singleWord.replace("+", "%20");
            //RR: And this is for replacing special characters with unicode values
            singleWord = URLTransformer.decode(singleWord);

            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    personId.add(new Integer(0));
                    try {
                        person.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                    } catch (URIException uriException) {
                        logger.debug(uriException);
                    }
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text

                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        personId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty personId is equal to 0
                        personId.add(new Integer(0));
                    }
                    try {
                        person.add(URIUtil.decode(singleText, "UTF-8"));
                    } catch (URIException uriException) {
                        logger.debug(uriException);
                        personId.remove(personId.size() - 1);
                    }
                }
            } catch (NumberFormatException nex) {
                logger.error(nex);
            }
        }
    } else {
        personId = new ArrayList<Integer>(0);
        person = new ArrayList<String>(0);
    }

    // Place
    if ((command.getPlace() != null) && (command.getPlace().size() > 0)) {
        placeId = new ArrayList<Integer>(command.getPlace().size());
        place = new ArrayList<String>(command.getPlace().size());

        for (String singleWord : command.getPlace()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleWord = singleWord.replace("+", "%20");
            //RR: And this is for replacing special characters with unicode values
            singleWord = URLTransformer.decode(singleWord);

            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    placeId.add(new Integer(0));
                    place.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text
                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        placeId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty placeId is equal to 0
                        placeId.add(new Integer(0));
                    }
                    place.add(URIUtil.decode(singleText, "UTF-8"));
                }
            } catch (NumberFormatException nex) {
                logger.debug(nex);
            } catch (URIException uriException) {
                logger.debug(uriException);
                placeId.remove(placeId.size() - 1);
            }
        }
    } else {
        placeId = new ArrayList<Integer>(0);
        place = new ArrayList<String>(0);
    }

    // Sender
    if ((command.getSender() != null) && (command.getSender().size() > 0)) {
        senderId = new ArrayList<Integer>(command.getSender().size());
        sender = new ArrayList<String>(command.getSender().size());

        for (String singleWord : command.getSender()) {
            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    senderId.add(new Integer(0));
                    sender.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text
                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        senderId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty senderId is equal to 0
                        senderId.add(new Integer(0));
                    }
                    sender.add(URIUtil.decode(singleText, "UTF-8"));
                }
            } catch (NumberFormatException nex) {
                logger.debug(nex);
            } catch (URIException uriException) {
                logger.debug(uriException);
                senderId.remove(senderId.size() - 1);
            }
        }
    } else {
        senderId = new ArrayList<Integer>(0);
        sender = new ArrayList<String>(0);
    }

    // From
    if ((command.getFrom() != null) && (command.getFrom().size() > 0)) {
        fromId = new ArrayList<Integer>(command.getFrom().size());
        from = new ArrayList<String>(command.getFrom().size());

        for (String singleWord : command.getFrom()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleWord = singleWord.replace("+", "%20");
            //RR: And this is for replacing special characters with unicode values
            singleWord = URLTransformer.decode(singleWord);

            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    fromId.add(new Integer(0));
                    from.add(stringTokenizer.nextToken());
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text
                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        fromId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty fromId is equal to 0
                        fromId.add(new Integer(0));
                    }
                    from.add(URIUtil.decode(singleText, "UTF-8"));
                }
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
                fromId.remove(fromId.size() - 1);
            }
        }
    } else {
        fromId = new ArrayList<Integer>(0);
        from = new ArrayList<String>(0);
    }

    // Recipient
    if ((command.getRecipient() != null) && (command.getRecipient().size() > 0)) {
        recipientId = new ArrayList<Integer>(command.getRecipient().size());
        recipient = new ArrayList<String>(command.getRecipient().size());

        for (String singleWord : command.getRecipient()) {
            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    recipientId.add(new Integer(0));
                    recipient.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text
                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        recipientId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty recipientId is equal to 0
                        recipientId.add(new Integer(0));
                    }
                    recipient.add(URIUtil.decode(singleText, "UTF-8"));
                }
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
                recipientId.remove(recipientId.size() - 1);
            }
        }
    } else {
        recipientId = new ArrayList<Integer>(0);
        recipient = new ArrayList<String>(0);
    }

    // To
    if ((command.getTo() != null) && (command.getTo().size() > 0)) {
        toId = new ArrayList<Integer>(command.getTo().size());
        to = new ArrayList<String>(command.getTo().size());

        for (String singleWord : command.getTo()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleWord = singleWord.replace("+", "%20");
            //RR: And this is for replacing special characters with unicode values
            singleWord = URLTransformer.decode(singleWord);

            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    toId.add(new Integer(0));
                    to.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text
                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        toId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty toId is equal to 0
                        toId.add(new Integer(0));
                    }
                    to.add(URIUtil.decode(singleText, "UTF-8"));
                }
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
                toId.remove(toId.size() - 1);
            }
        }
    } else {
        toId = new ArrayList<Integer>(0);
        to = new ArrayList<String>(0);
    }

    // ResTo;
    if ((command.getRefersTo() != null) && (command.getRefersTo().size() > 0)) {
        refersToId = new ArrayList<Integer>(command.getRefersTo().size());
        refersTo = new ArrayList<String>(command.getRefersTo().size());

        for (String singleWord : command.getRefersTo()) {
            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            // string format is number|text
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is |text
                    refersToId.add(new Integer(0));
                    refersTo.add(stringTokenizer.nextToken());
                } else if (stringTokenizer.countTokens() == 2) {
                    String singleId = stringTokenizer.nextToken();
                    String singleText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(singleId)) {
                        refersToId.add(NumberUtils.createInteger(singleId));
                    } else {
                        //Empty refersToId is equal to 0
                        refersToId.add(new Integer(0));
                    }
                    refersTo.add(URIUtil.decode(singleText, "UTF-8"));
                }
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
                refersToId.remove(refersToId.size() - 1);
            }
        }
    } else {
        refersToId = new ArrayList<Integer>(0);
        refersTo = new ArrayList<String>(0);
    }

    // Extract
    if ((command.getExtract() != null) && (command.getExtract().size() > 0)) {
        extract = new ArrayList<String>(command.getExtract().size());

        for (String singleWord : command.getExtract()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleWord = singleWord.replace("+", "%20");
            singleWord = singleWord.replace("\"", "%22");
            singleWord = singleWord.replace("'", "%27");
            //RR: And this is for replacing special characters with unicode values
            singleWord = URLTransformer.decode(singleWord);
            try {
                extract.add(URIUtil.decode(singleWord, "UTF-8"));
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
            }
        }
    } else {
        extract = new ArrayList<String>(0);
    }

    // Synopsis
    if ((command.getSynopsis() != null) && (command.getSynopsis().size() > 0)) {
        synopsis = new ArrayList<String>(command.getSynopsis().size());

        for (String singleWord : command.getSynopsis()) {
            singleWord = singleWord.replace("+", "%20");
            singleWord = singleWord.replace("\"", "%22");
            singleWord = singleWord.replace("'", "%27");
            singleWord = URLTransformer.decode(singleWord);
            try {
                synopsis.add(URIUtil.decode(singleWord, "UTF-8"));
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
            }
        }
    } else {
        synopsis = new ArrayList<String>(0);
    }

    // Topics
    if ((command.getTopic() != null) && (command.getTopic().size() > 0)) {
        topicsId = new ArrayList<Integer>(command.getTopic().size());
        topics = new ArrayList<String>(command.getTopic().size());
        topicsPlaceId = new ArrayList<Integer>(command.getTopic().size());
        topicsPlace = new ArrayList<String>(command.getTopic().size());

        for (String singleWord : command.getTopic()) {
            singleWord = singleWord.replace("+", "%20");

            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            try {
                if (stringTokenizer.countTokens() == 0) {
                    continue;
                } else if (stringTokenizer.countTokens() == 1) {
                    // string format is number
                    String topicId = stringTokenizer.nextToken();
                    if (NumberUtils.isNumber(topicId)) {
                        topicsId.add(NumberUtils.createInteger(topicId));
                    } else {
                        //Empty topicsId is equal to 0
                        topicsId.add(new Integer(0));
                    }
                    //                  topics.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                } else if (stringTokenizer.countTokens() == 2) {
                    // string format is number|text
                    String topicId = stringTokenizer.nextToken();
                    String topicText = stringTokenizer.nextToken();
                    // Check if field is correct
                    if (NumberUtils.isNumber(topicId)) {
                        topicsId.add(NumberUtils.createInteger(topicId));
                    } else {
                        //Empty topicsId is equal to 0
                        topicsId.add(new Integer(0));
                    }
                    topics.add(URIUtil.decode(topicText, "UTF-8"));
                } else if (stringTokenizer.countTokens() == 3) {
                    //string format is number|text|number
                    String singleId = stringTokenizer.nextToken();
                    String topicText = stringTokenizer.nextToken();
                    String placeId = stringTokenizer.nextToken();

                    if (NumberUtils.isNumber(singleId)) {
                        topicsId.add(NumberUtils.createInteger(singleId));
                    } else {
                        topicsId.add(new Integer(0));
                    }
                    topics.add(URIUtil.decode(topicText, "UTF-8"));
                    if (NumberUtils.isNumber(placeId)) {
                        topicsPlaceId.add(NumberUtils.createInteger(placeId));
                    } else {
                        topicsPlaceId.add(new Integer(0));
                    }
                } else if (stringTokenizer.countTokens() == 4) {
                    //string format is number|text|number|text
                    String singleId = stringTokenizer.nextToken();
                    String topicText = stringTokenizer.nextToken();
                    String placeId = stringTokenizer.nextToken();
                    String placeText = stringTokenizer.nextToken();

                    if (NumberUtils.isNumber(singleId)) {
                        topicsId.add(NumberUtils.createInteger(singleId));
                    } else {
                        topicsId.add(new Integer(0));
                    }
                    topics.add(URIUtil.decode(topicText, "UTF-8"));
                    if (NumberUtils.isNumber(placeId)) {
                        topicsPlaceId.add(NumberUtils.createInteger(placeId));
                    } else {
                        topicsPlaceId.add(new Integer(0));
                    }
                    topicsPlace.add(URIUtil.decode(placeText, "UTF-8"));
                }
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
                topicsId.remove(topicsId.size() - 1);
                topicsPlaceId.remove(topicsPlaceId.size() - 1);
            }
        }
    } else {
        topicsId = new ArrayList<Integer>(0);
        topics = new ArrayList<String>(0);
    }

    //Topics Place
    // Place
    //      if ((command.getTopicPlace() != null) && (command.getTopicPlace().size() >0)) {
    //         topicsPlaceId = new ArrayList<Integer>(command.getTopicPlace().size());
    //         topicsPlace = new ArrayList<String>(command.getTopicPlace().size());
    //         
    //         for (String singleWord : command.getTopicPlace()) {
    //            //MD: This is for refine search when the URLencoder change the space in "+" and the special character "\u00E7" in "%E7"
    //            singleWord = singleWord.replace("+", "%20");
    //            singleWord = singleWord.replace("%E7", "\u00E7");
    //            
    //            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
    //            try {
    //               if (stringTokenizer.countTokens() == 0) {
    //                  continue;
    //               } else if (stringTokenizer.countTokens() == 1) {
    //                  // string format is |text
    //                  topicsPlaceId.add(new Integer(0));
    //                  topicsPlace.add(URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
    //               } else if (stringTokenizer.countTokens() == 2) {
    //                  // string format is number|text
    //                  String singleId = stringTokenizer.nextToken();
    //                  String singleText = stringTokenizer.nextToken();
    //                  // Check if field is correct
    //                  if (NumberUtils.isNumber(singleId)) { 
    //                     topicsPlaceId.add(NumberUtils.createInteger(singleId));
    //                  } else {
    //                     //Empty placeId is equal to 0
    //                     topicsPlaceId.add(new Integer(0));
    //                  }
    //                  topicsPlace.add(URIUtil.decode(singleText, "UTF-8"));
    //               }
    //            } catch (NumberFormatException numberFormatException) {
    //               logger.debug(numberFormatException);
    //            } catch (URIException uriException) {
    //               logger.debug(uriException);
    //               topicsPlaceId.remove(topicsPlaceId.size()-1);
    //            }
    //         }
    //      } else {
    //         topicsPlaceId = new ArrayList<Integer>(0);
    //         topicsPlace = new ArrayList<String>(0);
    //      }

    //Date
    if ((command.getDate() != null) && (command.getDate().size() > 0)) {
        datesTypes = new ArrayList<DateType>(command.getDate().size());
        datesYear = new ArrayList<Integer>(command.getDate().size());
        datesMonth = new ArrayList<Integer>(command.getDate().size());
        datesDay = new ArrayList<Integer>(command.getDate().size());
        datesYearBetween = new ArrayList<Integer>(command.getDate().size());
        datesMonthBetween = new ArrayList<Integer>(command.getDate().size());
        datesDayBetween = new ArrayList<Integer>(command.getDate().size());

        for (String singleWord : command.getDate()) {
            //e.g. After|1222|01|12|1223|12|12
            String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|");
            datesTypes.add(DateType.valueOf(fields[0]));
            datesYear.add(DateUtils.getDateYearFromString(fields[1]));
            datesMonth.add(DateUtils.getDateMonthFromString(fields[2]));
            datesDay.add(DateUtils.getDateDayFromString(fields[3]));
            datesYearBetween.add(DateUtils.getDateYearFromString(fields[4]));
            datesMonthBetween.add(DateUtils.getDateMonthFromString(fields[5]));
            datesDayBetween.add(DateUtils.getDateDayFromString(fields[6]));
        }
    } else {
        datesTypes = new ArrayList<DateType>(0);
        datesYear = new ArrayList<Integer>(0);
        datesMonth = new ArrayList<Integer>(0);
        datesDay = new ArrayList<Integer>(0);
        datesYearBetween = new ArrayList<Integer>(0);
        datesMonthBetween = new ArrayList<Integer>(0);
        datesDayBetween = new ArrayList<Integer>(0);
    }

    //Date Created
    if ((command.getDateCreated() != null) && (command.getDateCreated().size() > 0)) {
        datesCreatedTypes = new ArrayList<DateType>(command.getDateCreated().size());
        datesCreated = new ArrayList<Date>(command.getDateCreated().size());
        datesCreatedBetween = new ArrayList<Date>(command.getDateCreated().size());

        for (String singleWord : command.getDateCreated()) {
            //e.g. After|20120112|20120112
            String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|");
            datesCreatedTypes.add(DateType.valueOf(fields[0]));
            datesCreated.add(DateUtils.getDateFromString(fields[1]));
            datesCreatedBetween.add(DateUtils.getDateFromString(fields[2]));
        }
    } else {
        datesCreatedTypes = new ArrayList<DateType>(0);
        datesCreated = new ArrayList<Date>(0);
        datesCreatedBetween = new ArrayList<Date>(0);
    }

    //Date lastUpdate
    if ((command.getDateLastUpdate() != null) && (command.getDateLastUpdate().size() > 0)) {
        datesLastUpdateTypes = new ArrayList<DateType>(command.getDateLastUpdate().size());
        datesLastUpdate = new ArrayList<Date>(command.getDateLastUpdate().size());
        datesLastUpdateBetween = new ArrayList<Date>(command.getDateLastUpdate().size());

        for (String singleWord : command.getDateLastUpdate()) {
            //e.g. After|20120112|20120112
            String[] fields = StringUtils.splitPreserveAllTokens(singleWord, "|");
            datesLastUpdateTypes.add(DateType.valueOf(fields[0]));
            datesLastUpdate.add(DateUtils.getDateFromString(fields[1]));
            datesLastUpdateBetween.add(DateUtils.getDateFromString(fields[2]));
        }
    } else {
        datesLastUpdateTypes = new ArrayList<DateType>(0);
        datesLastUpdate = new ArrayList<Date>(0);
        datesLastUpdateBetween = new ArrayList<Date>(0);
    }

    //Volume
    if ((command.getVolume() != null) && (command.getVolume().size() > 0)) {
        volumesTypes = new ArrayList<VolumeType>(command.getVolume().size());
        volumes = new ArrayList<String>(command.getVolume().size());
        volumesBetween = new ArrayList<String>(command.getVolume().size());

        for (String singleWord : command.getVolume()) {
            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            if ((stringTokenizer.countTokens() == 0) || (stringTokenizer.countTokens() == 1)) {
                continue;
            } else if (stringTokenizer.countTokens() == 2) {
                // string format is Exactly|12
                volumesTypes.add(VolumeType.valueOf(stringTokenizer.nextToken()));
                volumes.add(stringTokenizer.nextToken());
                volumesBetween.add("0");
            } else if (stringTokenizer.countTokens() == 3) {
                // string format is Exactly|12|16
                volumesTypes.add(VolumeType.valueOf(stringTokenizer.nextToken()));
                volumes.add(stringTokenizer.nextToken());
                volumesBetween.add(stringTokenizer.nextToken());
            }
        }
    } else {
        volumesTypes = new ArrayList<VolumeType>(0);
        volumes = new ArrayList<String>(0);
        volumesBetween = new ArrayList<String>(0);
    }

    // Insert
    if ((command.getInsert() != null && command.getInsert().size() > 0)) {
        insertNums = new ArrayList<String>(command.getInsert().size());

        for (String insert : command.getInsert()) {
            insertNums.add(insert);
        }
    } else {
        insertNums = new ArrayList<String>(0);
    }

    //Folio
    if ((command.getFolio() != null) && (command.getFolio().size() > 0)) {
        foliosTypes = new ArrayList<AdvancedSearchAbstract.FolioType>(command.getFolio().size());
        folios = new ArrayList<String>(command.getFolio().size());
        foliosBetween = new ArrayList<String>(command.getFolio().size());

        for (String singleWord : command.getFolio()) {
            StringTokenizer stringTokenizer = new StringTokenizer(singleWord, "|");
            if ((stringTokenizer.countTokens() == 0) || (stringTokenizer.countTokens() == 1)) {
                continue;
            } else if (stringTokenizer.countTokens() == 2) {
                foliosTypes.add(FolioType.valueOf(stringTokenizer.nextToken()));
                folios.add(stringTokenizer.nextToken());
                foliosBetween.add("0");
            } else if (stringTokenizer.countTokens() == 3) {
                foliosTypes.add(FolioType.valueOf(stringTokenizer.nextToken()));
                folios.add(stringTokenizer.nextToken());
                foliosBetween.add(stringTokenizer.nextToken());
            }
        }
    } else {
        foliosTypes = new ArrayList<AdvancedSearchAbstract.FolioType>(0);
        folios = new ArrayList<String>(0);
        foliosBetween = new ArrayList<String>(0);
    }

    //FolioMod
    if (command.getFolioMod() != null && command.getFolioMod().size() > 0) {
        folioMods = new ArrayList<String>(command.getFolioMod().size());
        folioMods.addAll(command.getFolioMod());
    } else {
        folioMods = new ArrayList<String>(0);
    }

    //EntryId
    if ((command.getDocId() != null) && (command.getDocId().size() > 0)) {
        docIds = new ArrayList<String>(command.getDocId().size());

        for (String singleWord : command.getDocId()) {
            try {
                docIds.add(URIUtil.decode(singleWord, "UTF-8"));
            } catch (NumberFormatException numberFormatException) {
                logger.debug(numberFormatException);
            } catch (URIException uriException) {
                logger.debug(uriException);
            }
        }
    } else {
        docIds = new ArrayList<String>(0);
    }

    //LogicalDelete
    if (command.getLogicalDelete() != null) {
        if (command.getLogicalDelete().equals("true")) {
            logicalDelete = Boolean.TRUE;
        } else {
            logicalDelete = Boolean.FALSE;
        }
    }

    //Users
    if (command.getUser() != null) {
        userActionTypes = new ArrayList<UserActionType>(command.getUser().size());
        users = new ArrayList<String>(command.getUser().size());

        for (String singleUser : command.getUser()) {
            //MD: This is for refine search when the URLencoder change the space in "+"
            singleUser = singleUser.replace("+", "%20");
            singleUser = singleUser.replace("\"", "%22");
            singleUser = singleUser.replace("'", "%27");
            //RR: And this is for replacing special characters with unicode values
            singleUser = URLTransformer.decode(singleUser);
            StringTokenizer stringTokenizer = new StringTokenizer(singleUser, "|");
            try {
                if (stringTokenizer.countTokens() == 2) {
                    userActionTypes.add(UserActionType.valueOf(stringTokenizer.nextToken()));
                    StringBuffer tempString = new StringBuffer(
                            URIUtil.decode(stringTokenizer.nextToken(), "UTF-8"));
                    if (StringUtils.countMatches(tempString.toString(), "\"") % 2 != 0) {
                        tempString.setCharAt(tempString.lastIndexOf("\""), ' ');
                    }
                    users.add(tempString.toString());

                } else {
                    continue;
                }
            } catch (URIException uriException) {
                logger.debug(uriException);
                wordsTypes.remove(wordsTypes.size() - 1);
            }
        }
    } else {
        userActionTypes = new ArrayList<UserActionType>(0);
        users = new ArrayList<String>(0);
    }

}