Example usage for java.lang StringBuffer equals

List of usage examples for java.lang StringBuffer equals

Introduction

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

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:TerminalMonitor.java

static public void main(String args[]) {
    DriverPropertyInfo[] required;
    StringBuffer buffer = new StringBuffer();
    Properties props = new Properties();
    boolean connected = false;
    Driver driver;//from w w w  . j  av  a  2s.c  o m
    String url;
    int line = 1; // Mark current input line

    if (args.length < 1) {
        System.out.println("Syntax: <java -Djdbc.drivers=DRIVER_NAME " + "TerminalMonitor JDBC_URL>");
        return;
    }
    url = args[0];
    // We have to get a reference to the driver so we can
    // find out what values to prompt the user for in order
    // to make a connection.
    try {
        driver = DriverManager.getDriver(url);
    } catch (SQLException e) {
        e.printStackTrace();
        System.err.println("Unable to find a driver for the specified " + "URL.");
        System.err.println("Make sure you passed the jdbc.drivers " + "property on the command line to specify "
                + "the driver to be used.");
        return;
    }
    try {
        required = driver.getPropertyInfo(url, props);
    } catch (SQLException e) {
        e.printStackTrace();
        System.err.println("Unable to get driver property information.");
        return;
    }
    input = new BufferedReader(new InputStreamReader(System.in));
    // some drivers do not implement this properly
    // if that is the case, prompt for user name and password
    try {
        if (required.length < 1) {
            props.put("user", prompt("user: "));
            props.put("password", prompt("password: "));
        } else {
            // for each required attribute in the driver property info
            // prompt the user for the value
            for (int i = 0; i < required.length; i++) {
                if (!required[i].required) {
                    continue;
                }
                props.put(required[i].name, prompt(required[i].name + ": "));
            }
        }
    } catch (IOException e) {
        e.printStackTrace();
        System.err.println("Unable to read property info.");
        return;
    }
    // Make the connection.
    try {
        connection = DriverManager.getConnection(url, props);
    } catch (SQLException e) {
        e.printStackTrace();
        System.err.println("Unable to connect to the database.");
    }
    connected = true;
    System.out.println("Connected to " + url);
    // Enter into a user input loop
    while (connected) {
        String tmp, cmd;

        // Print a prompt
        if (line == 1) {
            System.out.print("TM > ");
        } else {
            System.out.print(line + " -> ");
        }
        System.out.flush();
        // Get the next line of input
        try {
            tmp = input.readLine();
        } catch (java.io.IOException e) {
            e.printStackTrace();
            return;
        }
        // Get rid of extra space in the command
        cmd = tmp.trim();
        // The user wants to commit pending transactions
        if (cmd.equals("commit")) {
            try {
                connection.commit();
                System.out.println("Commit successful.");
            } catch (SQLException e) {
                System.out.println("Error in commit: " + e.getMessage());
            }
            buffer = new StringBuffer();
            line = 1;
        }
        // The user wants to execute the current buffer
        else if (cmd.equals("go")) {
            if (!buffer.equals("")) {
                try {
                    executeStatement(buffer);
                } catch (SQLException e) {
                    System.out.println(e.getMessage());
                }
            }
            buffer = new StringBuffer();
            line = 1;
            continue;
        }
        // The user wants to quit
        else if (cmd.equals("quit")) {
            connected = false;
            continue;
        }
        // The user wants to clear the current buffer
        else if (cmd.equals("reset")) {
            buffer = new StringBuffer();
            line = 1;
            continue;
        }
        // The user wants to abort a pending transaction
        else if (cmd.equals("rollback")) {
            try {
                connection.rollback();
                System.out.println("Rollback successful.");
            } catch (SQLException e) {
                System.out.println("An error occurred during rollback: " + e.getMessage());
            }
            buffer = new StringBuffer();
            line = 1;
        }
        // The user wants version info
        else if (cmd.startsWith("show")) {
            DatabaseMetaData meta;

            try {
                meta = connection.getMetaData();
                cmd = cmd.substring(5, cmd.length()).trim();
                if (cmd.equals("version")) {
                    showVersion(meta);
                } else {
                    System.out.println("show version"); // Bad arg
                }
            } catch (SQLException e) {
                System.out.println("Failed to load meta data: " + e.getMessage());
            }
            buffer = new StringBuffer();
            line = 1;
        }
        // The input that is not a keyword should appended be to the buffer
        else {
            buffer.append(" " + tmp);
            line++;
            continue;
        }
    }
    try {
        connection.close();
    } catch (SQLException e) {
        System.out.println("Error closing connection: " + e.getMessage());
    }
    System.out.println("Connection closed.");
}

