1 52 53 package com.go.teaservlet; 54 55 import java.lang.reflect.Method ; 56 import java.beans.*; 57 import com.go.teaservlet.util.NameValuePair; 58 59 65 public class FunctionInfo extends NameValuePair { 66 private ApplicationInfo mApp; 67 68 public FunctionInfo(MethodDescriptor method, ApplicationInfo provider) { 69 super(method.getName(), method); 70 mApp = provider; 71 } 72 73 public MethodDescriptor getDescriptor() { 74 return (MethodDescriptor)getValue(); 75 } 76 77 public ApplicationInfo getProvider() { 78 return mApp; 79 } 80 81 public int compareTo(Object other) { 82 String thisName = getName(); 83 String otherName = ((FunctionInfo)other).getName(); 84 85 if (thisName == null) { 86 return otherName == null ? 0 : 1; 87 } 88 89 if (otherName == null) { 90 return -1; 91 } 92 93 String thisPrefix, otherPrefix; 94 int index = thisName.indexOf('$'); 95 if (index <= 0) { 96 thisPrefix = ""; 97 } 98 else { 99 thisPrefix = thisName.substring(0, index); 100 thisName = thisName.substring(index + 1); 101 } 102 103 index = otherName.indexOf('$'); 104 if (index <= 0) { 105 otherPrefix = ""; 106 } 107 else { 108 otherPrefix = otherName.substring(0, index); 109 otherName = otherName.substring(index + 1); 110 } 111 112 int compare = thisName.compareToIgnoreCase(otherName); 114 if (compare != 0) { 115 return compare; 116 } 117 118 compare = thisPrefix.compareToIgnoreCase(otherPrefix); 120 if (compare != 0) { 121 return compare; 122 } 123 124 Class [] thisParams = getDescriptor().getMethod().getParameterTypes(); 126 Class [] otherParams = 127 ((FunctionInfo)other).getDescriptor().getMethod().getParameterTypes(); 128 129 if (thisParams.length < otherParams.length) { 130 return -1; 131 } 132 else if (thisParams.length > otherParams.length) { 133 return 1; 134 } 135 136 return 0; 137 } 138 } 139
| Popular Tags
|