基于公共类字符串比较器的比较器{
String string_char漂亮的背包={'a '、' s '、' d '、' f '、' g '、' h '、' k '、' l '、' z '、' x '、'
公共枚举数据类型{
STRING,INTEGER,SPECIAL_CHAR;
}
publicintegergetdatatypepriority {
try{
交换机(类型) {
case SPECIAL_CHAR:
返回1;
case INTEGER:
返回2;
case STRING:
返回3;
默认:
布雷克;
}
}catch(exceptione ) {
e .打印堆栈跟踪(;
}
返回空值;
}
publicbooleanisstringtype{
for(stringtemp:string_char ) )。
if(temp.equalsignorecase(val ) )
返回真;
返回假;
}
公共数据类型分组数据类型(character val ) {
数据类型=null;
try{
集成. parseint (val.tostring ) );
type=DataType.INTEGER;
}catch(exceptione ) {
if(isstringtype(val.tostring ) )
type=DataType.STRING;
else
type=DataType.SPECIAL_CHAR;
}
返回类型;
}
@Override
公共int比较(string new _ val,String old_val )。
int result=0;
try{
if(new_val==null )
是elseif(old_val==null ) )
返回1;
数据类型old数据类型=null;
数据类型新数据类型=null;
int old_length=old_val.length (;
int new_length=new_val.length (;
int max=old_length;
if(new_lengthold_length )//equals
max=new_val.length (;
for(intI=0; I
OLD_Char.Setlength(0;
new_char.Setlength(0;
old _ char.append (old _ val.charat (I ) );
new _ char.append (new _ val.charat (I );
old数据类型PE=get数据类型PE (old _ val.charat (I );
new datatype=get datatype (new _ val.charat (I );
ID (Old数据类型!=newDataType ) {
if (获取数据类型优先级(新数据类型)获取数据类型优先级(old数据类型) )
返回1;
else
}else{//same
if (new datatype.equals (datatype.string ) ) )
if(old_int.length ) (0) {//clearing string builder
OLD_int.Setlength(0;
new_int.Setlength(0;
}
if (new _ char.tostring (.com Pareto ) old_char.tostring ()0) ) ) ) ) ) )。
返回1;
else if (new _ char.tostring (.com Pareto ) old_char.tostring () )0) ) ) ) ) ) ) ) )。
} else if (new datatype.equals (datatype.integer ) )。
old _ int.append (old _ val.charat (I ) );
new _ int.append (new _ val.charat (I ) );
while(I1 )
i=1;
old数据类型PE=get数据类型PE (old _ val.charat (I );
new datatype=get datatype (new _ val.charat (I );
if (old datatype.equals (datatype.integer ) )
old _ int.append (old _ val.charat (I ) );
if (new datatype.equals (datatype.integer ) )
new _ int.append (new _ val.charat (I ) );
ID (Old数据类型!=newDataType )
布雷克;
}
if(new_lengthmax ) {
wile(I1new_length ) {
i=1;
new datatype=get datatype (new _ val.charat (I );
if (new datatype.equals (datatype.integer ) )
new _ int.append (new _ val.charat (I ) );
else
布雷克;
}
}elseif(old_lengthmax ) {
while(I1 )
i=1;
old数据类型PE=get数据类型PE (old _ val.charat (I );
if (old datatype.equals (datatype.integer ) )
old _ int.append (old _ val.charat (I ) );
else
布雷克;
}
}
integern=integer.parseint (new _ int.tostring );
integero=integer.parseint (old _ int.tostring );
是if (否)
返回1;
else if (否) ) )。
}else{//special char
if(old_int.length ) (0) {//clearing string builder
OLD_int.Setlength(0;
new_int.Setlength(0;
}
if (new _ char.tostring (.com Pareto ) old_char.tostring ()0) ) ) ) ) ) )。
返回1;
else if (new _ char.tostring (.com Pareto ) old_char.tostring () )0) ) ) ) ) ) ) ) )。
}
}
}
return new _ val.com Pareto (old _ val );
}catch(exceptione ) {
e .打印堆栈跟踪(;
}
返回结果;
}