From source file:Main.java

public static boolean isEmpty(StringBuffer s) {
    return null == s || s.equals("");
}

From source file:br.gov.frameworkdemoiselle.behave.integration.alm.objects.util.GenerateXMLString.java

public static Testcase getTestcaseObject(HttpResponse response) throws IOException, JAXBException {

    Testcase testcase = null;/*from  w  ww  .ja  v a  2 s .  co m*/
    StringBuffer xmlString = new StringBuffer();
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        InputStream instream = entity.getContent();
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
            String line = "";
            while ((line = reader.readLine()) != null) {
                xmlString.append(line);
            }
        } finally {
            instream.close();
        }
    }

    if (!xmlString.equals("")) {
        JAXBContext jaxbContext = JAXBContext.newInstance(Testcase.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        StringReader reader = new StringReader(xmlString.toString());
        testcase = (Testcase) unmarshaller.unmarshal(reader);
    }

    return testcase;

}

From source file:br.gov.frameworkdemoiselle.behave.integration.alm.objects.util.GenerateXMLString.java

public static Testplan getTestPlanObject(HttpResponse response) throws IOException, JAXBException {

    Testplan plan = null;//from  ww w.j a v  a  2 s  .  c  o m
    StringBuffer xmlString = new StringBuffer();
    HttpEntity entity = response.getEntity();
    if (entity != null) {
        InputStream instream = entity.getContent();
        try {
            BufferedReader reader = new BufferedReader(new InputStreamReader(instream));
            String line = "";
            while ((line = reader.readLine()) != null) {
                xmlString.append(line);
            }
        } finally {
            instream.close();
        }
    }

    if (!xmlString.equals("")) {
        JAXBContext jaxbContext = JAXBContext.newInstance(Testplan.class);
        Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        StringReader reader = new StringReader(xmlString.toString());
        plan = (Testplan) unmarshaller.unmarshal(reader);
    }

    return plan;

}

From source file:com.sap.research.connectivity.gw.parsers.JavaSourceFileEditor.java

public void addMethod(JavaSourceMethod method, boolean overwrite) {
    JavaSourceMethod currentMethod = null;
    StringBuffer fileContent;
    if ((currentMethod = getMethod(method)) != null) {
        if (!overwrite)
            return;
        else {/* ww  w  .jav a2  s .c  o m*/
            fileContent = new StringBuffer(getFileContent());
            if (fileContent.equals(""))
                return;

            replaceMethod(currentMethod, method, fileContent);
        }
    } else {
        fileContent = new StringBuffer(getFileContent());
        if (fileContent.equals(""))
            return;

        insertMethod(method, fileContent);
    }
}

From source file:es.pode.empaquetador.presentacion.archivos.modificar.ModificarArchivoControllerImpl.java

/**
 * @see es.pode.empaquetador.presentacion.archivos.modificar.ModificarArchivoController#modificar(org.apache.struts.action.ActionMapping, es.pode.empaquetador.presentacion.archivos.modificar.ModificarForm, javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
 *//*from w  w w.j  a  v  a2 s .com*/
