Back to project page jepldroid.
The source code is released under:
Apache License
If you think the Android project jepldroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
/* Copyright 2011 Jose Maria Arranz Santamaria // w w w. j a v a 2 s. co m Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ package jepl.impl.lex; /** * * @author jmarranz */ public class JDBCParamWithNumberToken extends JDBCParamToken { protected String value = ""; protected int number; /** * Creates a new instance of FloatNumber */ public JDBCParamWithNumberToken(Cursor cursor) { super(cursor.getCurrentPos()); parse(cursor); } public static boolean isJDBCParamWithNumberToken(char c,Cursor cursor) { if (JDBCParamStandardToken.isJDBCParamStandardToken(c, cursor)) return false; if (c != '?') return false; // Vemos si el siguiente caracter es el comienzo de un nmero if (cursor.isLastPos()) return false; // No sigue un nmero char c2 = cursor.getNextChar(); if (!Character.isDigit(c2)) return false; return true; } @Override public String toString() { return value; } public int getNumber() { return number; } public void parse(Cursor cursor) { StringBuilder valueTmp = new StringBuilder(); valueTmp.append( cursor.getCurrentChar() ); // El ? cursor.inc(); // Comienzo del nmero while(cursor.isValidPosition() && Character.isDigit(cursor.getCurrentChar())) { valueTmp.append( cursor.getCurrentChar() ); cursor.inc(); } this.value = valueTmp.toString(); this.number = Integer.parseInt(valueTmp.substring(1)); cursor.dec(); this.end = cursor.getCurrentPos(); // apunta al ltimo caracter del nmero } }