如何优化我的 Java 代码以使用 Java 7 开关?
How to optimize my Java code for using Java 7 switch?
我有一个疑问,我有一个通过参数获得的字符串,问题是拆分我知道你不知道它是否是最好的,但我的想法是分离这些感兴趣的价值链我,然后比较一下。
public class TestSplit {
public static final String CODIGO_BUSCAR = "001";
public static final String CODIGO_NUEVO = "002";
public static final String CODIGO_MODIFICAR = "003";
public static final String CODIGO_ELIMINAR = "004";
public static final String CODIGO_CONSULTAR = "006";
public static void main(String[] args) throws Exception {
boolean mostrarBotonNuevo = false;
boolean mostrarBotonModificar = false;
boolean mostrarBotonConsultar = false;
boolean mostrarBotonEliminar = false;
boolean mostrarBotonBuscar = false;
String key = "{javax.faces.partial.ajax=true, javax.faces.source=j_idt88:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt88:linkAjax=j_idt88:linkAjax, parametroAccion={javax.faces.partial.ajax=true, javax.faces.source=j_idt80:j_idt82:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt80:j_idt82:linkAjax=j_idt80:j_idt82:linkAjax, parametroAccion={menuForm=menuForm, j_idt46_activeIndex=0, javax.faces.ViewState=KAITjDUzvPckml3R4yYr9j3J2z/iwqr8HrkQyCyPl4QUNAom0iY7kGQqomJaUN4enfhiwIGBXb1c9bgohVXD3P0emxCpykIM9fGP2hBtKq2fPssmHkbbYDNa5DX2mxTvTssCeRZ/Y1dTSim2x/J/lJQFpa8e/GJh8KkK7AaVCb1X3kk5J5nZHIlhDpfnRwGe7VfHxkQNKsdiDhf+lCwp+rDb0eGsOyGnRSaIB83TVbCBqN6E8IARA6i5FiQe6qW6hxAA0tpCoMGQO69sKau3TCZEAbDCyLnaGa471QEl4974sSziZVQBRywJJsdBM+seSrgnO04idUdCpY7n/qJLyB8L5yNn5beTki/azTOMBPKQgK2NC/ACILU/E8QeQ6zq0vJ43/I16s+t1IgB3ajnOAMsvkMyU9LLDjlbCrMnlyoUVlPIwVK6Qg+dBTkyNOXXTu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t46:j_idt55=j_idt46:j_idt55, menuItemCotizaciones005=menuItemCotizaciones005, menuItemCotizaciones006=menuItemCotizaciones006, j_idt46:j_idt55_menuid=2_9, menuItemCotizaciones003=menuItemCotizaciones003, menuItemCotizaciones004=menuItemCotizaciones004, menuItemCotizaciones001=menuItemCotizaciones001, menuItemCotizaciones002=menuItemCotizaciones002}, principalForm=principalForm, idSeleccionoRegistro=false, j_idt120:input=, j_idt124:select_focus=, j_idt124:select_input=, j_idt129:select_focus=, j_idt129:select_input=, j_idt134:calendar_input=, j_idt137:calendar_input=, javax.faces.ViewState=YmaLdynq93csVHnfBbfsdEoqLX1VsE34AnGcIl1K609wg0pfECjwZI0e3Y/hu6fvEhAElNo9Theyrh8/cEDWpeiQRJ/is89OXCI3dpp1Gk8oEERlP3xS4ivexx3OzET5k2UqbGDOYvv9yejBe7jwCJqA4Uw/yXtXHc959XW7sAjV9Rs8d5JqWgchaayW0UaWdPb0piAs+e5WETWxYZShLXGF3kQ+ikf4NG1xUEiOnXvUHyn+Th7tbmRqSEa/idPOKzoirxMunWtGXWg9/Uu3cl2OqBwDJEMT99ryys5THtds8fgrixOvNksVsuk8HkeR/QrwFq9LM7CqWu1ho9PyAraySSg5WRN9IZkcFV7MGw5TzJG9pVkGZs21xeZozB28Fk5tiG9c3G9qa9IXYL53RLOZb27/wLZlWPedGkiDoEzXXdnSP315uRshDASLCMzvqJFy4/Y4IX2Sdk5Ks4px9aqGMoXFUd2vJpOQniKrx+tkzUsX5NNheLQZCHGchSDivhjwxmbxk/hy0KnKAsitC/XM2cb47Jvd/Y/zqDmFMu05Jya36rOC+bT7hElV9u/NZgf0ZscFuZ4x6LIWKyjkhAmRanSOBDlFs24fu3NMv+FE2Q5OpGzgHyDn+gq1fo4tcNk9szeSuF06FMtIA5vnd1GCojssv5c0cRv656ndBLx9hHmIULjg9avxu0fpKHTLQultYTXTp9m7OCkESSTKV/qLymItsGgwLK3NvDEQ0a3ovweO6GKEi8MTnOxn0aFw06F7YmsOb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GQSj+mdb3SuGcrHcaNb4e7jyO9S/JziaoX+WOKfj3lZ7Enr32NMeNospIiXqYu6DzMdW8egfjGydZuKx/zfDsycvYUJ1HKD8W588F5ZkDTxSH3C/CPf50FpTEEBX+RXe7+6WPs71rUTepkqAjOYMgw4gVpD+nNx5C...";
String keyFormat [] = key.split("=");
for(String value : keyFormat) {
System.out.println("--> "+value);
if(value.endsWith(CODIGO_BUSCAR)) {
mostrarBotonBuscar = true;
}
if(value.endsWith(CODIGO_NUEVO)) {
mostrarBotonNuevo = true;
}
if(value.endsWith(CODIGO_MODIFICAR)) {
mostrarBotonModificar = true;
}
if(value.endsWith(CODIGO_ELIMINAR)) {
mostrarBotonEliminar = true;
}
if(value.endsWith(CODIGO_CONSULTAR)) {
mostrarBotonConsultar = true;
}
}
System.out.println("--> mostrarBotonBuscar: "+mostrarBotonBuscar+" mostrarBotonNuevo: "+mostrarBotonNuevo+
" mostrarBotonModificar: "+mostrarBotonModificar+" mostrarBotonEliminar: "+mostrarBotonEliminar+
" mostrarBotonConsultar: "+mostrarBotonConsultar);
}
}
基本上我所做的就是使用slipt来分隔字符串并比较值是否以"001"、"002"结尾, "003", "004" and "006", 其他细节无所谓,然后他们相遇就是激活相应的布尔状态。
我正在考虑使用 switch 或 while 运算符来优化我的代码,如果有人可以给我一个改进我的指导代码,因为注意到循环正在比较每个链,所以想法是比较每个链并完成循环。
关于使用子字符串和开关的问题....
public class TestSplit {
public static final String CODIGO_BUSCAR = "001";
public static final String CODIGO_NUEVO = "002";
public static final String CODIGO_MODIFICAR = "003";
public static final String CODIGO_ELIMINAR = "004";
public static final String CODIGO_CONSULTAR = "006";
public static void main(String[] args) throws Exception {
boolean mostrarBotonNuevo = false;
boolean mostrarBotonModificar = false;
boolean mostrarBotonConsultar = false;
boolean mostrarBotonEliminar = false;
boolean mostrarBotonBuscar = false;
String key = "{javax.faces.partial.ajax=true, javax.faces.source=j_idt88:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt88:linkAjax=j_idt88:linkAjax, parametroAccion={javax.faces.partial.ajax=true, javax.faces.source=j_idt80:j_idt82:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt80:j_idt82:linkAjax=j_idt80:j_idt82:linkAjax, parametroAccion={menuForm=menuForm, j_idt46_activeIndex=0, javax.faces.ViewState=KAITjDUzvPckml3R4yYr9j3J2z/iwqr8HrkQyCyPl4QUNAom0iY7kGQqomJaUN4enfhiwIGBXb1c9bgohVXD3P0emxCpykIM9fGP2hBtKq2fPssmHkbbYDNa5DX2mxTvTssCeRZ/Y1dTSim2x/J/lJQFpa8e/GJh8KkK7AaVCb1X3kk5J5nZHIlhDpfnRwGe7VfHxkQNKsdiDhf+lCwp+rDb0eGsOyGnRSaIB83TVbCBqN6E8IARA6i5FiQe6qW6hxAA0tpCoMGQO69sKau3TCZEAbDCyLnaGa471QEl4974sSziZVQBRywJJsdBM+seSrgnO04idUdCpY7n/qJLyB8L5yNn5beTki/azTOMBPKQgK2NC/ACILU/E8QeQ6zq0vJ43/I16s+t1IgB3ajnOAMsvkMyU9LLDjlbCrMnlyoUVlPIwVK6Qg+dBTkyNOXXTuYLm9hXdaIcjbXXqLbQj7igfFWA9dAmCn5AAHA8ttIQ6kEBuTc+Ldd5UxNhxn1lVrcafItdp+4kkv1BhMJVsVUJRDwRwnfeTbf6XwlaICHeHg9EDhQOXP8bAJz5d4fpGgXgjwizqRnqdTG4B14cfLJgMG5QNOlYD6aY6mU2xH3oQ9SNsGRsRccCfBKJaBgxzED8K7JcAvbL9OQ7mA6lJz7ZvX8z3jGRJYsNZu0bXYz3I9XHpmml69jceMN8RNtlz7bzWDlANnqtENKfK8TmVuc2r/I6SnAcJIbumQhECd8zoJQj1Mr8p+QorRI2HZEt9eJlV49Ohadkvfpn+kxsMojrJ8B5Ib+JW+YJijvFB/LS3ABFMKdxhxJsngKxUl/JIUXV4ArXWdj7dh9b3anW/++7gqCxwO2dzIBnU0wEtxy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Kee6xpKPG6Py8HDO/IAfi9Cq3Apbt6R7ZAKi8sB7ltAuCY6h60qDT3m46OO8nvTJQvVESBrPxKiuHEEx4g6gLjI362tb+tPOQ0iQ3I0VZgF6UvtHK8D0hw+b7tGsnILcQYabjzciN0g9cf+9w6Kr6FpfT7gKPP1ODMoBKcZYC/HgbIfx2f/+/Qsszc2njFiZlPmtqZBR7T+lHdK7g6sUQm0DsGO1jDHBw3zNc1clPPcFm6oxSE3fkNaIPzwZZDkwpv7UkJGAlQ9NVGayHEWZBk+aMKjRLDNOordde5byeuYoopwG9Ex6UtwPMlDiAd3ofcvrGXJoE9J5zWRijmFlbD524VG703Dx8c5x+3ymKPg9snfLMSPM4c5tYhT9ileJ1CwwBGPRhByu9QbIGvm9BO04V3G7h+XMSoCsIzFDmzQ6GbktnTFVEyaHcM9XJ2DNSfFzOYbrUiWM4hNFQTUWSPPJ8VdiurJnbN1Dl+mSub+bQgurmnkO7Iq9foE7ILlXiQv1qI3fvHIdpB4kCNCYSTeHXtgwCxQzvLBD1CGdStzgAkLxZa2m9tTy5Cc8dVh/spKlv0Ia+AHWFDZAziZD8gbPkos5N8=, vdesOpcForm=menuItemCotizaciones, j_idt46:j_idt55=j_idt46:j_idt55, menuItemCotizaciones005=menuItemCotizaciones005, menuItemCotizaciones006=menuItemCotizaciones006, j_idt46:j_idt55_menuid=2_9, menuItemCotizaciones003=menuItemCotizaciones003, menuItemCotizaciones004=menuItemCotizaciones004, menuItemCotizaciones001=menuItemCotizaciones001, menuItemCotizaciones002=menuItemCotizaciones002}, principalForm=principalForm, idSeleccionoRegistro=false, j_idt120:input=, j_idt124:select_focus=, j_idt124:select_input=, j_idt129:select_focus=, j_idt129:select_input=, j_idt134:calendar_input=, j_idt137:calendar_input=, javax.faces.ViewState=YmaLdynq93csVHnfBbfsdEoqLX1VsE34AnGcIl1K609wg0pfECjwZI0e3Y/hu6fvEhAElNo9Theyrh8/cEDWpeiQRJ/is89OXCI3dpp1Gk8oEERlP3xS4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0nT1yVxQzhW2940MlA0GTPG6gbhY27q1TW4Wcgx9DG0a7DsruuW/4AfgJKC0CdfIBITMVULG/ud/dR+oS8L1AlWFbUNK+7R0iBNZhMpfFMFDK+dCQ5lNRsPxTZeZWuY5vUgONnX9mt60NgkqwTae6pTxxgSAGFhAScN812UN0BjpR4Cf5dAiDDreB/jZsbP7G/GUCwQ2b4HDcw9Df+eXXGdjBLAFt+y+DN+bTXdOL50/w0GnPuMq60IpdR58tYeUDQnBXx0apc+c+sIv9hCaPQKkoHPvDuWnA7cmvCDTQGjQq5Zs9+MagQ31sZVioTDCbiCx89O0vQ3l+RZY47q/OyDZ2K+WHAQVDUox2pN87YpNWkN4a1x8jF0xHM4nrdpx/h8GKms5PU55uo6NlPIZaNkf1e7vdluBkDw1SFyXAVZhGoe121Pa1PlKY/uD0dVmIXZ+H2dfh3zXlawwTDEyx4ZoVLpr8Ni8+diSThy2snaXyn4LGXdbpEjgLfCpSmaI2hdvRjuswjSAtc6RTNv++8v4SK5Z3NJ0wQxGgA5YJaGIWn0ee96VwHnQZZHG8z2ALOjgtJ/10WUU1X28UL+kDY3gkLafkfdrP3NYNMs1LZ03yvZfmks5ZBrsSTl1CGQSj+mdb3SuGcrHcaNb4e7jyO9S/JziaoX+WOKfj3lZ7Enr32NMeNospIiXqYu6DzMdW8egfjGydZuKx/zfDsycvYUJ1HKD8W588F5ZkDTxSH3C/CPf50FpTEEBX+RXe7+6WPs71rUTepkqAjOYMgw4gVpD+nNx5C...";
String keyFormat [] = key.split("=");
for(String value : keyFormat) {
int size = value.length();
if(size > 3) {
String vcodIdeObj = value.substring(size-3, size);
switch (vcodIdeObj) {
case CODIGO_BUSCAR:
mostrarBotonBuscar = true;
break;
case CODIGO_NUEVO:
mostrarBotonNuevo = true;
break;
case CODIGO_MODIFICAR:
mostrarBotonModificar = true;
break;
case CODIGO_ELIMINAR:
mostrarBotonEliminar = true;
break;
case CODIGO_CONSULTAR:
mostrarBotonConsultar = true;
break;
}
}
}
}
}
请验证我的代码,谢谢。
我认为 while
甚至不适合这里。 switch
也不会有任何好处(与其保持原样,或者更好,将 ifs
更改为 else-ifs
。但我可以给出一个更好的主意,其中涉及 none 他们。只需使用 ||
运算符。这将需要将您的 for
循环更改为:
for(String value : keyFormat) {
System.out.println("--> "+value);
mostrarBotonBuscar = mostrarBotonBuscar || value.endsWith(CODIGO_BUSCAR);
mostrarBotonNuevo = mostrarBotonNuevo || value.endsWith(CODIGO_NUEVO);
mostrarBotonModificar = mostrarBotonModificar || value.endsWith(CODIGO_MODIFICAR);
mostrarBotonEliminar = mostrarBotonEliminar || value.endsWith(CODIGO_ELIMINAR);
mostrarBotonConsultar = mostrarBotonConsultar || value.endsWith(CODIGO_CONSULTAR);
}
就是这样。没有其他你需要的。此外,一旦标志设置为 true
.
,它也将停止评估相应的 endsWith()
方法
我有一个疑问,我有一个通过参数获得的字符串,问题是拆分我知道你不知道它是否是最好的,但我的想法是分离这些感兴趣的价值链我,然后比较一下。
public class TestSplit {
public static final String CODIGO_BUSCAR = "001";
public static final String CODIGO_NUEVO = "002";
public static final String CODIGO_MODIFICAR = "003";
public static final String CODIGO_ELIMINAR = "004";
public static final String CODIGO_CONSULTAR = "006";
public static void main(String[] args) throws Exception {
boolean mostrarBotonNuevo = false;
boolean mostrarBotonModificar = false;
boolean mostrarBotonConsultar = false;
boolean mostrarBotonEliminar = false;
boolean mostrarBotonBuscar = false;
String key = "{javax.faces.partial.ajax=true, javax.faces.source=j_idt88:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt88:linkAjax=j_idt88:linkAjax, parametroAccion={javax.faces.partial.ajax=true, javax.faces.source=j_idt80:j_idt82:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt80:j_idt82:linkAjax=j_idt80:j_idt82:linkAjax, parametroAccion={menuForm=menuForm, j_idt46_activeIndex=0, javax.faces.ViewState=KAITjDUzvPckml3R4yYr9j3J2z/iwqr8HrkQyCyPl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PPcFm6oxSE3fkNaIPzwZZDkwpv7UkJGAlQ9NVGayHEWZBk+aMKjRLDNOordde5byeuYoopwG9Ex6UtwPMlDiAd3ofcvrGXJoE9J5zWRijmFlbD524VG703Dx8c5x+3ymKPg9snfLMSPM4c5tYhT9ileJ1CwwBGPRhByu9QbIGvm9BO04V3G7h+XMSoCsIzFDmzQ6GbktnTFVEyaHcM9XJ2DNSfFzOYbrUiWM4hNFQTUWSPPJ8VdiurJnbN1Dl+mSub+bQgurmnkO7Iq9foE7ILlXiQv1qI3fvHIdpB4kCNCYSTeHXtgwCxQzvLBD1CGdStzgAkLxZa2m9tTy5Cc8dVh/spKlv0Ia+AHWFDZAziZD8gbPkos5N8=, vdesOpcForm=menuItemCotizaciones, j_idt46:j_idt55=j_idt46:j_idt55, menuItemCotizaciones005=menuItemCotizaciones005, menuItemCotizaciones006=menuItemCotizaciones006, j_idt46:j_idt55_menuid=2_9, menuItemCotizaciones003=menuItemCotizaciones003, menuItemCotizaciones004=menuItemCotizaciones004, menuItemCotizaciones001=menuItemCotizaciones001, menuItemCotizaciones002=menuItemCotizaciones002}, principalForm=principalForm, idSeleccionoRegistro=false, j_idt120:input=, j_idt124:select_focus=, j_idt124:select_input=, j_idt129:select_focus=, j_idt129:select_input=, j_idt134:calendar_input=, j_idt137:calendar_input=, javax.faces.ViewState=YmaLdynq93csVHnfBbfsdEoqLX1VsE34AnGcIl1K609wg0pfECjwZI0e3Y/hu6fvEhAElNo9Theyrh8/cEDWpeiQRJ/is89OXCI3dpp1Gk8oEERlP3xS4ivexx3OzET5k2UqbGDOYvv9yejBe7jwCJqA4Uw/yXtXHc959XW7sAjV9Rs8d5JqWgchaayW0UaWdPb0piAs+e5WETWxYZShLXGF3kQ+ikf4NG1xUEiOnXvUHyn+Th7tbmRqSEa/idPOKzoirxMunWtGXWg9/Uu3cl2OqBwDJEMT99ryys5THtds8fgrixOvNksVsuk8HkeR/QrwFq9LM7CqWu1ho9PyAraySSg5WRN9IZkcFV7MGw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0GnPuMq60IpdR58tYeUDQnBXx0apc+c+sIv9hCaPQKkoHPvDuWnA7cmvCDTQGjQq5Zs9+MagQ31sZVioTDCbiCx89O0vQ3l+RZY47q/OyDZ2K+WHAQVDUox2pN87YpNWkN4a1x8jF0xHM4nrdpx/h8GKms5PU55uo6NlPIZaNkf1e7vdluBkDw1SFyXAVZhGoe121Pa1PlKY/uD0dVmIXZ+H2dfh3zXlawwTDEyx4ZoVLpr8Ni8+diSThy2snaXyn4LGXdbpEjgLfCpSmaI2hdvRjuswjSAtc6RTNv++8v4SK5Z3NJ0wQxGgA5YJaGIWn0ee96VwHnQZZHG8z2ALOjgtJ/10WUU1X28UL+kDY3gkLafkfdrP3NYNMs1LZ03yvZfmks5ZBrsSTl1CGQSj+mdb3SuGcrHcaNb4e7jyO9S/JziaoX+WOKfj3lZ7Enr32NMeNospIiXqYu6DzMdW8egfjGydZuKx/zfDsycvYUJ1HKD8W588F5ZkDTxSH3C/CPf50FpTEEBX+RXe7+6WPs71rUTepkqAjOYMgw4gVpD+nNx5C...";
String keyFormat [] = key.split("=");
for(String value : keyFormat) {
System.out.println("--> "+value);
if(value.endsWith(CODIGO_BUSCAR)) {
mostrarBotonBuscar = true;
}
if(value.endsWith(CODIGO_NUEVO)) {
mostrarBotonNuevo = true;
}
if(value.endsWith(CODIGO_MODIFICAR)) {
mostrarBotonModificar = true;
}
if(value.endsWith(CODIGO_ELIMINAR)) {
mostrarBotonEliminar = true;
}
if(value.endsWith(CODIGO_CONSULTAR)) {
mostrarBotonConsultar = true;
}
}
System.out.println("--> mostrarBotonBuscar: "+mostrarBotonBuscar+" mostrarBotonNuevo: "+mostrarBotonNuevo+
" mostrarBotonModificar: "+mostrarBotonModificar+" mostrarBotonEliminar: "+mostrarBotonEliminar+
" mostrarBotonConsultar: "+mostrarBotonConsultar);
}
}
基本上我所做的就是使用slipt来分隔字符串并比较值是否以"001"、"002"结尾, "003", "004" and "006", 其他细节无所谓,然后他们相遇就是激活相应的布尔状态。
我正在考虑使用 switch 或 while 运算符来优化我的代码,如果有人可以给我一个改进我的指导代码,因为注意到循环正在比较每个链,所以想法是比较每个链并完成循环。
关于使用子字符串和开关的问题....
public class TestSplit {
public static final String CODIGO_BUSCAR = "001";
public static final String CODIGO_NUEVO = "002";
public static final String CODIGO_MODIFICAR = "003";
public static final String CODIGO_ELIMINAR = "004";
public static final String CODIGO_CONSULTAR = "006";
public static void main(String[] args) throws Exception {
boolean mostrarBotonNuevo = false;
boolean mostrarBotonModificar = false;
boolean mostrarBotonConsultar = false;
boolean mostrarBotonEliminar = false;
boolean mostrarBotonBuscar = false;
String key = "{javax.faces.partial.ajax=true, javax.faces.source=j_idt88:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt88:linkAjax=j_idt88:linkAjax, parametroAccion={javax.faces.partial.ajax=true, javax.faces.source=j_idt80:j_idt82:linkAjax, javax.faces.partial.execute=@all, javax.faces.partial.render=mensajesGrowl, j_idt80:j_idt82:linkAjax=j_idt80:j_idt82:linkAjax, parametroAccion={menuForm=menuForm, j_idt46_activeIndex=0, javax.faces.ViewState=KAITjDUzvPckml3R4yYr9j3J2z/iwqr8HrkQyCyPl4QUNAom0iY7kGQqomJaUN4enfhiwIGBXb1c9bgohVXD3P0emxCpykIM9fGP2hBtKq2fPssmHkbbYDNa5DX2mxTvTssCeRZ/Y1dTSim2x/J/lJQFpa8e/GJh8KkK7AaVCb1X3kk5J5nZHIlhDpfnRwGe7VfHxkQNKsdiDhf+lCwp+rDb0eGsOyGnRSaIB83TVbCBqN6E8IARA6i5FiQe6qW6hxAA0tpCoMGQO69sKau3TCZEAbDCyLnaGa471QEl4974sSziZVQBRywJJsdBM+seSrgnO04idUdCpY7n/qJLyB8L5yNn5beTki/azTOMBPKQgK2NC/ACILU/E8QeQ6zq0vJ43/I16s+t1IgB3ajnOAMsvkMyU9LLDjlbCrMnlyoUVlPIwVK6Qg+dBTkyNOXXTuYLm9hXdaIcjbXXqLbQj7igfFWA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Cotizaciones005=menuItemCotizaciones005, menuItemCotizaciones006=menuItemCotizaciones006, j_idt46:j_idt55_menuid=2_9, menuItemCotizaciones003=menuItemCotizaciones003, menuItemCotizaciones004=menuItemCotizaciones004, menuItemCotizaciones001=menuItemCotizaciones001, menuItemCotizaciones002=menuItemCotizaciones002}, principalForm=principalForm, idSeleccionoRegistro=false, j_idt120:input=, j_idt124:select_focus=, j_idt124:select_input=, j_idt129:select_focus=, j_idt129:select_input=, j_idt134:calendar_input=, j_idt137:calendar_input=, javax.faces.ViewState=YmaLdynq93csVHnfBbfsdEoqLX1VsE34AnGcIl1K609wg0pfECjwZI0e3Y/hu6fvEhAElNo9Theyrh8/cEDWpeiQRJ/is89OXCI3dpp1Gk8oEERlP3xS4ivexx3OzET5k2UqbGDOYvv9yejBe7jwCJqA4Uw/yXtXHc959XW7sAjV9Rs8d5JqWgchaayW0UaWdPb0piAs+e5WETWxYZShLXGF3kQ+ikf4NG1xUEiOnXvUHyn+Th7tbmRqSEa/idPOKzoirxMunWtGXWg9/Uu3cl2OqBwDJEMT99ryys5THtds8fgrixOvNksVsuk8HkeR/QrwFq9LM7CqWu1ho9PyAraySSg5WRN9IZkcFV7MGw5TzJG9pVkGZs21xeZozB28Fk5tiG9c3G9qa9IXYL53RLOZb27/wLZlWPedGkiDoEzXXdnSP315uRshDASLCMzvqJFy4/Y4IX2Sdk5Ks4px9aqGMoXFUd2vJpOQniKrx+tkzUsX5NNheLQZCHGchSDivhjwxmbxk/hy0KnKAsitC/XM2cb47Jvd/Y/zqDmFMu05Jya36rOC+bT7hElV9u/NZgf0ZscFuZ4x6LIWKyjkhAmRanSOBDlFs24fu3NMv+FE2Q5OpGzgHyDn+gq1fo4tcNk9szeSuF06FMtIA5vnd1GCojssv5c0cRv656ndBLx9hHmIULjg9avxu0fpKHTLQultYTXTp9m7OCkESSTKV/qLymItsGgwLK3NvDEQ0a3ovweO6GKEi8MTnOxn0aFw06F7YmsObd4ITKIR8qwHTjORGcPDskBL0mS3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9S/JziaoX+WOKfj3lZ7Enr32NMeNospIiXqYu6DzMdW8egfjGydZuKx/zfDsycvYUJ1HKD8W588F5ZkDTxSH3C/CPf50FpTEEBX+RXe7+6WPs71rUTepkqAjOYMgw4gVpD+nNx5C...";
String keyFormat [] = key.split("=");
for(String value : keyFormat) {
int size = value.length();
if(size > 3) {
String vcodIdeObj = value.substring(size-3, size);
switch (vcodIdeObj) {
case CODIGO_BUSCAR:
mostrarBotonBuscar = true;
break;
case CODIGO_NUEVO:
mostrarBotonNuevo = true;
break;
case CODIGO_MODIFICAR:
mostrarBotonModificar = true;
break;
case CODIGO_ELIMINAR:
mostrarBotonEliminar = true;
break;
case CODIGO_CONSULTAR:
mostrarBotonConsultar = true;
break;
}
}
}
}
}
请验证我的代码,谢谢。
我认为 while
甚至不适合这里。 switch
也不会有任何好处(与其保持原样,或者更好,将 ifs
更改为 else-ifs
。但我可以给出一个更好的主意,其中涉及 none 他们。只需使用 ||
运算符。这将需要将您的 for
循环更改为:
for(String value : keyFormat) {
System.out.println("--> "+value);
mostrarBotonBuscar = mostrarBotonBuscar || value.endsWith(CODIGO_BUSCAR);
mostrarBotonNuevo = mostrarBotonNuevo || value.endsWith(CODIGO_NUEVO);
mostrarBotonModificar = mostrarBotonModificar || value.endsWith(CODIGO_MODIFICAR);
mostrarBotonEliminar = mostrarBotonEliminar || value.endsWith(CODIGO_ELIMINAR);
mostrarBotonConsultar = mostrarBotonConsultar || value.endsWith(CODIGO_CONSULTAR);
}
就是这样。没有其他你需要的。此外,一旦标志设置为 true
.
endsWith()
方法