public final void modificar(ActionMapping mapping,
        es.pode.empaquetador.presentacion.archivos.modificar.ModificarForm form, HttpServletRequest request,
        HttpServletResponse response) throws Exception {
    EmpaquetadorSession sesEmpaq = this.getEmpaquetadorSession(request);
    GestorArchivosSession sesArch = this.getGestorArchivosSession(request);

    java.util.Locale locale = (Locale) request.getSession().getAttribute(ConstantesAgrega.DEFAULT_LOCALE);
    ResourceBundle i18n = ResourceBundle.getBundle("application-resources", locale);

    String opcion = form.getAction();

    if (opcion.equals(i18n.getString("portal_empaquetado.modificarNombre"))) {

        //nuevoNombre debe ser la concatenacin de la extensin y el nuevo nombre
        String extension = form.getExtension();
        String nuevoNombre;
        if (extension.equals("")) {
            nuevoNombre = form.getNuevoNombre();
        } else {
            StringBuffer nombre = new StringBuffer(form.getNuevoNombre());
            nombre.append(".").append(extension);
            nuevoNombre = nombre.toString();
        }
        GestorSesion gs = new GestorSesion();
        gs.validarNombreFichero(nuevoNombre);

        ArchivoVO archivo = (ArchivoVO) request.getSession().getAttribute("archivoVO");
        String nombre = archivo.getNombre();

        if (!extension.equals("")) {
            nombre = nombre + "." + extension;
        }

        if (!nombre.equals(nuevoNombre)) {

            // obtengo el identificador del ODEVO
            String identificador = sesEmpaq.getIdLocalizador();

            List path = sesArch.getPath();
            ArchivoVO ultimoPath = (ArchivoVO) path.get(path.size() - 1);
            // obtengo la carpetaDestino
            String carpetaPadre = null;
            if (path.size() > 1 && ultimoPath.getCarpetaPadre() == null) {
                carpetaPadre = ultimoPath.getNombre();
            } else if (path.size() > 1 && ultimoPath.getCarpetaPadre() != null) {
                carpetaPadre = ultimoPath.getCarpetaPadre().concat("/").concat(ultimoPath.getNombre());
            }

            try {
                this.getSrvEmpaquetadorBasicoService().renombrar(identificador, carpetaPadre, nombre,
                        nuevoNombre);
            } catch (Exception e) {
                throw new ValidatorException("{portalempaquetado.archivos.error.renombrar}");
            }
        }
    }
}

From source file:com.pari.nm.utils.db.ReportDBHelper.java

