Author: tchemit Date: 2009-05-11 05:08:16 +0000 (Mon, 11 May 2009) New Revision: 315 Modified: jrst/trunk/changelog.txt jrst/trunk/src/main/java/org/codelutin/jrst/AdvancedReader.java jrst/trunk/src/main/java/org/codelutin/jrst/JRSTDirective.java jrst/trunk/src/main/java/org/codelutin/jrst/JRSTGenerator.java jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java Log: * fix some javadoc, reformat code, remove redundant cast,... Modified: jrst/trunk/changelog.txt =================================================================== --- jrst/trunk/changelog.txt 2009-05-11 04:44:26 UTC (rev 314) +++ jrst/trunk/changelog.txt 2009-05-11 05:08:16 UTC (rev 315) @@ -5,6 +5,7 @@ * bump versions (lutinproject, lutinutil, maven-i18n-plugin, maven-license-switcher-plugin) * use doxia-modules-jrst instead of maven-jrst-plugin * improve download section on site + * fix some javadoc, reformat code, remove redundant cast,... ver-0.8.5 chemit 20090409 Modified: jrst/trunk/src/main/java/org/codelutin/jrst/AdvancedReader.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/AdvancedReader.java 2009-05-11 04:44:26 UTC (rev 314) +++ jrst/trunk/src/main/java/org/codelutin/jrst/AdvancedReader.java 2009-05-11 05:08:16 UTC (rev 315) @@ -87,6 +87,7 @@ /** * + * @param in the io reader */ public AdvancedReader(Reader in) { this.in = new LineNumberReader(in); @@ -147,7 +148,7 @@ /** * ensure that have number char available and not allready read * - * @param number + * @param number ? * @throws IOException */ private void fill(int number) throws IOException { @@ -232,8 +233,8 @@ /** * read one char in buffer * - * @return - * @throws IOException + * @return the next car + * @throws IOException pour tout pb de lecture */ public int read() throws IOException { fill(1); @@ -252,7 +253,7 @@ * read one line * * @return one line without '\n' or null if end of file - * @throws IOException + * @throws IOException pour tout pb de lecture */ public String readLine() throws IOException { StringBuffer result = new StringBuffer(READ_AHEAD); @@ -280,8 +281,8 @@ /** * lit toutes les lignes du fichier * - * @return - * @throws IOException + * @return toutes les lignes du fichier + * @throws IOException pour tout pb de lecture */ String[] readAll() throws IOException { String[] result = readLines(-1); @@ -289,12 +290,12 @@ } /** - * lit un certain nombre de ligne + * lit un certain nombre de lignes * * @param count * si negatif lit toutes les lignes - * @return - * @throws IOException + * @return un certain nombre de lignes + * @throws IOException pour tout pb de lecture */ public String[] readLines(int count) throws IOException { ArrayList<String> result = new ArrayList<String>(); @@ -312,8 +313,8 @@ /** * lit les lignes jusqu'a la premiere ligne blanche (non retournée) * - * @return - * @throws IOException + * @return toutes les ligne jusqu'à la première ligne blanche (non incluse) + * @throws IOException pour tout pb de lecture */ public String[] readUntilBlank() throws IOException { String[] result = readUntil("\\s*"); @@ -324,9 +325,10 @@ * lit les lignes jusqu'a la ligne qui correspond pas au pattern, cette * ligne n'est pas mise dans le resultat retourne * - * @param pattern - * @return - * @throws IOException + * @param pattern ? + * @return les lignes jusqu'a la ligne qui correspond pas au pattern, cette + * ligne n'est pas mise dans le resultat retourne + * @throws IOException pour tout pb de lecture */ public String[] readUntil(String pattern) throws IOException { ArrayList<String> result = new ArrayList<String>(); @@ -344,9 +346,9 @@ /** * lit les lignes tant que les lignes correspondent au pattern * - * @param pattern - * @return - * @throws IOException + * @param pattern ? + * @return les lignes tant que les lignes correspondent au pattern + * @throws IOException pour tout pb de lecture */ public String[] readWhile(String pattern) throws IOException { ArrayList<String> result = new ArrayList<String>(); Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTDirective.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/JRSTDirective.java 2009-05-11 04:44:26 UTC (rev 314) +++ jrst/trunk/src/main/java/org/codelutin/jrst/JRSTDirective.java 2009-05-11 05:08:16 UTC (rev 315) @@ -36,8 +36,8 @@ /** * parse directive block element and return element to put in final XML * - * @param e - * @return + * @param e the element to scan + * @return the parsed node */ public Node parse(Element e); } Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTGenerator.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/JRSTGenerator.java 2009-05-11 04:44:26 UTC (rev 314) +++ jrst/trunk/src/main/java/org/codelutin/jrst/JRSTGenerator.java 2009-05-11 05:08:16 UTC (rev 315) @@ -188,7 +188,8 @@ * * @param doc * @param stylesheet - * @return + * @param args + * @return the transformed document * @throws TransformerException * @throws IOException */ @@ -249,6 +250,7 @@ path); } + @Override public Source resolve(String href, String base) throws TransformerException { try { @@ -281,6 +283,7 @@ /* * @see org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String) */ + @Override public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { log.debug("## resolveEntity publicId '" + publicId @@ -326,7 +329,7 @@ * <emphasis<>toto</emphasis<> qui donne *toto* retournera 6 * * @param e - * @return + * @return la longueur du text dans l'element. */ @SuppressWarnings("unchecked") protected int inlineLength(Element e) { @@ -359,6 +362,7 @@ * * @see org.codelutin.jrst.DocumentHandler#startDocument(org.dom4j.Document) */ + @Override public void startDocument(Document doc) { } @@ -367,6 +371,7 @@ * * @see org.codelutin.jrst.DocumentHandler#endDocument(org.dom4j.Document) */ + @Override public void endDocument(Document doc) { } @@ -375,6 +380,7 @@ * * @see org.codelutin.jrst.DocumentHandler#endElement(org.dom4j.Element) */ + @Override public void endElement(Element e) { boolean needNewLine = false; @@ -478,6 +484,7 @@ * * @see org.codelutin.jrst.DocumentHandler#startElement(org.dom4j.Element) */ + @Override public void startElement(Element e) { if (SECTION.equals(e.getName())) { sectionLevel++; @@ -576,6 +583,7 @@ * * @see org.codelutin.jrst.DocumentHandler#text(org.dom4j.Text) */ + @Override public void text(Text t) { if (LITERAL_BLOCK.equals(t.getParent().getName())) { writeIndent(t.getText()); Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java 2009-05-11 04:44:26 UTC (rev 314) +++ jrst/trunk/src/main/java/org/codelutin/jrst/JRSTLexer.java 2009-05-11 05:08:16 UTC (rev 315) @@ -589,8 +589,9 @@ result.addAttribute("option", "literal"); line = in.readLine(); result.setText(line.trim()); - } else + } else { result.setText(option); + } } } @@ -670,8 +671,9 @@ line = line.substring(option_string.length() + option_argument.length() + 3, line .length()); - } else + } else { done = true; + } } else { // Si la description n'est pas sur la meme // ligne option_argument = option_stringTmp; @@ -683,10 +685,9 @@ } } } - if (done) - result.setText(option_stringTmp.substring( - matcher.end(), option_stringTmp.length()) - .trim()); + if (done) { + result.setText(option_stringTmp.substring(matcher.end(), option_stringTmp.length()).trim()); + } } while (delimiter == ','); } } @@ -718,15 +719,17 @@ String title = line.substring(matcher.end(), line.length()); result.addAttribute(TITLE, title); line = in.readLine(); - if (line.matches("\\s*")) + if (line.matches("\\s*")) { line = in.readLine(); + } int level = level(line); String[] lines = null; if (level != 0) { lines = in.readWhile("(^ {" + level + "}.*)|(\\s*)"); String txt = line; - for (String txtTmp : lines) + for (String txtTmp : lines) { txt += "\n" + txtTmp.trim(); + } result.setText(txt); } @@ -770,8 +773,9 @@ result.addAttribute("subExiste", "true"); result.addAttribute("subtitle", subTitle); line = in.readLine(); - } else + } else { result.addAttribute("subExiste", "false"); + } String txt = joinBlock(readBlock(level(line))); result.setText(txt); @@ -806,21 +810,25 @@ String[] linesTmp = readBlock(0); String[] lines = new String[linesTmp.length + 1]; lines[0] = line; - for (int i = 0; i < linesTmp.length; i++) + for (int i = 0; i < linesTmp.length; i++) { lines[i + 1] = linesTmp[i]; + } int[] levelsTmp = new int[lines.length]; int levelmin = 999; result = DocumentHelper.createElement(LINE_BLOCK).addAttribute( "level", 0 + ""); - for (int i = 0; i < levelsTmp.length; i++) + for (int i = 0; i < levelsTmp.length; i++) { // on enleve | lines[i] = lines[i].replaceAll("\\|\\s?", ""); - for (int i = 0; i < levelsTmp.length; i++) + } + for (int i = 0; i < levelsTmp.length; i++) { // determination des levels levelsTmp[i] = level(lines[i]); - for (int i : levelsTmp) + } + for (int i : levelsTmp) { // level minimal levelmin = Math.min(levelmin, i); + } int cnt = 0; String lineAv = ""; int[] levels = new int[levelsTmp.length]; @@ -840,23 +848,29 @@ int levelAp = levelsTmp[cnt + 1] - levelmin; if (levelAp < level - && levelAv < levelAp) + && levelAv < levelAp) { levels[cnt]++; + } } } else { levels[cnt] = levels[cnt - 1] - 1; } - } else + } else { levels[cnt] = 1; - } else + } + } else { levels[cnt] = 1; - } else + } + } else { levels[cnt] = 0; + } } else { - if (cnt != 0) + if (cnt != 0) { levels[cnt] = levels[cnt - 1]; - else + } + else { levels[cnt] = 0; + } } cnt++; lineAv = l; @@ -934,13 +948,15 @@ blockQuote = l; blockQuote = blockQuote.replaceAll("--", "") .trim(); - } else + } else { txt += "\n" + l; + } } result = DocumentHelper.createElement(BLOCK_QUOTE) .addAttribute("level", String.valueOf(level)); - if (blockQuote != null) + if (blockQuote != null) { result.addAttribute(ATTRIBUTION, blockQuote); + } result.setText(txt); } } @@ -1201,10 +1217,12 @@ String[] lines = in.readWhile("(^ {" + level + "}.*|\\s*)"); while (lines.length > 0) { for (String line : lines) { - if (!line.matches("\\s*")) + if (!line.matches("\\s*")) { para += line.substring(level) + "\n"; - else + } + else { para += "\n"; + } } lines = in.readWhile("(^ {" + level + "}.*|\\s*)"); } @@ -1251,11 +1269,13 @@ */ String text = line.substring(line.indexOf(":", 1) + 1).trim(); String[] textTmp = in.readWhile("^\\s+.*"); - if (textTmp.length != 0) + if (textTmp.length != 0) { in.mark(); + } - for (String txt : textTmp) + for (String txt : textTmp) { text += "\n" + txt.trim(); + } // CVS, RCS support text = text.replaceAll("\\$\\w+: (.+?)\\$", "$1"); @@ -1518,12 +1538,14 @@ int tableWidth = line.length(); int nbSeparations = 0; for (String l : table) { - if (l.length() > tableWidth) + if (l.length() > tableWidth) { tableWidth = l.length(); // Determination de la + } // Determination de la // longueur max matcher = pBordersEquals.matcher(l); - if (matcher.matches()) + if (matcher.matches()) { nbSeparations++; + } } // Header if the table contains 3 equals separations @@ -1535,7 +1557,7 @@ .valueOf(tableWidth + 1)); Element row = DocumentHelper.createElement(ROW); // Determination of the columns positions - List columns = new LinkedList(); + List<Integer> columns = new LinkedList<Integer>(); matcher = Pattern.compile("=+\\s+").matcher(line); for (int cellNumber = 0; matcher.find(); cellNumber++) { columns.add(matcher.end()); @@ -1560,13 +1582,13 @@ */ String lineRef = line.replace('=', '-'); Matcher matcher2; - List tableTmp = new LinkedList(); + List<String> tableTmp = new LinkedList<String>(); for (int i = 0; i < table.length - 1; i++) { tableTmp.add(table[i]); if (!table[i].equals("")) { if (!table[i + 1] - .substring(0, (Integer) columns.get(0)) + .substring(0, columns.get(0)) .matches("\\s*")) { matcher = pBorders.matcher(table[i]); matcher2 = pBorders.matcher(table[i + 1]); @@ -1579,11 +1601,12 @@ } tableTmp.add(table[table.length - 1]); table = new String[tableTmp.size()]; - for (int i = 0; i < tableTmp.size(); i++) - table[i] = (String) tableTmp.get(i); + for (int i = 0; i < tableTmp.size(); i++) { + table[i] = tableTmp.get(i); + } boolean done = false; - LinkedList lastLines = new LinkedList(); + LinkedList<String> lastLines = new LinkedList<String>(); int separation = 1; for (String l : table) { if (l != null) { @@ -1595,7 +1618,7 @@ while (!lastLines.isEmpty()) { matcher = Pattern.compile("[-=]+\\s*").matcher( l); - String tmpLine = (String) lastLines.getLast(); + String tmpLine = lastLines.getLast(); lastLines.removeLast(); int cellNumber; for (cellNumber = 0; matcher.find(); cellNumber++) { @@ -1613,16 +1636,12 @@ + "\n"); } else { if (matcher.end() < tmpLine - .length()) - cell.setText(tmpLine.substring( - matcher.start(), - matcher.end()) - + "\n"); - else - cell.setText(tmpLine.substring( - matcher.start(), - tmpLine.length()) - + "\n"); + .length()) { + cell.setText(tmpLine.substring(matcher.start(), matcher.end()) + "\n"); + } + else { + cell.setText(tmpLine.substring(matcher.start(), tmpLine.length()) + "\n"); + } } } @@ -1635,25 +1654,21 @@ } cell.addAttribute(CELL_INDEX_START, String .valueOf(matcher.start() + 1)); - if (line.length() == matcher.end()) - cell - .addAttribute( - CELL_INDEX_END, - String - .valueOf(columns - .get(columns - .size() - 1))); - else - cell.addAttribute(CELL_INDEX_END, - String.valueOf(matcher.end())); + if (line.length() == matcher.end()) { + cell.addAttribute(CELL_INDEX_END, String.valueOf(columns.get(columns.size() - 1))); + } + else { + cell.addAttribute(CELL_INDEX_END, String.valueOf(matcher.end())); + } } if (matcher2.matches()) { separation++; row.addAttribute(ROW_END_HEADER, "" + (separation == 2)); - } else + } else { row.addAttribute(ROW_END_HEADER, "false"); + } result.add(row); row = DocumentHelper.createElement(ROW); @@ -2034,9 +2049,9 @@ } result.getLast().addAttribute("refuri", line.trim()); - } else - result.getLast().addAttribute("refuri", - line.substring(i + 2, line.length())); + } else { + result.getLast().addAttribute("refuri", line.substring(i + 2, line.length())); + } done = true; } @@ -2164,8 +2179,9 @@ .readWhile("(^ {" + level + "}.*)|(\\s*)"); text += "\n" + line.trim(); - for (String l : lines) + for (String l : lines) { text += "\n" + l.trim(); + } } else if (line.matches("\\s*")) { level = levelAv + 1; @@ -2173,8 +2189,9 @@ .readWhile("(^ {" + level + "}.*)|(\\s*)"); text += "\n" + line.trim(); - for (String l : lines) + for (String l : lines) { text += "\n" + l.trim(); + } } } @@ -2190,8 +2207,9 @@ } } - if (line == null) + if (line == null) { line = ""; + } footnote.setText(text); done = true; } @@ -2233,7 +2251,7 @@ * rapport aux positions dans le fichier. Util pour afficher a l'utilisateur * les lignes qui ont produit une erreur * - * @return + * @return les lignes non vides * @throws IOException */ public String readNotBlanckLine() throws IOException { Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java 2009-05-11 04:44:26 UTC (rev 314) +++ jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java 2009-05-11 05:08:16 UTC (rev 315) @@ -417,6 +417,7 @@ } /** + * @param name * @return the defaultDirectives */ public JRSTDirective getDirective(String name) { @@ -436,7 +437,7 @@ * l'article a partir de ces elements. * * @param reader - * @return + * @return le document cree * @throws Exception */ public Document read(Reader reader) throws Exception { @@ -1097,7 +1098,7 @@ int labelMax = 0; for (int i = 0; i < lblFootnotes.size(); i++) { - int lbl = (Integer) lblFootnotes.get(i); + int lbl = lblFootnotes.get(i); labelMax = Math.max(lbl, labelMax); } @@ -1106,7 +1107,7 @@ labels[i] = false; } for (int i = 0; i < lblFootnotes.size(); i++) { - labels[(Integer) lblFootnotes.get(i) - 1] = true; + labels[lblFootnotes.get(i) - 1] = true; } idMax++; String name = null; @@ -1181,7 +1182,7 @@ if (result[i].attributeValue("id").equals("")) { idMax++; result[i].addAttribute("id", "id" + idMax); - ((Element) eFootnotes.get(i)).addAttribute("id", "id" + idMax); + (eFootnotes.get(i)).addAttribute("id", "id" + idMax); } } @@ -1310,8 +1311,9 @@ } cnt = 0; boolean[] lineDone = new boolean[lines.size()]; - for (int i = 0; i < lineDone.length; i++) + for (int i = 0; i < lineDone.length; i++) { lineDone[i] = false; + } for (Element l : lines) { if (levels[cnt] == 0) { result.addElement(LINE).addAttribute("inline", "true").setText( @@ -1666,8 +1668,9 @@ Element result = DocumentHelper.createElement(ENUMERATED_LIST); copyLevel(item, result); String enumType = item.attributeValue("enumtype"); - if (!enumType.equals("arabic")) + if (!enumType.equals("arabic")) { result.addAttribute("start", item.attributeValue("start")); + } result.addAttribute("prefix", item.attributeValue("prefix")); result.addAttribute("suffix", item.attributeValue("suffix")); result.addAttribute("enumtype", enumType); @@ -2088,7 +2091,7 @@ symbolMaxRef++; footnote.addAttribute("auto", "*"); for (int j = 0; j < eFootnotes.size(); j++) { - Element eFootnote = (Element) eFootnotes.get(j); + Element eFootnote = eFootnotes.get(j); if (eFootnote.attributeValue("label").equals(label)) { footnote.addAttribute("id", eFootnote @@ -2103,7 +2106,7 @@ } else if (id.matches("[1-9]+")) { for (int j = 0; j < eFootnotes.size(); j++) { - Element eFootnote = (Element) eFootnotes.get(j); + Element eFootnote = eFootnotes.get(j); if (eFootnote.attributeValue("label").equals(id)) { footnote.addAttribute("id", eFootnote .attributeValue("backrefs")); @@ -2116,15 +2119,17 @@ } else if (id.equals("#")) { int lblMax = 0; - for (int j = 0; j < lblFootnotesRef.size(); j++) - lblMax = Math.max(lblMax, (Integer) lblFootnotesRef - .get(j)); + for (int j = 0; j < lblFootnotesRef.size(); j++) { + lblMax = Math.max(lblMax, lblFootnotesRef.get(j)); + } boolean[] lbls = new boolean[lblMax]; - for (int j = 0; j < lbls.length; j++) + for (int j = 0; j < lbls.length; j++) { lbls[j] = false; - for (int j = 0; j < lblFootnotesRef.size(); j++) - lbls[(Integer) lblFootnotesRef.get(j) - 1] = true; + } + for (int j = 0; j < lblFootnotesRef.size(); j++) { + lbls[lblFootnotesRef.get(j) - 1] = true; + } boolean valide = false; do { boolean trouve = false; @@ -2141,7 +2146,7 @@ } footnote.addAttribute("auto", "1"); for (int j = 0; j < eFootnotes.size(); j++) { - Element eFootnote = (Element) eFootnotes.get(j); + Element eFootnote = eFootnotes.get(j); if (eFootnote.attributeValue("label").equals( label)) { if (!(eFootnote.attributeValue("type") @@ -2170,7 +2175,7 @@ String name = id.substring(1); boolean trouve = false; for (int j = 0; j < eFootnotes.size() && !trouve; j++) { - Element eFootnote = (Element) eFootnotes.get(j); + Element eFootnote = eFootnotes.get(j); if (eFootnote.attributeValue("name").equals(name)) { footnote.addAttribute("id", eFootnote .attributeValue("backrefs"));