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

io.baltoro.client.util.StringUtil Maven / Gradle / Ivy

There is a newer version: 4.0.12
Show newest version
package io.baltoro.client.util;

import java.util.Base64;
import java.util.Collection;
import java.util.Iterator;

import io.baltoro.obj.Base;

public class StringUtil 
{
	public static boolean isNullOrEmpty(String str)
	{
		if(str != null && str.length() > 0)
		{
			return false;
		}
		
		return true;
			
	}
	
	public static boolean isNullOrEmpty(Object[] objs)
	{
		if(objs != null && objs.length > 0)
		{
			return false;
		}
		
		return true;
			
	}
	
	public static boolean isNullOrEmpty(Collection col)
	{
		if(col != null && col.size() > 0)
		{
			return false;
		}
		
		return true;
			
	}
	
	public static boolean isNotNullAndNotEmpty(String str)
	{
		if(str != null && str.length() > 0)
		{
			return true;
		}
		
		return false;	
	}
	
	public static boolean isNotNullAndNotEmpty(Object[] str)
	{
		if(str != null && str.length > 0)
		{
			return true;
		}
		
		return false;	
	}
	
	public static boolean isNotNullAndNotEmpty(Collection col)
	{
		if(col != null && col.size() > 0)
		{
			return true;
		}
		
		return false;	
	}
	
	
	public static String stripPhoneNumber(String phoneNumber)
	{
		StringBuffer str = new StringBuffer();
		
		char[] chars = phoneNumber.toCharArray();
		for (int i = 0; i < chars.length; i++) 
		{
			char c = chars[i];
			if(c >= '0' && c <= '9')
			{
				str.append(chars[i]);
			}
		}
		return str.toString();
	}

	
	
	public static String encode(byte[] bytes)
	{
		return Base64.getEncoder().encodeToString(bytes);
	}
	
	public static byte[] decode(String str)
	{
		return Base64.getDecoder().decode(str);
	}
	
	
	public static String[] toUuids(Base[] objs)
	{
		String[] uuids = new String[objs.length];
		
		for (int i=0;i col)
	{
		if(col==null || col.isEmpty())
		{
			return "";
		}
		
		StringBuilder buffer = new StringBuilder(col.size() * 10); 
		Iterator it = col.iterator();
		while(it.hasNext())
		{
			String val = it.next();
			buffer.append("'"+val+"',");
		}
		buffer.deleteCharAt(buffer.length()-1);
		
		return buffer.toString();
	}
	
	public static String toInClauseForMetadata(Collection col)
	{
		if(col==null || col.isEmpty())
		{
			return "";
		}
		
		StringBuilder buffer = new StringBuilder(col.size() * 10); 
		Iterator it = col.iterator();
		while(it.hasNext())
		{
			Base val = it.next();
			buffer.append("'"+val.getLatestVersionUuid()+"',");
		}
		buffer.deleteCharAt(buffer.length()-1);
		
		return buffer.toString();
	}
	
	
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy