Olá,
Estou precisando de uma ajuda em refatoração, observem esses dois métodos:
private String BuscaValoresRetornadosModSeg(String strXML,
String strTagPai, String strTagFilha) throws Exception {
if (strXML != "") {
Document doc = carregarXmlPorString(strXML);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName(strTagPai);
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
return getValorTag(strTagFilha, eElement);
}
}
}
return "";
}
private List<String> BuscarValoresRetornadosModSeg(String strXML,
String strTagPai, String strTagFilha) throws Exception {
List<String> lstRetorno = new ArrayList<String>();
if (strXML != "") {
Document doc = carregarXmlPorString(strXML);
doc.getDocumentElement().normalize();
NodeList nList = doc.getElementsByTagName(strTagPai);
for (int temp = 0; temp < nList.getLength(); temp++) {
Node nNode = nList.item(temp);
if (nNode.getNodeType() == Node.ELEMENT_NODE) {
Element eElement = (Element) nNode;
lstRetorno.add(getValorTag(strTagFilha, eElement));
}
}
}
return lstRetorno;
}
Não gostaria de deixá-los duplicados assim, como eu poderia refatorar??
Obrigado.