All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.abubusoft.kripton.android.sqlite.SpreadUtils Maven / Gradle / Ivy

The newest version!
package com.abubusoft.kripton.android.sqlite;

import java.util.Collection;

/**
 * Contains utilitity function for split arguments and generate ?.
 * 
 * @author Francesco Benincasa ([email protected])
 *
 */
public abstract class SpreadUtils {
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(byte[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}

	/**
	 * @param args
	 * @return
	 */
	private static String generateInternal(int length) {
		StringBuilder buffer = new StringBuilder("?");

		for (int i = 1; i < length; i++) {
			buffer.append(", ?");
		}

		return buffer.toString();
	}
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(char[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(short[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(int[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(long[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(float[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(double[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	

	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(E[] args) {
		if (args == null || args.length == 0)
			return "";

		return generateInternal(args.length);
	}
	
	/**
	 * For each element of array, generate a question.
	 * 
	 * @param args
	 * @return
	 */
	public static  String generateQuestion(Collection args) {
		if (args == null || args.size() == 0)
			return "";

		return generateInternal(args.size());
	}
		
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy