Example usage for com.amazonaws.services.simpledb.util SimpleDBUtils quoteValue

List of usage examples for com.amazonaws.services.simpledb.util SimpleDBUtils quoteValue

Introduction

In this page you can find the example usage for com.amazonaws.services.simpledb.util SimpleDBUtils quoteValue.

Prototype

public static String quoteValue(String value) 

Source Link

Document

Quotes and escapes an attribute value by wrapping it with single quotes and escaping any single quotes inside the value.

Usage

From source file:com.shelfmap.simplequery.expression.matcher.BaseMatcher.java

License:Apache License

@Override
public String describe() {
    StringBuilder sb = new StringBuilder();
    sb.append(expression()).append(" ");
    sb.append(SimpleDBUtils.quoteValue(attributeConverter.convertValue(values[0])));
    return sb.toString();
}

From source file:com.shelfmap.simplequery.expression.matcher.InMatcher.java

License:Apache License

@Override
public String describe() {
    StringBuilder sb = new StringBuilder();
    sb.append(expression()).append(" (");

    StringBuilder parameters = new StringBuilder();
    for (T value : getValues()) {
        if (parameters.length() > 0)
            parameters.append(", ");
        parameters.append(SimpleDBUtils.quoteValue(getAttributeConverter().convertValue(value)));
    }//  w  w w. ja  v a2s  .  c om
    sb.append(parameters.toString());
    sb.append(")");
    return sb.toString();
}

From source file:com.shelfmap.simplequery.expression.matcher.ReferToMatcher.java

License:Apache License

@Override
public String describe() {
    StringBuilder sb = new StringBuilder();
    sb.append(expression());/*  w  w w .jav a2  s  .co  m*/
    if (getValues().size() > 1) {
        sb.append(" (");
        sb.append(SimpleDBUtils.quoteValues(getValues()));
        sb.append(")");
    } else {
        sb.append(" ");
        sb.append(SimpleDBUtils.quoteValue(values()[0]));
    }
    return sb.toString();
}

From source file:org.grails.datastore.mapping.simpledb.util.SimpleDBUtil.java

License:Apache License

/**
 * Quotes and escapes an attribute value by wrapping it with single quotes and escaping any single quotes inside the value.
 * @param value/*from ww  w  . java2  s  .  c  o m*/
 * @return
 */
public static String quoteValue(String value) {
    return SimpleDBUtils.quoteValue(value);
}

From source file:wwutil.jsoda.Filter.java

License:Mozilla Public License

void toSimpleDBConditionStr(StringBuilder sb) {

    if (BINARY_OPERATORS.contains(operator)) {
        if (operand == null)
            throw new IllegalArgumentException("Operand of a condition cannot be null.");
        if (!DataUtil.canBeEncoded(operand, field.getType()))
            throw new IllegalArgumentException("The value of field " + field.getName() + " has type "
                    + field.getType() + " which cannot be used in a query condition.");
        sb.append(attr);/*from  w w w. j  a  v  a 2s  .  c  om*/
        sb.append(" ").append(operator).append(" ");
        sb.append(SimpleDBUtils.quoteValue(DataUtil.encodeValueToAttrStr(operand, field.getType())));
        return;
    }

    if (UNARY_OPERATORS.contains(operator)) {
        sb.append(attr);
        sb.append(" ").append(operator).append(" ");
        return;
    }

    if (TRINARY_OPERATORS.contains(operator)) {
        if (operand == null || operand2 == null)
            throw new IllegalArgumentException("Operand of a condition cannot be null.");
        if (!DataUtil.canBeEncoded(operand, field.getType())
                || !DataUtil.canBeEncoded(operand2, field.getType()))
            throw new IllegalArgumentException("The value of field " + field.getName() + " has type "
                    + field.getType() + " which cannot be used in a query condition.");
        sb.append(attr);
        sb.append(" between ");
        sb.append(SimpleDBUtils.quoteValue(DataUtil.encodeValueToAttrStr(operand, field.getType())));
        sb.append(" and ");
        sb.append(SimpleDBUtils.quoteValue(DataUtil.encodeValueToAttrStr(operand2, field.getType())));
        return;
    }

    if (LIST_OPERATORS.contains(operator)) {
        sb.append(attr);
        sb.append(" ").append(operator).append(" ");
        sb.append("(");
        int index = 0;
        for (Object valueObj : operands) {
            if (!DataUtil.canBeEncoded(valueObj, field.getType()))
                throw new IllegalArgumentException("The value of field " + field.getName() + " has type "
                        + field.getType() + " which cannot be used in a query condition.");
            sb.append(index++ == 0 ? "" : ", ");
            sb.append(SimpleDBUtils.quoteValue(DataUtil.encodeValueToAttrStr(valueObj, field.getType())));
        }
        sb.append(")");
        return;
    }

    throw new UnsupportedOperationException(operator);
}