public static int getTempTableRecordCountByCol(String reportId, String sessionId, TableDefinition tableDef,
        Map<String, String> mapOfConditions, List<ColumnLevelFilter> columnLevelFilters, String uniqueColumn)
        throws Exception {
    // using report and session id get temp table name
    String tempTableName = getTempPaginationTblName(reportId, sessionId);
    if (null == tempTableName) {
        String error = "Failed to get Temp Table name for ReportId[" + reportId + "] SessionId[" + sessionId
                + "]";
        logger.error(error);/*from   ww w. j  ava 2s. c  o m*/
        throw new Exception(error);
    }

    // check whether temp table exist or not.
    boolean isTempTableExists = checkTempTableExists(reportId, sessionId);
    if (false == isTempTableExists) {
        String error = "Table does not exist for Report Id[" + reportId + "] SessionId[" + sessionId + "]";
        logger.error(error);
        throw new Exception(error);
    }

    int totalRecordCount = 0;
    Connection connection = null;
    Statement statement = null;
    ResultSet resultset = null;

    try {
        connection = DBHelper.getConnection();
        if (connection == null) {
            logger.info("Unable to get Connection.");
            throw new Exception("Unable to get connection");
        }

        StringBuffer buffer = new StringBuffer();
        if (null != mapOfConditions) {
            if (reportId.equalsIgnoreCase("device_details")
                    || reportId.equalsIgnoreCase("device_with_additional_details")) {
                buffer = getSpecificQueryCondition(mapOfConditions, reportId, tableDef);
                if (!buffer.equals("")) {
                    buffer = new StringBuffer().append(" Q1 ").append(buffer);
                }
            } else {
                int condition = mapOfConditions.size();
                buffer.append((0 == mapOfConditions.size() ? "" : " WHERE "));
                for (Map.Entry<String, String> map : mapOfConditions.entrySet()) {
                    String columnName = map.getKey();
                    if (null != tableDef) {
                        // Add the condition for refering the device table only if the report contains a column
                        // for deviceID field else by pass. If there exist any other report then new mechanism
                        // should
                        // be introduced .
                        if (isDeviceINQueryRequired(tableDef, reportId, columnName)) {
                            if (true == "hostname".equals(columnName.toLowerCase())) {
                                if (isPostgres()) {
                                    buffer.append("DEVICE IN (SELECT CAST (ID AS TEXT) FROM IOS_VERSION WHERE "
                                            + map.getValue() + ")");
                                } else {
                                    buffer.append("DEVICE IN (SELECT ID FROM IOS_VERSION WHERE "
                                            + map.getValue() + ")");
                                }
                            } else if (true == "ipaddress".equals(columnName.toLowerCase())) {
                                if (isPostgres()) {
                                    buffer.append("DEVICE IN (SELECT CAST (ID AS TEXT) FROM NODES WHERE "
                                            + map.getValue() + ")");
                                } else {
                                    buffer.append(
                                            "DEVICE IN (SELECT ID FROM NODES WHERE " + map.getValue() + ")");
                                }
                            } else {
                                buffer.append(map.getValue());
                            }
                        } else if (isCustomerIdINQueryRequired(tableDef, reportId)) {

                            if (true == "customerid".equals(columnName.toLowerCase())) {
                                String value = map.getValue();
                                value = value.replace(columnName, "customer_name");
                                buffer.append("CUSTOMERID IN (SELECT customer_id FROM customers WHERE " + value
                                        + ")");
                            } else {
                                buffer.append(map.getValue());
                            }

                        } else {
                            buffer.append(map.getValue());
                        }
                    } else

                    {
                        buffer.append(map.getValue());
                    }
                    condition -= 1; // decrease
                    buffer.append((0 == condition) ? " " : " OR ");
                }
            }
        }
        String columnLevelWhere = null;
        if (isPostgres()) {
            columnLevelWhere = PostgresReportDBHelper.getColumnLevelFilterQuery(columnLevelFilters, tableDef,
                    reportId);
        } else {
            columnLevelWhere = getColumnLevelFilterQuery(columnLevelFilters, tableDef, reportId);
        }
        String additionalQuery = "";

        if (uniqueColumn != null && "hostname".equals(uniqueColumn.toLowerCase())
                && isDeviceINQueryRequired(tableDef, reportId, uniqueColumn.toLowerCase())) {
            if (isPostgres()) {
                additionalQuery = " temp LEFT JOIN IOS_VERSION ON temp.DEVICE=CAST(IOS_VERSION.ID AS TEXT)";
            } else {
                additionalQuery = " temp LEFT JOIN IOS_VERSION ON temp.DEVICE=TO_CHAR(IOS_VERSION.ID)";
            }
        } else if (uniqueColumn != null && true == "ipaddress".equals(uniqueColumn.toLowerCase())
                && isDeviceINQueryRequired(tableDef, reportId, uniqueColumn.toLowerCase())) {
            additionalQuery = " temp LEFT JOIN NODES ON temp.DEVICE=TO_CHAR(NODES.ID) ";
            if (isPostgres()) {
                additionalQuery = " temp LEFT JOIN NODES ON temp.DEVICE=CAST(NODES.ID AS TEXT) ";
            }
        } else if (uniqueColumn != null && true == "customername".equalsIgnoreCase(uniqueColumn)) {
            additionalQuery = " temp LEFT JOIN CUSTOMERS ON temp.CUSTOMERID=CUSTOMERS.CUSTOMER_ID";
        }

        String query = null;
        if (uniqueColumn == null) {
            query = "SELECT COUNT(*) AS ROWCOUNT FROM (SELECT * FROM " + tempTableName + String.valueOf(buffer)
                    + " ) X " + columnLevelWhere;
        } else if (uniqueColumn.equalsIgnoreCase("CustomerName")) {
            query = "SELECT COUNT(*) AS ROWCOUNT FROM (SELECT DISTINCT customer_name as CustomerName FROM (SELECT * FROM "
                    + tempTableName + additionalQuery + String.valueOf(buffer) + " ) X " + columnLevelWhere
                    + " ) Y";
        } else {
            query = "SELECT COUNT(*) AS ROWCOUNT FROM (SELECT DISTINCT "
                    + ColumnLevelFilter.getColumnName(uniqueColumn) + " FROM (SELECT * FROM " + tempTableName
                    + additionalQuery + String.valueOf(buffer) + " ) X " + columnLevelWhere + " ) Y";
        }

        // if (colName != null)
        // {
        // query = "SELECT COUNT(DISTINCT " + colName + ") AS ROWCOUNT FROM " + tempTableName
        // + String.valueOf(buffer);
        // }

        statement = connection.createStatement();
        resultset = statement.executeQuery(query);
        while ((resultset != null) && resultset.next()) {
            totalRecordCount = resultset.getInt("ROWCOUNT");
            break;
        }
        return totalRecordCount;
    } catch (Exception ex) {
        logger.error("Error while getting row count from temp table.", ex);
        throw ex;
    } finally {
        try {
            if (null != resultset) {
                resultset.close();
            }
        } catch (Exception ee) {
        }
        if (statement != null) {
            try {
                statement.close();
            } catch (SQLException e) {
                logger.error("Exception while closing Statement:", e);
            }
        }
        DBHelper.releaseConnection(connection);
    }
}

From source file:it.prato.comune.sit.LayerTerritorio.java

