Author: chatellier Date: 2009-02-17 13:29:30 +0000 (Tue, 17 Feb 2009) New Revision: 266 Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java Log: Fix some checktyle Modified: jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java =================================================================== --- jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java 2009-02-11 10:24:29 UTC (rev 265) +++ jrst/trunk/src/main/java/org/codelutin/jrst/JRSTReader.java 2009-02-17 13:29:30 UTC (rev 266) @@ -274,13 +274,13 @@ public class JRSTReader { /** to use log facility, just put in your code: log.info(\"...\"); */ - static private Log log = LogFactory.getLog(JRSTReader.class); + private static Log log = LogFactory.getLog(JRSTReader.class); - boolean ERROR_MISSING_ITEM = false; + protected boolean ERROR_MISSING_ITEM = false; - static int MAX_SECTION_DEPTH = -1000; + protected static int MAX_SECTION_DEPTH = -1000; - static protected Map<String, JRSTDirective> defaultDirectives = null; + protected static Map<String, JRSTDirective> defaultDirectives = null; protected Map<String, JRSTDirective> directives = new HashMap<String, JRSTDirective>(); @@ -434,17 +434,16 @@ if (matcher.matches()) { pattern = Pattern.compile("\\p{Digit}+"); matcher = pattern.matcher(matcher.group()); - if (matcher.find()) + if (matcher.find()) { depth = Integer.parseInt(matcher.group()); + } } int levelInit = 0; try { levelInit = Integer.parseInt(eTitle.getFirst().attributeValue( "level")); } catch (NumberFormatException eee) { - log - .error( - "Can't parse level in: " + log.error("Can't parse level in: " + eTitle.getFirst().asXML(), eee); return; } @@ -460,11 +459,13 @@ int level = Integer.parseInt(el.attributeValue("level")); level = level - levelInit; el.addAttribute("level", "" + level); - if (depth == -1) + if (depth == -1) { title.add(el); + } else { - if (depth > level) + if (depth > level) { title.add(el); + } } } e.addAttribute("class", "contents"); @@ -492,8 +493,9 @@ */ private Element composeLineContent(LinkedList<Element> title, String num) { Element result = DocumentHelper.createElement(BULLET_LIST); - if (sectnum) + if (sectnum) { result.addAttribute("class", "auto-toc"); + } Element item = null; int cnt = 0; while (!title.isEmpty()) { @@ -611,8 +613,9 @@ // les eléments a enlever (deja parser : header, footer...) item = lexer.peekRemove(); - if (itemEquals("remove", item)) + if (itemEquals("remove", item)) { lexer.remove(); + } // le titre du doc item = lexer.peekTitle(); @@ -738,8 +741,9 @@ } // on ajoute le footer a la fin - if (footer != null) + if (footer != null) { result.add(footer); + } return result; } @@ -874,8 +878,9 @@ } else if (itemEquals("footnotes", item)) { lexer.remove(); Element[] list = composeFootnote(item); - for (Element l : list) + for (Element l : list) { parent.add(l); + } } else if (itemEquals(COMMENT, item)) { lexer.remove(); Element list = composeComment(item); @@ -1022,8 +1027,9 @@ } boolean[] labels = new boolean[labelMax]; - for (int i = 0; i < labels.length; i++) + for (int i = 0; i < labels.length; i++) { labels[i] = false; + } for (int i = 0; i < lblFootnotes.size(); i++) { labels[(Integer) lblFootnotes.get(i) - 1] = true; } @@ -1042,10 +1048,12 @@ efootnote.addAttribute("backrefs", "id" + idMax); if (type.equals("num") || type.equals("autoNumLabel")) { name = footnote.attributeValue("name"); - if (type.equals("autoNumLabel")) + if (type.equals("autoNumLabel")) { id = name; - else + } + else { label = name; + } } if (type.equals("autoNum") || type.equals("autoNumLabel")) { boolean done = false; @@ -1056,10 +1064,12 @@ label = "" + (i + 1); } } - if (!done) + if (!done) { label = "" + (labels.length + 1); - if (type.equals("autoNum")) + } + if (type.equals("autoNum")) { name = label; + } } if (type.equals("autoSymbol")) { @@ -1080,8 +1090,9 @@ } result[cnt].addElement("label").setText("" + label); efootnote.addAttribute("label", "" + label); - if (!type.equals("autoSymbol")) + if (!type.equals("autoSymbol")) { lblFootnotes.add(Integer.parseInt(label)); + } efootnote.addAttribute("type", type); eFootnotes.add(efootnote); String text = footnote.getText(); @@ -1187,10 +1198,11 @@ result = DocumentHelper.createElement(SIDEBAR); result.addElement(TITLE).addAttribute("inline", "true").setText( item.attributeValue(TITLE)); - if (item.attributeValue("subExiste").equals("true")) + if (item.attributeValue("subExiste").equals("true")) { result.addElement(SUBTITLE).addAttribute("inline", "true").setText( item.attributeValue(SUBTITLE)); - + } + String text = item.getText(); Document doc = newJRSTReader(new StringReader(text)); result.appendContent(doc.getRootElement()); @@ -1226,9 +1238,10 @@ for (int i = 0; i < lineDone.length; i++) lineDone[i] = false; for (Element l : lines) { - if (levels[cnt] == 0) + if (levels[cnt] == 0) { result.addElement(LINE).addAttribute("inline", "true").setText( l.getText()); + } else { if (!lineDone[cnt]) { Element newItem = DocumentHelper.createElement(LINE_BLOCK); @@ -1239,8 +1252,9 @@ eLine.addAttribute("level", "" + (levels[i] - 1)); eLine.setText(lines.get(i).getText()); lineDone[i] = true; - } else + } else { done = true; + } } Element eLineBlock = result.addElement(LINE_BLOCK); @@ -1322,10 +1336,11 @@ result.addAttribute("class", admonitionClass); result.addElement(TITLE).addAttribute("inline", "true").setText( title.trim()); - } else + } else { result = DocumentHelper.createElement(item.attributeValue("type") .toLowerCase()); - + } + String text = item.getText(); Document doc = newJRSTReader(new StringReader(text)); result.appendContent(doc.getRootElement()); @@ -1341,8 +1356,9 @@ private Node composeDirective(Element item) { Node result = item; String type = item.attributeValue(JRSTLexer.DIRECTIVE_TYPE); - if (type.equals("sectnum")) + if (type.equals("sectnum")) { sectnum = true; + } JRSTDirective directive = getDirective(type); if (directive == null) { directive = getDefaultDirective(type); @@ -2045,8 +2061,9 @@ label = "" + (j + 1); } } - if (!trouve) + if (!trouve) { label = "" + (lbls.length + 1); + } footnote.addAttribute("auto", "1"); for (int j = 0; j < eFootnotes.size(); j++) { Element eFootnote = (Element) eFootnotes.get(j); @@ -2139,8 +2156,9 @@ trouve = true; } } - if (!trouve) + if (!trouve) { hyper.addAttribute("refid", ref); + } hyper.setText(ref); text = txtDebut + hyper.asXML() + " " + txtFin; matcher = REGEX_HYPERLINK_REFERENCE.matcher(text);
participants (1)
-
chatellier@users.labs.libre-entreprise.org