/* (non-Javadoc)
@see org.talend.esb.sam.server.persistence.criterias.Criteria#parseValue(java.lang.String)
9977
@Override
    public Criteria[] parseValue(String attribute) {
        long attributeValue = Long.parseLong(attribute);
        if (name.endsWith("_on")) {
            // We have timestamp_on case
            DateCriteria after = new DateCriteria(name + "_after", columnName);
            after.value = new Timestamp(attributeValue - MILLS_IN_DAY/2);
            DateCriteria before = new DateCriteria(name + "_before", columnName);
            before.value = new Timestamp(attributeValue + MILLS_IN_DAY/2);
            return new Criteria[] {after, before};
        } else {
            DateCriteria result = new DateCriteria(name, columnName);
            result.value = new Timestamp(attributeValue);
            return new Criteria[] {result};
        }
    }
1154105
public void parse(final SelectStatement selectStatement) {
        Optional<LimitValue> offset = Optional.absent();
        Optional<LimitValue> rowCount = Optional.absent();
        while (true) {
            if (lexerEngine.skipIfEqual(PostgreSQLKeyword.LIMIT)) {
                rowCount = buildRowCount(selectStatement);
            } else if (lexerEngine.skipIfEqual(PostgreSQLKeyword.OFFSET)) {
                offset = buildOffset(selectStatement);
            } else {
                break;
            }
        }
        if (offset.isPresent() || rowCount.isPresent()) {
            setLimit(offset, rowCount, selectStatement);
        }
    }
784146
private void parseDirectiveWithValue(String directiveName, String directiveValue) {
        Directive directive;
        if (directiveName.equals(Directive.MAX_AGE.getName())) {
            if (directiveValue.startsWith(M_PLUS_STRING)) {
                directiveValue = directiveValue.replace(M_PLUS_STRING, EMPTY_STRING_VALUE);
                directive = Directive.MAX_AGE_MPLUS;
            } else {
                directive = Directive.MAX_AGE;
            }
        } else {
            directive = Directive.get(directiveName);
        }
        long value = Utils.parseTimeInterval(directiveValue, TimeUnit.SECONDS, 0);
        directives.put(directive, Long.toString(value));
    }
190181
private void parseProperties(JsonParser jp, Object[] values) throws IOException, SQLException {
        jp.nextToken();//START_OBJECT {
        while (jp.nextToken() != JsonToken.END_OBJECT) {
            String fieldName = TableLocation.quoteIdentifier(jp.getText().toUpperCase(), isH2); //FIELD_NAME columnName 
            JsonToken value = jp.nextToken();
            if (value == JsonToken.VALUE_STRING) {                
                values[cachedColumnIndex.get(fieldName)] =  jp.getText();
            } else if (value == JsonToken.VALUE_TRUE) {
                values[cachedColumnIndex.get(fieldName)] =  jp.getValueAsBoolean();
            } else if (value == JsonToken.VALUE_FALSE) {
                values[cachedColumnIndex.get(fieldName)] =  jp.getValueAsBoolean();
            } else if (value == JsonToken.VALUE_NUMBER_FLOAT) {
                values[cachedColumnIndex.get(fieldName)] =  jp.getValueAsDouble();
            } else if (value == JsonToken.VALUE_NUMBER_INT) {
                values[cachedColumnIndex.get(fieldName)] =  jp.getBigIntegerValue();
            } else if (value == JsonToken.START_ARRAY) {
                ArrayList<Object> arrayList = parseArray(jp);
                values[cachedColumnIndex.get(fieldName)] = arrayList.toArray();
            } else if (value == JsonToken.START_OBJECT) {
                String str = parseObject(jp);
                values[cachedColumnIndex.get(fieldName)] = str;
            } else if (value == JsonToken.VALUE_NULL) {
                values[cachedColumnIndex.get(fieldName)] = "null";
            }
            else {
                //ignore other value
            }
        }

    }
1301217
private void tryToSetParsedValue(String value) throws Exception {

        JSONObject json = JSONParser.parseStrict(value).isObject();
        JSONValue val = json.get(JsonKey.START);
        setStart(readOptionalDate(val));
        val = json.get(JsonKey.END);
        setEnd(readOptionalDate(val));
        setWholeDay(readOptionalBoolean(json.get(JsonKey.WHOLE_DAY)));
        JSONObject patternJson = json.get(JsonKey.PATTERN).isObject();
        readPattern(patternJson);
        setExceptions(readDates(json.get(JsonKey.EXCEPTIONS)));
        setSeriesEndDate(readOptionalDate(json.get(JsonKey.SERIES_ENDDATE)));
        setOccurrences(readOptionalInt(json.get(JsonKey.SERIES_OCCURRENCES)));
        setDerivedEndType();
        setCurrentTillEnd(readOptionalBoolean(json.get(JsonKey.CURRENT_TILL_END)));
        setParentSeriesId(readOptionalUUID(json.get(JsonKey.PARENT_SERIES)));

    }
530772
private void parseValues(final InsertStatement insertStatement) {
        Optional<InsertValuesToken> insertValuesToken = insertStatement.findSQLToken(InsertValuesToken.class);
        Preconditions.checkState(insertValuesToken.isPresent());
        insertStatement.getSQLTokens().remove(insertValuesToken.get());
        insertStatement.addSQLToken(new InsertValuesToken(insertValuesToken.get().getStartIndex()));
        do {
            lexerEngine.accept(Symbol.LEFT_PAREN);
            List<SQLExpression> sqlExpressions = new LinkedList<>();
            int count = 0;
            do {
                sqlExpressions.add(basicExpressionParser.parse(insertStatement));
                skipsDoubleColon();
                count++;
            } while (lexerEngine.skipIfEqual(Symbol.COMMA));
            Collection<String> columnNames = new ArrayList<>(insertStatement.getColumnNames());
            Optional<String> generateKeyColumnName = shardingRule.findGenerateKeyColumnName(insertStatement.getTables().getSingleTableName());
            if (generateKeyColumnName.isPresent() && count != insertStatement.getColumnNames().size()) {
                columnNames.remove(generateKeyColumnName.get());
            }
            count = 0;
            AndCondition andCondition = new AndCondition();
            String tableName = insertStatement.getTables().getSingleTableName();
            for (String each : columnNames) {
                SQLExpression sqlExpression = sqlExpressions.get(count);
                if (shardingRule.isShardingColumn(each, tableName)) {
                    if (!(sqlExpression instanceof SQLNumberExpression || sqlExpression instanceof SQLTextExpression || sqlExpression instanceof SQLParameterMarkerExpression)) {
                        throw new SQLParsingException("INSERT INTO can not support complex expression value on sharding column '%s'.", each);
                    }
                    andCondition.getConditions().add(new Condition(new Column(each, tableName), sqlExpression));
                }
                count++;
            }
            lexerEngine.accept(Symbol.RIGHT_PAREN);
            InsertValue insertValue = new InsertValue(sqlExpressions);
            insertStatement.getValues().add(insertValue);
            insertStatement.getRouteConditions().getOrCondition().getAndConditions().add(andCondition);
        } while (lexerEngine.skipIfEqual(Symbol.COMMA));
    }
52854
protected String parseStringValue(String strVal, Properties props, Set visitedPlaceholders)
            throws BeanDefinitionStoreException {

        DynamicProperty dynamic = null;

        // replace reloading prefix and suffix by "normal" prefix and suffix.
        // remember all the "dynamic" placeholders encountered.
        StringBuffer buf = new StringBuffer(strVal);
        int startIndex = strVal.indexOf(this.placeholderPrefix);
        while (startIndex != -1) {
            int endIndex = buf.toString().indexOf(this.placeholderSuffix, startIndex + this.placeholderPrefix.length());
            if (endIndex != -1) {
                if (currentBeanName != null && currentPropertyName != null) {
                    String placeholder = buf.substring(startIndex + this.placeholderPrefix.length(), endIndex);
                    placeholder = getPlaceholder(placeholder);
                    if (dynamic == null) {
                        dynamic = getDynamic(currentBeanName, currentPropertyName, strVal);
                    }
                    addDependency(dynamic, placeholder);
                } else {
                    logger.debug("dynamic property outside bean property value - ignored: " + strVal);
                }
                startIndex = endIndex - this.placeholderPrefix.length() + this.placeholderPrefix.length() +
                        this.placeholderSuffix.length();
                startIndex = strVal.indexOf(this.placeholderPrefix, startIndex);
            } else {
                startIndex = -1;
            }
        }
        // then, business as usual. no recursive reloading placeholders please.
        return super.parseStringValue(buf.toString(), props, visitedPlaceholders);
    }
904861
private void parse(String s) {
    if (s != null) {
      for (MatchResult r = transformParseRegex.exec(s); r != null; r = transformParseRegex.exec(s)) {
        setFromString(vendorProperty(r.getGroup(1)), r.getGroup(2));
      }
    }
  }
581505
public static long parseLong(String val, long defValue){
        if(TextUtils.isEmpty(val)) return defValue;
        try{
            return Long.parseLong(val);
        }catch (NumberFormatException e){
            return defValue;
        }
    }
1159141
private int parseInteger(String value, int defaultValue)
	{
		try
		{
			return Integer.parseInt(value);
		}
		catch (NumberFormatException e)
		{
			return defaultValue;
		}
	}
1329583
private static List<Integer> parseArray(String value, ValueParser parser){
		final List<Integer> values = new ArrayList<>();
	
		final List<String> parts = StrUtil.split(value, StrUtil.C_COMMA);
		for (String part : parts) {
			CollectionUtil.addAllIfNotContains(values, parseStep(part, parser));
		}
		return values;
	}
1138968
@Override
    public Object convertValue(final String valueToConvert) {
        return Integer.valueOf(ParserUtils.stripNonLongChars(valueToConvert));
    }
1368298
@SuppressWarnings("unchecked")
    private static Enum parseEnum(final String value) {
        final int idx = value.lastIndexOf('.');
        try {
            final Class type = Class.forName(value.substring(0, idx));
            if (!type.isEnum()) {
                throw new IllegalStateException("Type " + type.getName() + " is not enum");
            }
            return Enum.valueOf(type, value.substring(idx + 1));
        } catch (Exception ex) {
            throw new IllegalStateException("Failed to recognize enum value: " + value, ex);
        }
    }
754880
public void parse(final InsertStatement insertStatement) {
        lexerEngine.unsupportedIfEqual(getUnsupportedKeywordsBeforeInto());
        lexerEngine.skipUntil(DefaultKeyword.INTO);
        lexerEngine.nextToken();
        tableReferencesClauseParser.parse(insertStatement, true);
        skipBetweenTableAndValues(insertStatement);
    }
406982
public static Long parseLong(String s, long defaultValue) {
        try {
            Long value = Long.parseLong(s);
            return value;
        } catch (NumberFormatException e) {
            //do nothing
        }
        return defaultValue;
    }
846384
@Override
	protected R parseValueFromString(String s)
	{
		Class<R> range = this.getRange();
		R value = null;
		try
		{
			if (range.equals(double.class))
			{
				value= (R) Double.valueOf(s);
			}
			else if (range.equals(float.class))
			{
				value=  (R) Float.valueOf(s);
			}
			else if (range.equals(int.class))
			{
				value= (R) Integer.valueOf(s);
			}
			else if (range.equals(Boolean.class))
			{
				value= (R) Boolean.valueOf(s);
			}
		}

		catch (NumberFormatException e)

		{
			throw new IllegalBioPAXArgumentException(
					"Failed to convert literal " + s +
					" to " + range.getSimpleName()
					+ " for " + property, e);
		}
		return value;
	}
685613
private char[] parseEntityValue(String id, Location loc, char quoteChar)
        throws XMLStreamException
    {
        /* 25-Jun-2004, TSa: Let's first mark current input source as the
         *   scope, so we can both make sure it ends in this input
         *   context (file), and that embedded single/double quotes
         *   in potentially expanded entities do not end the value
         *   definition (as per XML 1.0/3, 4.4.5)
         */
        WstxInputSource currScope = mInput;

        /* 18-Jul-2004, TSa: Also, let's see if parameter entities are
         *  allowed; they are only legal outside of main internal subset
         *  (ie. main XML input) file (or to be precise; they are legal
         *  in the int. subset only as complete declarations)
         */
        //boolean allowPEs = mIsExternal || (mInput != mRootInput);

        TextBuffer tb = mValueBuffer;
        if (tb == null) {
            tb = TextBuffer.createTemporaryBuffer();
        }
        tb.resetInitialized();

        char[] outBuf = tb.getCurrentSegment();
        int outPtr = tb.getCurrentSegmentSize();

        while (true) {
            if (mInputPtr >= mInputEnd) {
                loadMoreScoped(currScope, id, loc);
            }
            char c = mInputBuffer[mInputPtr++];

            // Let's get most normal chars 'skipped' first
            if (c >= CHAR_FIRST_PURE_TEXT) {
                ;
            } else if (c == quoteChar) {
                // Only end if we are in correct scope:
                if (mInput == currScope) {
                    break;
                }
            } else if (c == '&') { // char entity that needs to be replaced?
                /* 06-Sep-2004, TSa: We can NOT expand pre-defined entities, as
                 *   XML specs consider them 'real' (non-char) entities.
                 *   And expanding them would cause problems with entities
                 *   that have such entities.
                 */
                int d = resolveCharOnlyEntity(false);
                // Did we get a real char entity?
                if (d != 0) {
                    if (d <= 0xFFFF) {
                        c = (char) d;
                    } else {
                        // Need more room?
                        if (outPtr >= outBuf.length) {
                            outBuf = tb.finishCurrentSegment();
                            outPtr = 0;
                        }
                        d -= 0x10000;
                        outBuf[outPtr++] = (char) ((d >> 10)  + 0xD800);;
                        c = (char) ((d & 0x3FF)  + 0xDC00);
                    }
                } else {
                    /* 11-Feb-2006, TSa: Even so, must verify that the
                     *   entity reference is well-formed.
                     */
                    boolean first = true;
                    while (true) {
                        if (outPtr >= outBuf.length) { // need more room?
                            outBuf = tb.finishCurrentSegment();
                            outPtr = 0;
                        }
                        outBuf[outPtr++] = c; // starting with '&'
                        if (mInputPtr >= mInputEnd) {
                            loadMoreScoped(currScope, id, loc);
                        }
                        c = mInputBuffer[mInputPtr++];
                        if (c == ';') {
                            break;
                        }
                        if (first) {
                            first = false;
                            if (isNameStartChar(c)) {
                                continue;
                            }
                        } else {
                            if (isNameChar(c)) {
                                continue;
                            }
                        }
                        if (c == ':' && !mCfgNsEnabled) {
                            continue; // fine in non-ns mode
                        }
                        if (first) { // missing name
                            throwDTDUnexpectedChar(c, "; expected entity name after '&'");
                        }
                        throwDTDUnexpectedChar(c, "; expected semi-colon after entity name");
                    }
                    // we can just fall through to let semicolon be added
                }
                // Either '&' itself, or expanded char entity
            } else if (c == '%') { // param entity?
                expandPE();
                // Need to loop over, no char available yet
                continue;
            } else if (c < CHAR_SPACE) {
                if (c == '\n') {
                    markLF();
                } else if (c == '\r') {
                    if (skipCRLF(c)) {
                        if (!mNormalizeLFs) {
                            // Special handling, to output 2 chars at a time:
                            if (outPtr >= outBuf.length) { // need more room?
                                outBuf = tb.finishCurrentSegment();
                                outPtr = 0;
                            }
                            outBuf[outPtr++] = c;
                        }
                        c = '\n';
                    } else {
                        if (mNormalizeLFs) { // Mac LF
                            c = '\n';
                        }
                    }
                } else if (c != '\t') {
                    throwInvalidSpace(c);
                }
            }
            
            // Need more room?
            if (outPtr >= outBuf.length) {
                outBuf = tb.finishCurrentSegment();
                outPtr = 0;
            }
            // Ok, let's add char to output:
            outBuf[outPtr++] = c;
        }
        tb.setCurrentLength(outPtr);
        
        // Ok, now need the closing '>':
        char c = skipDtdWs(true);
        if (c != '>') {
            throwDTDUnexpectedChar(c, "; expected closing '>' after ENTITY declaration");
        }
        char[] result = tb.contentsAsArray();
        mValueBuffer = tb; // recycle, if needed later on

        return result;
    }