/**
 * Compone una query SQL sulla base dei parametri passati come argomento.
 * /*  w  w w  .  j av a 2  s  .c  o m*/
 * @param connection
 * @param sqlPreWhere
 * @param sqlWhere
 * @param sqlPostWhere
 * @param usaFiltro
 * @return String
 * @throws IOException
 * @throws SITException
 * @throws SQLException
 */
public PreparedStatement queryDirettaSql(Connection connection, String sqlPreWhere, String sqlWhere,
        String sqlPostWhere, boolean usaFiltro) throws IOException, SITException, SQLException {

    StringBuffer sqlFiltro = new StringBuffer("");

    JDBCDataStore store = (JDBCDataStore) getDataStore();
    PreparedStatementSQLDialect dialect = (PreparedStatementSQLDialect) store.getSQLDialect();
    PreparedFilterToSQL encoder = null;

    if (usaFiltro) {
        if (filtroTotale != null) {

            encoder = dialect.createPreparedFilterToSQL();

            try {
                String filter = encoder.encodeToString(filtroTotale.getFiltro());
                sqlFiltro.append(filter);
            } catch (FilterToSQLException e) {
                String errMsg = "Errore durante creazione filtro per query diretta";
                logger.error(errMsg, e);
                throw new SITSQLEncoderException(errMsg, e);
            }
        }
    }

    StringBuffer sqlWhereTot = new StringBuffer("");

    if (!sqlFiltro.equals("")) {
        sqlWhereTot.append(" ");
        sqlWhereTot.append(sqlFiltro.toString());
        sqlWhereTot.append(" ");
    }

    if (!sqlWhere.equals("")) {
        if (!sqlWhereTot.equals("")) {
            sqlWhereTot.append(" AND ");
        }
        sqlWhereTot.append(sqlWhere);
    }

    if (sqlFiltro.equals("")) {
        sqlWhereTot.append(" WHERE ");
        sqlWhereTot.append(sqlWhereTot);
    }

    PreparedStatement statement = null;

    try {
        String sql = sqlPreWhere + sqlWhereTot.toString() + sqlPostWhere;

        logger.info("Query: " + sql);

        if (encoder != null) {
            List<Object> preparedObjects = encoder.getLiteralValues();

            int listSize = preparedObjects.size();
            if (listSize > 0) {
                statement = connection.prepareStatement(sql);

                for (int i = 0; i < preparedObjects.size(); i++) {
                    Object obj = preparedObjects.get(i);
                    Class binding = encoder.getLiteralTypes().get(i);

                    if (obj instanceof Geometry) {
                        Geometry geometry = (Geometry) preparedObjects.get(i);

                        CoordinateReferenceSystem crs = getFeatureType().getCoordinateReferenceSystem();
                        // Inserito controllo perch almeno su Oracle se il layer non ha SRID impostato ma la geometria si vsi verifica errore
                        if (crs != null) {
                            dialect.setGeometryValue(geometry, geometry.getDimension(), geometry.getSRID(),
                                    binding, statement, i + 1);
                        } else {
                            dialect.setGeometryValue(geometry, geometry.getDimension(), 0, binding, statement,
                                    i + 1);
                        }
                    } else {
                        dialect.setValue(obj, binding, statement, i + 1, connection);
                    }
                }
            } else {
                statement = connection.prepareStatement(sql);
            }
        } else {
            statement = connection.prepareStatement(sql);
        }

    } catch (SQLException e) {
        logger.error("Errore durante preparing sql query diretta", e);
        throw e;
    }

    return statement;
}

From source file:org.kuali.ole.select.document.OleLineItemReceivingDocument.java

public boolean checkForEnumeration(StringBuffer enumeration) {
    if (null != enumeration && !(enumeration.equals("")) && !(enumeration.toString().equals("null"))) {
        return true;
    } else {//from ww w.ja  v a  2  s  .  c om
        return false;
    }
}

From source file:usbong.android.utils.UsbongUtils.java

