// Generated by Haxe 4.3.1
package haxe.root;

import haxe.root.*;

@SuppressWarnings(value={"rawtypes", "unchecked"})
public class StringTools extends haxe.lang.HxObject
{
	public StringTools(haxe.lang.EmptyObject empty)
	{
	}
	
	
	public StringTools()
	{
		//line 38 "/usr/share/haxe/std/StringTools.hx"
		haxe.root.StringTools.__hx_ctor__StringTools(this);
	}
	
	
	protected static void __hx_ctor__StringTools(haxe.root.StringTools __hx_this)
	{
	}
	
	
	public static java.lang.String htmlEscape(java.lang.String s, java.lang.Object quotes)
	{
		//line 159 "/usr/share/haxe/std/StringTools.hx"
		haxe.root.StringBuf buf = new haxe.root.StringBuf();
		//line 160 "/usr/share/haxe/std/StringTools.hx"
		{
			//line 160 "/usr/share/haxe/std/StringTools.hx"
			int _g_offset = 0;
			//line 160 "/usr/share/haxe/std/StringTools.hx"
			java.lang.String _g_s = s;
			//line 160 "/usr/share/haxe/std/StringTools.hx"
			while (( _g_offset < _g_s.length() ))
			{
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				java.lang.String s1 = _g_s;
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				int index = _g_offset++;
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				int c = ( (( index < s1.length() )) ? (((int) (((java.lang.String) (((java.lang.Object) (s1) )) ).charAt(index)) )) : (-1) );
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				if (( ( c >= 55296 ) && ( c <= 56319 ) )) 
				{
					//line 160 "/usr/share/haxe/std/StringTools.hx"
					int index1 = ( index + 1 );
					//line 639 "/usr/share/haxe/std/StringTools.hx"
					c = ( ( ( c - 55232 ) << 10 ) | ( (( (( index1 < s1.length() )) ? (((int) (((java.lang.String) (((java.lang.Object) (s1) )) ).charAt(index1)) )) : (-1) )) & 1023 ) );
				}
				
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				int c1 = c;
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				if (( c1 >= 65536 )) 
				{
					//line 160 "/usr/share/haxe/std/StringTools.hx"
					 ++ _g_offset;
				}
				
				//line 160 "/usr/share/haxe/std/StringTools.hx"
				int code1 = c1;
				//line 161 "/usr/share/haxe/std/StringTools.hx"
				switch (code1)
				{
					case 34:
					{
						//line 168 "/usr/share/haxe/std/StringTools.hx"
						if (haxe.lang.Runtime.toBool(((java.lang.Boolean) ((quotes)) ))) 
						{
							//line 169 "/usr/share/haxe/std/StringTools.hx"
							buf.add(haxe.lang.Runtime.toString("&quot;"));
							//line 169 "/usr/share/haxe/std/StringTools.hx"
							java.lang.Object __temp_expr1 = ((java.lang.Object) (null) );
						}
						else
						{
							//line 173 "/usr/share/haxe/std/StringTools.hx"
							buf.addChar(code1);
						}
						
						//line 168 "/usr/share/haxe/std/StringTools.hx"
						break;
					}
					
					
					case 38:
					{
						//line 163 "/usr/share/haxe/std/StringTools.hx"
						buf.add(haxe.lang.Runtime.toString("&amp;"));
						//line 163 "/usr/share/haxe/std/StringTools.hx"
						java.lang.Object __temp_expr2 = ((java.lang.Object) (null) );
						//line 163 "/usr/share/haxe/std/StringTools.hx"
						break;
					}
					
					
					case 39:
					{
						//line 170 "/usr/share/haxe/std/StringTools.hx"
						if (haxe.lang.Runtime.toBool(((java.lang.Boolean) ((quotes)) ))) 
						{
							//line 171 "/usr/share/haxe/std/StringTools.hx"
							buf.add(haxe.lang.Runtime.toString("&#039;"));
							//line 171 "/usr/share/haxe/std/StringTools.hx"
							java.lang.Object __temp_expr3 = ((java.lang.Object) (null) );
						}
						else
						{
							//line 173 "/usr/share/haxe/std/StringTools.hx"
							buf.addChar(code1);
						}
						
						//line 170 "/usr/share/haxe/std/StringTools.hx"
						break;
					}
					
					
					case 60:
					{
						//line 165 "/usr/share/haxe/std/StringTools.hx"
						buf.add(haxe.lang.Runtime.toString("&lt;"));
						//line 165 "/usr/share/haxe/std/StringTools.hx"
						java.lang.Object __temp_expr4 = ((java.lang.Object) (null) );
						//line 165 "/usr/share/haxe/std/StringTools.hx"
						break;
					}
					
					
					case 62:
					{
						//line 167 "/usr/share/haxe/std/StringTools.hx"
						buf.add(haxe.lang.Runtime.toString("&gt;"));
						//line 167 "/usr/share/haxe/std/StringTools.hx"
						java.lang.Object __temp_expr5 = ((java.lang.Object) (null) );
						//line 167 "/usr/share/haxe/std/StringTools.hx"
						break;
					}
					
					
					default:
					{
						//line 173 "/usr/share/haxe/std/StringTools.hx"
						buf.addChar(code1);
						//line 173 "/usr/share/haxe/std/StringTools.hx"
						break;
					}
					
				}
				
			}
			
		}
		
		//line 176 "/usr/share/haxe/std/StringTools.hx"
		return buf.toString();
	}
	
	
	public static boolean isSpace(java.lang.String s, int pos)
	{
		//line 287 "/usr/share/haxe/std/StringTools.hx"
		java.lang.Object c = haxe.lang.StringExt.charCodeAt(s, pos);
		//line 288 "/usr/share/haxe/std/StringTools.hx"
		if ( ! ((( ( ((int) (haxe.lang.Runtime.toInt(c)) ) > 8 ) && ( ((int) (haxe.lang.Runtime.toInt(c)) ) < 14 ) ))) ) 
		{
			//line 288 "/usr/share/haxe/std/StringTools.hx"
			return haxe.lang.Runtime.eq(c, 32);
		}
		else
		{
			//line 288 "/usr/share/haxe/std/StringTools.hx"
			return true;
		}
		
	}
	
	
	public static java.lang.String ltrim(java.lang.String s)
	{
		//line 304 "/usr/share/haxe/std/StringTools.hx"
		int l = s.length();
		//line 305 "/usr/share/haxe/std/StringTools.hx"
		int r = 0;
		//line 306 "/usr/share/haxe/std/StringTools.hx"
		while (( ( r < l ) && haxe.root.StringTools.isSpace(s, r) ))
		{
			//line 307 "/usr/share/haxe/std/StringTools.hx"
			 ++ r;
		}
		
		//line 309 "/usr/share/haxe/std/StringTools.hx"
		if (( r > 0 )) 
		{
			//line 310 "/usr/share/haxe/std/StringTools.hx"
			return haxe.lang.StringExt.substr(s, r, ( l - r ));
		}
		else
		{
			//line 312 "/usr/share/haxe/std/StringTools.hx"
			return s;
		}
		
	}
	
	
	public static java.lang.String rtrim(java.lang.String s)
	{
		//line 329 "/usr/share/haxe/std/StringTools.hx"
		int l = s.length();
		//line 330 "/usr/share/haxe/std/StringTools.hx"
		int r = 0;
		//line 331 "/usr/share/haxe/std/StringTools.hx"
		while (( ( r < l ) && haxe.root.StringTools.isSpace(s, ( ( l - r ) - 1 )) ))
		{
			//line 332 "/usr/share/haxe/std/StringTools.hx"
			 ++ r;
		}
		
		//line 334 "/usr/share/haxe/std/StringTools.hx"
		if (( r > 0 )) 
		{
			//line 335 "/usr/share/haxe/std/StringTools.hx"
			return haxe.lang.StringExt.substr(s, 0, ( l - r ));
		}
		else
		{
			//line 337 "/usr/share/haxe/std/StringTools.hx"
			return s;
		}
		
	}
	
	
	public static java.lang.String replace(java.lang.String s, java.lang.String sub, java.lang.String by)
	{
		//line 418 "/usr/share/haxe/std/StringTools.hx"
		if (( sub.length() == 0 )) 
		{
			//line 419 "/usr/share/haxe/std/StringTools.hx"
			return haxe.lang.StringExt.split(s, sub).join(by);
		}
		else
		{
			//line 421 "/usr/share/haxe/std/StringTools.hx"
			return ((java.lang.String) (((java.lang.Object) (s) )) ).replace(((java.lang.CharSequence) (sub) ), ((java.lang.CharSequence) (by) ));
		}
		
	}
	
	
}


