private void getLabelsFromJavaFiles() throws IOException {
   for (String rootFolder : this.rootFolders) {
     List<File> javaFiles = FileUtil.findFiles("java", rootFolder + "src", null, null);
     for (File javaFile : javaFiles) {
       String inFile = FileUtil.readString("UTF-8", javaFile);
       int pos = inFile.indexOf(getMessage);
       while (pos >= 0) {
         int endLabel = inFile.indexOf(")", pos);
         if (endLabel >= 0) {
           String[] args = inFile.substring(pos + getMessage.length(), endLabel).split(",");
           for (String labelKey : this.labelSet) {
             String searchString = "\"" + labelKey + "\"";
             if (searchString.equals(args[1].trim())) {
               setLabelReference(labelKey, javaFile.getPath());
             }
           }
           pos = endLabel;
         } else {
           pos = pos + getMessage.length();
         }
         pos = inFile.indexOf(getMessage, pos);
       }
     }
   }
 }
 private void getLabelsFromSimpleMethodFiles() throws IOException {
   for (String rootFolder : this.rootFolders) {
     List<File> simpleMethodsFiles = FileUtil.findFiles("xml", rootFolder + "script", null, null);
     for (File file : simpleMethodsFiles) {
       String inFile = FileUtil.readString("UTF-8", file);
       findUiLabelMapInFile(inFile, file.getPath());
       findLabelKeyInElement(inFile, file.getPath(), "set");
       findLabelKeyInElement(inFile, file.getPath(), "fail-property");
     }
   }
 }
 private void getLabelsFromFtlFiles() throws IOException {
   for (String rootFolder : this.rootFolders) {
     List<File> ftlFiles = FileUtil.findFiles("ftl", rootFolder, null, null);
     for (File file : ftlFiles) {
       String inFile = FileUtil.readString("UTF-8", file);
       int pos = inFile.indexOf(bracketedUiLabelMap);
       while (pos >= 0) {
         int endPos = inFile.indexOf("}", pos);
         if (endPos >= 0) {
           String labelKey = inFile.substring(pos + bracketedUiLabelMap.length(), endPos);
           if (this.labelSet.contains(labelKey)) {
             setLabelReference(labelKey, file.getPath());
           }
           pos = endPos;
         } else {
           pos = pos + bracketedUiLabelMap.length();
         }
         pos = inFile.indexOf(bracketedUiLabelMap, pos);
       }
     }
   }
 }
 public Map<String, Map<String, Integer>> getLabelReferences()
     throws IOException, SAXException, ParserConfigurationException, GenericServiceException {
   if (this.labels.size() == 0) {
     // Nothing to search for
     return references;
   }
   // get labels from FTL files
   getLabelsFromFtlFiles();
   // get labels from java files
   getLabelsFromJavaFiles();
   // get labels from simple method files
   getLabelsFromSimpleMethodFiles();
   // get labels from widgets files
   List<File> fileList = FastList.newInstance();
   for (String rootFolder : this.rootFolders) {
     fileList.addAll(FileUtil.findXmlFiles(rootFolder + "webapp", null, null, null));
     fileList.addAll(FileUtil.findXmlFiles(rootFolder + "widget", null, null, null));
   }
   for (File file : fileList) {
     String inFile = FileUtil.readString("UTF-8", file);
     if (inFile.contains("</forms>")) {
       getLabelsFromFormWidgets(inFile, file);
       findLabelKeyInElement(inFile, file.getPath(), "set");
       continue;
     }
     if (inFile.contains("</screens>")
         || inFile.contains("</menus>")
         || inFile.contains("</trees>")) {
       findUiLabelMapInFile(inFile, file.getPath());
       findLabelKeyInElement(inFile, file.getPath(), "set");
       continue;
     }
   }
   // get labels from Ofbiz components files
   getLabelsFromOfbizComponents();
   return references;
 }
 private void getLabelsFromOfbizComponents()
     throws IOException, SAXException, ParserConfigurationException {
   List<File> componentsFiles =
       FileUtil.findXmlFiles(
           null, null, "ofbiz-component", "http://ofbiz.apache.org/dtds/ofbiz-component.xsd");
   for (File componentFile : componentsFiles) {
     String filePath = componentFile.getPath();
     Document menuDocument = UtilXml.readXmlDocument(componentFile.toURI().toURL());
     Element rootElem = menuDocument.getDocumentElement();
     for (Element elem1 : UtilXml.childElementList(rootElem)) {
       checkOfbizComponentTag(elem1, filePath);
       for (Element elem2 : UtilXml.childElementList(elem1)) {
         checkOfbizComponentTag(elem2, filePath);
       }
     }
   }
 }