public static ArrayList<String> tokenizeJapaneseString(String s) {
    ArrayList<String> output = new ArrayList<String>();
    StringBuffer kanjiCommonPhrase = new StringBuffer();
    StringBuffer kanjiRarePhrase = new StringBuffer();
    StringBuffer hiraganaPhrase = new StringBuffer();
    StringBuffer katakanaPhrase = new StringBuffer();
    StringBuffer japanesePunctuationPhrase = new StringBuffer();
    StringBuffer fullWidthRomanCharAndHalfWidthKatakanaPhrase = new StringBuffer();
    StringBuffer othersPhrase = new StringBuffer();

    Log.d(">>>>inside: tokenizeJapaneseString", "" + s);

    int value;/*from  w ww. j  ava 2s .c  o m*/
    //go through character by character
    for (int i = 0; i < s.length();) {
        value = (int) s.charAt(i);
        Log.d(">>>>", "" + s.charAt(i));

        //Reference: http://www.rikai.com/library/kanjitables/kanji_codes.unicode.shtml;
        //last accessed: 4 Oct. 2014
        //Reference: http://stackoverflow.com/questions/3826918/how-to-classify-japanese-characters-as-either-kanji-or-kana;
        //last accessed: 4 Oct. 2014;
        //answer by Jack, Sept. 30, 2010
        //KANJI (COMMON)
        if (value >= 0x4e00 && value <= 0x9faf) {
            for (; i < s.length() && value >= 0x4e00 && value <= 0x9faf;) { //while Kanji Char
                kanjiCommonPhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }
            //            Log.d(">>>","kanjiPhrase: "+kanjiPhrase);
            if (!kanjiCommonPhrase.toString().equals("")) {
                output.add(kanjiCommonPhrase.toString());
                kanjiCommonPhrase.replace(0, kanjiCommonPhrase.length(), "");
                //                Log.d(">>>","here");
                continue;
            }
        }
        //KANJI (RARE)
        if (value >= 0x3400 && value <= 0x4dbf) {
            for (; i < s.length() && value >= 0x3400 && value <= 0x4dbf;) {
                kanjiRarePhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }
            //            Log.d(">>>","kanjiPhrase: "+kanjiPhrase);
            if (!kanjiRarePhrase.toString().equals("")) {
                output.add(kanjiRarePhrase.toString());
                kanjiRarePhrase.replace(0, kanjiRarePhrase.length(), "");
                //                Log.d(">>>","here");
                continue;
            }
        } else if (value >= 0x3040 && value <= 0x309f) {
            //HIRAGANA
            for (; i < s.length() && value >= 0x3040 && value <= 0x309f;) {
                hiraganaPhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }

            if (!hiraganaPhrase.toString().equals("")) {
                output.add(hiraganaPhrase.toString());
                hiraganaPhrase.replace(0, hiraganaPhrase.length(), "");
                continue;
            }
        } else if (value >= 0x30a0 && value <= 0x30ff) {
            //KATAKANA
            for (; i < s.length() && value >= 0x30a0 && value <= 0x30ff;) {
                katakanaPhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }

            if (!katakanaPhrase.toString().equals("")) {
                output.add(katakanaPhrase.toString());
                katakanaPhrase.replace(0, katakanaPhrase.length(), "");
                continue;
            }
        } else if (value >= 0x3000 && value <= 0x303f) {
            //JAPANESE PUNCTUATION
            for (; i < s.length() && value >= 0x3000 && value <= 0x303f;) {
                japanesePunctuationPhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }

            if (!japanesePunctuationPhrase.equals("")) {
                output.add(japanesePunctuationPhrase.toString());
                japanesePunctuationPhrase.replace(0, japanesePunctuationPhrase.length(), "");
                continue;
            }
        } else if (value >= 0xff00 && value <= 0xffef) {
            //FULL-WIDTH ROMAN CHARACTERS and HALF-WIDTH KATAKANA
            for (; i < s.length() && value >= 0xff00 && value <= 0xffef;) {
                fullWidthRomanCharAndHalfWidthKatakanaPhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }

            if (!fullWidthRomanCharAndHalfWidthKatakanaPhrase.toString().equals("")) {
                output.add(fullWidthRomanCharAndHalfWidthKatakanaPhrase.toString());
                fullWidthRomanCharAndHalfWidthKatakanaPhrase.replace(0,
                        fullWidthRomanCharAndHalfWidthKatakanaPhrase.length(), "");
                continue;
            }
        } else {
            //IF NONE OF THE ABOVE
            for (; i < s.length() && ((value < 0x3000 || value > 0xffef));) {
                othersPhrase.append(s.charAt(i));
                i++;
                if (i < s.length()) {
                    value = (int) s.charAt(i);
                } else {
                    break;
                }
            }

            if (!othersPhrase.toString().equals("")) {
                output.add(othersPhrase.toString() + " ");
                othersPhrase.replace(0, othersPhrase.length(), "");
                continue;
            }
        }
        i++; //do increment here          
    }
    return output;
}