public static void run(PrintStream out, String projectDir, String input) throws IOException, ParserConfigurationException, TransformerException { ToolImport tool = new ToolImport(out); if (input == null || "".equals(input)) { tool.out.println("File name is missed"); return; } HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(new File(input))); HSSFSheet sheet = wb.getSheetAt(0); tool.outResDir = new File(projectDir, "/res"); //tool.outResDir.mkdirs(); tool.parse(sheet); }
private void addContent(Document dom, Element root, String value, String nodeName, String key, String quantity) { if (!mConfig.isMixedContent(key)) { addContentAsString(dom, root, value, nodeName, key, quantity); return; root.appendChild(tmp); } catch (Exception e) { addContentAsString(dom, root, value, nodeName, key, quantity);
private void parse(HSSFSheet sheet) throws IOException, TransformerException { Row row = sheet.getRow(0); Iterator<Cell> cells = row.cellIterator(); cells.next();// ignore key int i = 1; while (cells.hasNext()) { String lang = cells.next().toString(); if (mMapping != null && mMapping.containsKey(lang)) { lang = mMapping.get(lang); } generateLang(sheet, lang, i); i++; } }
pluralsNode.setAttribute("name", plurarName); value = prepareOutputValue(lang, key, value); addContent(dom, pluralsNode, value, "item", null, quantity); value = prepareOutputValue(lang, key, value); addContent(dom, stringArrayNode, value, "item", null, null); addEmptyKeyValue(dom, root, key); continue; addEmptyKeyValue(dom, root, key); } else { value = prepareOutputValue(lang, key, value); addContent(dom, root, value, "string", key, null); save(dom, lang);
public static void run(ImportConfig config) throws IOException, ParserConfigurationException, TransformerException { if (config == null) { System.err.println("Cannot import, missing config"); return; } if (StringUtils.isEmpty(config.inputFile)) { System.err.println("Cannot import, missing input file name"); return; } HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(new File(config.inputFile))); HSSFSheet sheet = wb.getSheetAt(0); HSSFSheet sheetMapping = null; if (!StringUtils.isEmpty(config.mappingFile)) { HSSFWorkbook wbMapping = new HSSFWorkbook(new FileInputStream(new File(config.mappingFile))); sheetMapping = wbMapping.getSheetAt(0); } String outputDirName = config.outputDirName; if (StringUtils.isEmpty(outputDirName)) { outputDirName = sheet.getSheetName(); } if (config.outputFileName == null) { config.outputFileName = "strings.xml"; } ToolImport tool = new ToolImport(null); tool.mConfig = config; tool.outResDir = new File("out/" + outputDirName + "/res"); tool.outResDir.mkdirs(); tool.prepareMapping(sheetMapping); tool.parse(sheet); }
pluralsNode.setAttribute("name", plurarName); value = prepareOutputValue(lang, key, value); addContent(dom, pluralsNode, value, "item", null, quantity); value = prepareOutputValue(lang, key, value); addContent(dom, stringArrayNode, value, "item", null, null); addEmptyKeyValue(dom, root, key); continue; addEmptyKeyValue(dom, root, key); } else { value = prepareOutputValue(lang, key, value); addContent(dom, root, value, "string", key, null); save(dom, lang);
public static void run(ImportConfig config) throws IOException, ParserConfigurationException, TransformerException { if (config == null) { System.err.println("Cannot import, missing config"); return; } if (StringUtils.isEmpty(config.inputFile)) { System.err.println("Cannot import, missing input file name"); return; } HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(new File(config.inputFile))); HSSFSheet sheet = wb.getSheetAt(0); HSSFSheet sheetMapping = null; if (!StringUtils.isEmpty(config.mappingFile)) { HSSFWorkbook wbMapping = new HSSFWorkbook(new FileInputStream(new File(config.mappingFile))); sheetMapping = wbMapping.getSheetAt(0); } String outputDirName = config.outputDirName; if (StringUtils.isEmpty(outputDirName)) { outputDirName = sheet.getSheetName(); } if (config.outputFileName == null) { config.outputFileName = "strings.xml"; } ToolImport tool = new ToolImport(null); tool.mConfig = config; tool.outResDir = new File("out/" + outputDirName + "/res"); tool.outResDir.mkdirs(); tool.prepareMapping(sheetMapping); tool.parse(sheet); }
public static void main(String[] args) throws IOException, ParserConfigurationException, TransformerException, SAXException { if (args == null || args.length == 0) { printHelp(); return; } CommandlineArguments parsedArgs = new CommandlineArguments(); try { new JCommander(parsedArgs, args); } catch (ParameterException e) { System.err.println(e.getMessage()); printHelp(); return; } if (parsedArgs.exportProject != null) { // exporting ExportConfig config = new ExportConfig(parsedArgs); ToolExport.run(config); } else if (parsedArgs.importFile != null) { SplittingConfig config = new SplittingConfig(parsedArgs); // importing if (parsedArgs.splittingConfigFile != null) { // splitting ToolImportSplitter.run(config); } else { ToolImport.run(config); } } else { printHelp(); } }
public static void run(PrintStream out, String projectDir, String input) throws IOException, ParserConfigurationException, TransformerException { ToolImport tool = new ToolImport(out); if (input == null || "".equals(input)) { tool.out.println("File name is missed"); return; } HSSFWorkbook wb = new HSSFWorkbook(new FileInputStream(new File(input))); HSSFSheet sheet = wb.getSheetAt(0); tool.outResDir = new File(projectDir, "/res"); //tool.outResDir.mkdirs(); tool.parse(sheet); }
private void parse(HSSFSheet sheet) throws IOException, TransformerException { Row row = sheet.getRow(0); Iterator<Cell> cells = row.cellIterator(); cells.next();// ignore key int i = 1; while (cells.hasNext()) { String lang = cells.next().toString(); if (mMapping != null && mMapping.containsKey(lang)) { lang = mMapping.get(lang); } generateLang(sheet, lang, i); i++; } }
private void addContent(Document dom, Element root, String value, String nodeName, String key, String quantity) { if (!mConfig.isMixedContent(key)) { addContentAsString(dom, root, value, nodeName, key, quantity); return; root.appendChild(tmp); } catch (Exception e) { addContentAsString(dom, root, value, nodeName, key, quantity);