Java String Split splitCQLStatements(String source)

Here you can find the source of splitCQLStatements(String source)

Description

Split a script containing one or more CQL statements (terminated by ;'s) into a list of individual statements.

License

Apache License

Parameter

Parameter Description
source the source script

Return

a list of individual CQL statements

Declaration

public static List<String> splitCQLStatements(String source) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *
 * Pentaho Big Data/*  w  ww  .ja  v a 2s. c  o m*/
 *
 * Copyright (C) 2002-2013 by Pentaho : http://www.pentaho.com
 *
 *******************************************************************************
 *
 * 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.
 *
 ******************************************************************************/

import java.util.ArrayList;

import java.util.List;

public class Main {
    /**
     * Split a script containing one or more CQL statements (terminated by ;'s) into a list of individual statements.
     * 
     * @param source
     *          the source script
     * @return a list of individual CQL statements
     */
    public static List<String> splitCQLStatements(String source) {
        String[] cqlStatements = source.split(";"); //$NON-NLS-1$
        List<String> individualStatements = new ArrayList<String>();

        if (cqlStatements.length > 0) {
            for (String cqlC : cqlStatements) {
                cqlC = cqlC.trim();
                if (!cqlC.endsWith(";")) { //$NON-NLS-1$
                    cqlC += ";"; //$NON-NLS-1$
                }

                individualStatements.add(cqlC);
            }
        }

        return individualStatements;
    }
}

Related

  1. splitAttributes(final String dname)
  2. splitAuthors(String source)
  3. splitBreaks(String text)
  4. splitByTypeAndName(final String s)
  5. splitCamelback(String s)
  6. splitDateText(String text)
  7. splitDigits(long input)
  8. splitDomains(String domains)
  9. splitElements(String values)