[FOray-commit] SF.net SVN: foray: [7826] trunk/foray/foray-pretty/src/java/org/foray/pretty
Modular XSL-FO Implementation for Java.
Status: Alpha
Brought to you by:
victormote
|
From: <vic...@us...> - 2006-07-23 21:24:41
|
Revision: 7826 Author: victormote Date: 2006-07-23 14:24:31 -0700 (Sun, 23 Jul 2006) ViewCVS: http://svn.sourceforge.net/foray/?rev=7826&view=rev Log Message: ----------- Implement standard use of final modifier on local variable and method parameters. Modified Paths: -------------- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTD.java trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDElement.java trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDTokenizer.java trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/ElementStack.java Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-07-23 21:15:10 UTC (rev 7825) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayPretty.java 2006-07-23 21:24:31 UTC (rev 7826) @@ -135,7 +135,8 @@ /** * Constructor. */ - public FOrayPretty(InputSource input, OutputStream output, String catalog) { + public FOrayPretty(final InputSource input, final OutputStream output, + final String catalog) { this.input = input; this.output = output; this.entityResolver = getEntityResolver(catalog); @@ -152,13 +153,13 @@ */ public void start() throws IOException, SAXException, ParserConfigurationException { - XMLReader parser = createParser(); + final XMLReader parser = createParser(); /* Bind the LexicalHandler to the XMLReader if possible. */ try { parser.setProperty("http://xml.org/sax/properties/lexical-handler", this); - } catch (SAXNotSupportedException e1) { + } catch (final SAXNotSupportedException e1) { logError("Parser does not support LexicalHandler."); } @@ -166,16 +167,16 @@ try { parser.setProperty("http://xml.org/sax/properties/" + "declaration-handler", this); - } catch (SAXNotSupportedException e) { + } catch (final SAXNotSupportedException e) { logError("Parser does not support Declaration Handler."); } /* Turn on validation if it is available. */ try { parser.setFeature("http://xml.org/sax/features/validation", true); - } catch (SAXNotRecognizedException e1) { + } catch (final SAXNotRecognizedException e1) { logError("Parser does not recognize validation."); - } catch (SAXNotSupportedException e1) { + } catch (final SAXNotSupportedException e1) { logError("Parser unable to validate."); } @@ -189,12 +190,12 @@ try { parser.setFeature("http://apache.org/xml/features/scanner/" + "notify-char-refs", true); - } catch (SAXNotRecognizedException e) { + } catch (final SAXNotRecognizedException e) { /* Make this a fatal error. */ logError("Parser cannot report character entities. Aborting."); cleanup(); return; - } catch (SAXNotSupportedException e) { + } catch (final SAXNotSupportedException e) { /* Make this a fatal error. */ logError("Parser cannot report character entities. Aborting."); cleanup(); @@ -212,24 +213,24 @@ */ public XMLReader createParser() throws SAXException, ParserConfigurationException { - SAXParserFactory spf = + final SAXParserFactory spf = javax.xml.parsers.SAXParserFactory.newInstance(); spf.setNamespaceAware(true); - XMLReader xmlReader = spf.newSAXParser().getXMLReader(); + final XMLReader xmlReader = spf.newSAXParser().getXMLReader(); if (this.entityResolver != null) { xmlReader.setEntityResolver(this.entityResolver); } return xmlReader; } - public void setDocumentLocator(Locator locator) { + public void setDocumentLocator(final Locator locator) { this.locator = locator; } private void cleanup() { try { output.close(); - } catch (IOException e1) { + } catch (final IOException e1) { /* Ignore. */ } } @@ -243,8 +244,8 @@ write(newLine()); } - public void startElement(String uri, String local, String qName, - Attributes attributes) { + public void startElement(final String uri, final String local, + final String qName, final Attributes attributes) { flushCharacters(); ensureTopElementWritten(false); /* Cache the parameters in instance variable for later processing. @@ -254,12 +255,12 @@ this.lastStartedLocal = local; /* Must copy the attributes as they are reset on each callback. */ this.lastStartedAttributes = new AttributesImpl(attributes); - DTDElement element = this.dtd.getElement(local); + final DTDElement element = this.dtd.getElement(local); this.elementStack.push(element); topElementWritten = false; } - private void ensureTopElementWritten(boolean isEmpty) { + private void ensureTopElementWritten(final boolean isEmpty) { if (this.topElementWritten) { return; } @@ -268,8 +269,8 @@ this.topElementWritten = true; } - private void writeElement(String local, Attributes attributes, - boolean isEmpty) { + private void writeElement(final String local, final Attributes attributes, + final boolean isEmpty) { if (local == null) { return; } @@ -280,12 +281,12 @@ } /* Accumulate the tag opener. */ - StringBuffer tagOpenBuffer = new StringBuffer(); + final StringBuffer tagOpenBuffer = new StringBuffer(); tagOpenBuffer.append("<"); tagOpenBuffer.append(local); /* Accumulate the attributes. */ - StringBuffer attributesBuffer = new StringBuffer(); + final StringBuffer attributesBuffer = new StringBuffer(); for (int i = 0; i < attributes.getLength(); i++) { attributesBuffer.append(" "); attributesBuffer.append(attributes.getLocalName(i)); @@ -295,7 +296,7 @@ } /* Accumulate the tag closer. */ - StringBuffer tagCloseBuffer = new StringBuffer(); + final StringBuffer tagCloseBuffer = new StringBuffer(); if (isEmpty) { tagCloseBuffer.append("/>"); } else { @@ -337,7 +338,7 @@ private String indent() { int numIndents = currentIndentation() * this.indent; - StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = new StringBuffer(); while (numIndents > 0) { buffer.append(" "); numIndents --; @@ -345,7 +346,8 @@ return buffer.toString(); } - public void endElement(String uri, String local, String qName) { + public void endElement(final String uri, final String local, + final String qName) { flushCharacters(); if (this.topElementWritten) { @@ -400,7 +402,8 @@ return true; } - public void characters(char[] buffer, int offset, int length) { + public void characters(final char[] buffer, final int offset, + final int length) { if (this.inEntity) { /* Skip these characters. We are writing the unexpanded entity * elsewhere. We do not want to also write the expanded version. */ @@ -424,34 +427,37 @@ this.charBuffer.setLength(0); } - private void addToQueue(String string) { + private void addToQueue(final String string) { if (string == null) { return; } this.queue.add(string); } - public void processingInstruction(String target, String data) { + public void processingInstruction(final String target, final String data) { write(target); write(data); } - public void ignorableWhitespace(char[] buffer, int offset, int length) { + public void ignorableWhitespace(final char[] buffer, final int offset, + final int length) { /* Ignorable white space is just ignored. */ // this.charBuffer.append(buffer, offset, length); } - public void comment(char[] buffer, int offset, int length) { + public void comment(final char[] buffer, final int offset, + final int length) { if (this.inDTD) { return; } write("<!--"); - String comment = new String(buffer, offset, length); + final String comment = new String(buffer, offset, length); writeRawPCDATA(comment); write("-->"); } - public void startDTD(String name, String publicId, String systemId) { + public void startDTD(final String name, final String publicId, + final String systemId) { write(newLine()); write("<!DOCTYPE "); write(name); @@ -473,7 +479,7 @@ this.inDTD = false; } - public void startEntity(String name) { + public void startEntity(final String name) { if (this.inDTD) { return; } @@ -484,12 +490,12 @@ this.inEntity = true; } - public void endEntity(String name) { + public void endEntity(final String name) { this.inEntity = false; } - public void elementDecl(String name, String model) { - DTDElement dtdElement = new DTDElement(name, model); + public void elementDecl(final String name, final String model) { + final DTDElement dtdElement = new DTDElement(name, model); this.dtd.addElement(dtdElement); } @@ -501,20 +507,20 @@ * as that may result in the conversion of \r\n to \r\r\n, for example. * @param outputString The String that should be written. */ - private void writeRawPCDATA(String outputString) { + private void writeRawPCDATA(final String outputString) { if (this.lineTerminator.equals("\n")) { /* The specified line terminator is the same as that used in the * input. Just write it. */ write(outputString); return; } - int lastLineBreakIndex = outputString.lastIndexOf("\n"); + final int lastLineBreakIndex = outputString.lastIndexOf("\n"); if (lastLineBreakIndex < 0) { /* No line breaks in what is being written. Just write it. */ write(outputString); return; } - StringBuffer buffer = new StringBuffer(outputString); + final StringBuffer buffer = new StringBuffer(outputString); int bufferIndex = 0; while (bufferIndex < buffer.length()) { if (buffer.charAt(bufferIndex) == '\n') { @@ -528,7 +534,7 @@ write (buffer.toString()); } - private void write(String outputString) { + private void write(final String outputString) { if (outputString == null) { return; } @@ -539,10 +545,11 @@ output.write(outputString.getBytes(this.outputEncoding)); /* Following line for debugging only */ output.flush(); - } catch (IOException e) { + } catch (final IOException e) { logError("Error converting text."); } - int lastLineBreakIndex = outputString.lastIndexOf(this.lineTerminator); + final int lastLineBreakIndex = outputString.lastIndexOf( + this.lineTerminator); if (lastLineBreakIndex < 0) { /* No line breaks in what is being written. Increment the current * column by the length of outputString. Note that we want the @@ -554,18 +561,18 @@ } } - public EntityResolver getEntityResolver(String catalog) { + public EntityResolver getEntityResolver(final String catalog) { if (catalog == null) { return null; } - String [] catalogs = {catalog}; - XMLCatalogResolver resolver = new XMLCatalogResolver(); + final String [] catalogs = {catalog}; + final XMLCatalogResolver resolver = new XMLCatalogResolver(); resolver.setPreferPublic(true); resolver.setCatalogList(catalogs); return resolver; } - private void logError(String message) { + private void logError(final String message) { if (this.locator != null) { System.out.print(locator.getSystemId() + ":" + locator.getLineNumber() + ":" @@ -625,7 +632,7 @@ if (this.breaksChosen.size() < 1) { sizeIfAccepted += lastColumnWritten; } - int firstChunkToConsider = this.getLastBreakChosen(); + final int firstChunkToConsider = this.getLastBreakChosen(); sizeIfAccepted += this.chunkSize(firstChunkToConsider, i); if (sizeIfAccepted > desiredLineLength) { int breakSelected = i - 1; @@ -656,7 +663,7 @@ private void writeAll() { while (this.toWriteQueue.size() > 0) { - String returnItem = (String) this.toWriteQueue.get(0); + final String returnItem = (String) this.toWriteQueue.get(0); writeRawPCDATA(returnItem); this.toWriteQueue.remove(0); } @@ -674,11 +681,11 @@ return toWriteQueue.size(); } - protected void add (String itemToAdd) { + protected void add (final String itemToAdd) { this.toWriteQueue.add(itemToAdd); } - protected String get(int index) { + protected String get(final int index) { if (index > this.toWriteQueue.size()) { return null; } @@ -688,7 +695,7 @@ private int charCount() { int charCount = 0; for (int i = 0; i < this.toWriteQueue.size(); i++) { - String string = get(i); + final String string = get(i); charCount += string.length(); } return charCount; @@ -710,19 +717,19 @@ this.writeChunk(Integer.MAX_VALUE, false); } - private int getBreakChosen(int index) { + private int getBreakChosen(final int index) { if (this.breaksChosen == null || index < 0 || index >= this.breaksChosen.size()) { return -1; } - Object object = this.breaksChosen.get(index); - Integer integer = (Integer) object; + final Object object = this.breaksChosen.get(index); + final Integer integer = (Integer) object; return integer.intValue(); } private int getLastBreakChosen() { - int lastIndex = this.breaksChosen.size() - 1; + final int lastIndex = this.breaksChosen.size() - 1; return getBreakChosen(lastIndex); } @@ -735,9 +742,9 @@ } count = 0; for (int i = 0; i < this.toWriteQueue.size(); i++) { - String string = this.get(i); + final String string = this.get(i); for (int j = 0; j < string.length(); j++) { - char c = string.charAt(j); + final char c = string.charAt(j); if (c == ' ') { this.breakOpportunityItems[count] = i; this.breakOpportunityIndexes[count] = j; @@ -748,7 +755,8 @@ count = this.breakOpportunityItems.length; } - private int chunkSize(int startOpportunity, int endOpportunity) { + private int chunkSize(final int startOpportunity, + final int endOpportunity) { if (startOpportunity == endOpportunity) { return 0; } @@ -763,10 +771,10 @@ startItem = this.breakOpportunityItems[startOpportunity]; startItemIndex = this.breakOpportunityIndexes[startOpportunity]; } - int lastOpportunity = this.breakOpportunityItems.length - 1; + final int lastOpportunity = this.breakOpportunityItems.length - 1; if (endOpportunity > lastOpportunity) { endItem = this.toWriteQueue.size() - 1; - String string = this.get(endItem); + final String string = this.get(endItem); endItemIndex = string.length(); } else { endItem = this.breakOpportunityItems[endOpportunity]; @@ -782,7 +790,7 @@ if (i == endItem) { endIndex = endItemIndex - 1; } else { - String item = this.get(i); + final String item = this.get(i); endIndex = item.length() - 1; } size += endIndex - startIndex; @@ -798,9 +806,9 @@ private int countBreakOpportunities() { int count = 0; for (int i = 0; i < this.toWriteQueue.size(); i++) { - String string = this.get(i); + final String string = this.get(i); for (int j = 0; j < string.length(); j++) { - char c = string.charAt(j); + final char c = string.charAt(j); if (c == ' ') { count ++; } @@ -815,7 +823,8 @@ * @param newLine Set to true if a new-line should be written after * the text of the line. */ - private void writeChunk(int breakSelected, boolean newLine) { + private void writeChunk(final int breakSelected, + final boolean newLine) { int startOpportunity; int endOpportunity; if (breakSelected == 0) { @@ -841,7 +850,7 @@ startItemIndex = this.breakOpportunityIndexes[startOpportunity]; } if (endOpportunity >= this.breakOpportunityIndexes.length) { - int lastItem = this.toWriteQueue.size() - 1; + final int lastItem = this.toWriteQueue.size() - 1; endItem = lastItem; endItemIndex = this.getLastItem().length() - 1; } else { @@ -849,7 +858,7 @@ endItemIndex = this.breakOpportunityIndexes[endOpportunity]; } for (int i = startItem; i <= endItem; i++) { - String string = this.get(i); + final String string = this.get(i); int startIndex = 0; if (i == startItem) { startIndex = startItemIndex; @@ -878,7 +887,7 @@ if (this.toWriteQueue.size() < 1) { return null; } - int lastIndex = this.toWriteQueue.size() - 1; + final int lastIndex = this.toWriteQueue.size() - 1; return (String) this.toWriteQueue.get(lastIndex); } @@ -892,15 +901,15 @@ * Argument 3 is an optional location of an OASIS-compliant catalog file * that can be used to locate local DTDs. */ - public static void main(String[] args) { + public static void main(final String[] args) { if (args == null || args.length < 2 || args.length > 3) { System.out.print("Wrong number of arguments."); System.exit(1); } - String input = args[0]; - String output = args[1]; + final String input = args[0]; + final String output = args[1]; String catalog = null; if (args.length > 2) { catalog = args[2]; @@ -910,24 +919,24 @@ FileInputStream fis = null; fis = new FileInputStream(input); inputStream = new BufferedInputStream(fis); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { System.err.println("File not found: " + input); System.exit(2); } - InputSource inputSource = new InputSource(inputStream); + final InputSource inputSource = new InputSource(inputStream); OutputStream outputStream = null; try { - FileOutputStream fos = new FileOutputStream(output); + final FileOutputStream fos = new FileOutputStream(output); outputStream = new BufferedOutputStream(fos); - } catch (FileNotFoundException e1) { + } catch (final FileNotFoundException e1) { System.err.println("File not found: " + output); System.exit(3); } - FOrayPretty processor = new FOrayPretty(inputSource, outputStream, + final FOrayPretty processor = new FOrayPretty(inputSource, outputStream, catalog); try { processor.start(); - } catch (Exception e) { + } catch (final Exception e) { System.out.print("Error parsing input."); e.printStackTrace(); System.exit(4); @@ -940,7 +949,7 @@ * normalized to spaces, duplicate spaces will be removed, and spaces and * new-lines will be treated as interchangeable. The default value is true. */ - public void setBreakPCDATA(boolean breakPCDATA) { + public void setBreakPCDATA(final boolean breakPCDATA) { this.breakPCDATA = breakPCDATA; } @@ -949,7 +958,7 @@ * at the beginning of the pretty-printed document. The default value is * <code><?xml version="1.0" encoding="UTF-8"?></code> */ - public void setXmlDeclaration(String xmlDeclaration) { + public void setXmlDeclaration(final String xmlDeclaration) { this.xmlDeclaration = xmlDeclaration; } @@ -959,7 +968,7 @@ * platform-specific. On Unix, for example, it is "\n". On Windows, it is * "\r\n". */ - public void setLineTerminator(String lineTerminator) { + public void setLineTerminator(final String lineTerminator) { this.lineTerminator = lineTerminator; } @@ -967,7 +976,7 @@ * Use this configuration parameter to set the output encoding for the * pretty-printed document. The default value is "UTF-8". */ - public void setOutputEncoding(String outputEncoding) { + public void setOutputEncoding(final String outputEncoding) { this.outputEncoding = outputEncoding; } @@ -978,7 +987,7 @@ * considered to be insignificant and is therefore stripped out. * The default value is null. */ - public void setPreRootText(String preRootText) { + public void setPreRootText(final String preRootText) { this.preRootText = preRootText; } @@ -989,7 +998,7 @@ * be insignificant and is therefore stripped out. * The default value is "\n" (one line-feed). */ - public void setPostRootText(String postRootText) { + public void setPostRootText(final String postRootText) { this.postRootText = postRootText; } @@ -998,7 +1007,7 @@ * successive block level of the document should be indented. The default * is 2. */ - public void setIndent(int indent) { + public void setIndent(final int indent) { this.indent = indent; } @@ -1006,7 +1015,7 @@ * Use this configuration parameter to set the desired maximum line length, * in characters, for the pretty-printed document. The default is 80. */ - public void setDesiredLineLength(int desiredLineLength) { + public void setDesiredLineLength(final int desiredLineLength) { this.desiredLineLength = desiredLineLength; } @@ -1014,7 +1023,7 @@ * Set this configuration parameter to true if blocks that are inside of * mixed content should be indented. The default is "false". */ - public void setIndentBlocksInsideMixedContent(boolean indent) { + public void setIndentBlocksInsideMixedContent(final boolean indent) { this.indentBlocksInsideMixedContent = indent; } Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-07-23 21:15:10 UTC (rev 7825) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/FOrayXDiff.java 2006-07-23 21:24:31 UTC (rev 7826) @@ -69,16 +69,16 @@ * @see #FOrayXDiff(InputStream[]) For a constructor that takes any * {@link InputStream}. */ - public FOrayXDiff(URL[] urls) throws Exception { + public FOrayXDiff(final URL[] urls) throws Exception { if (urls == null) { throw new Exception("No URLs to compare."); } - InputStream[] streams = new InputStream[urls.length]; + final InputStream[] streams = new InputStream[urls.length]; if (readerIDs == null) { readerIDs = new String[urls.length]; } for (int i = 0; i < urls.length; i++) { - InputStream in = urls[i].openStream(); + final InputStream in = urls[i].openStream(); streams[i] = in; this.readerIDs[i] = urls[i].toExternalForm(); } @@ -88,14 +88,14 @@ /** * Constructor accepting InputStreams to compare. */ - public FOrayXDiff(InputStream[] streams) throws Exception { + public FOrayXDiff(final InputStream[] streams) throws Exception { if (readerIDs == null) { readerIDs = new String[streams.length]; } convertStreams(streams); } - private void convertStreams(InputStream[] streams) + private void convertStreams(final InputStream[] streams) throws IllegalArgumentException, XMLStreamException { if (streams == null) { throw new IllegalArgumentException("No InputStreams to compare."); @@ -105,13 +105,13 @@ + "needed for comparison."); } this.readers = new XMLStreamReader[streams.length]; - XMLInputFactory factory = XMLInputFactory.newInstance(); + final XMLInputFactory factory = XMLInputFactory.newInstance(); /* Make parsers coalesce adjacent character data. */ factory.setProperty("javax.xml.stream.isCoalescing", Boolean.TRUE); factory.setProperty("javax.xml.stream.isReplacingEntityReferences", Boolean.FALSE); for (int i = 0; i < streams.length; i++) { - InputStream in = streams[i]; + final InputStream in = streams[i]; this.readers[i] = factory.createXMLStreamReader(in); if (this.readerIDs[i] == null) { /* If this stream was created from a URL, this should already @@ -132,7 +132,7 @@ */ public boolean equivalent() throws IOException, XMLStreamException { while (true) { - int event = readEvents(); + final int event = readEvents(); switch (event) { case XMLStreamConstants.START_DOCUMENT: { /* Nothing to do here. */ @@ -232,11 +232,11 @@ * @throws XMLStreamException */ private int readEvents() throws XMLStreamException { - int[] events = new int[this.readers.length]; + final int[] events = new int[this.readers.length]; for (int i = 0; i < this.readers.length; i++) { events[i] = readEvent(i); } - int baseEventValue = events[0]; + final int baseEventValue = events[0]; for (int i = 1; i < events.length; i++) { if (events[i] != baseEventValue) { message("Difference in Events\n" @@ -250,7 +250,7 @@ return baseEventValue; } - public static String getEventDescription(int event) { + public static String getEventDescription(final int event) { switch (event) { case XMLStreamConstants.START_DOCUMENT: { return "Start Document"; @@ -309,8 +309,8 @@ * @param i * @throws XMLStreamException */ - private int readEvent(int i) throws XMLStreamException { - XMLStreamReader reader = this.readers[i]; + private int readEvent(final int i) throws XMLStreamException { + final XMLStreamReader reader = this.readers[i]; if (! reader.hasNext()) { return XMLStreamReader.END_DOCUMENT; } @@ -335,18 +335,18 @@ return event; } - private void message(String message) { + private void message(final String message) { System.out.println(message); for (int i = 0; i < this.readers.length; i++) { - String sourceDescription = getSourceDescription(i); - String sourceLocation = getSourceLocation(i); + final String sourceDescription = getSourceDescription(i); + final String sourceLocation = getSourceLocation(i); System.out.println(" Document " + (i + 1) + ": " + sourceDescription + ":" + sourceLocation); } } - private String getSourceDescription(int inputIndex) { - Location location = this.readers[inputIndex].getLocation(); + private String getSourceDescription(final int inputIndex) { + final Location location = this.readers[inputIndex].getLocation(); if (location != null && location.getSystemId() != null) { return location.getSystemId(); @@ -358,8 +358,8 @@ return this.readerIDs[inputIndex]; } - private String getSourceLocation(int inputIndex) { - Location location = this.readers[inputIndex].getLocation(); + private String getSourceLocation(final int inputIndex) { + final Location location = this.readers[inputIndex].getLocation(); if (location == null) { return "Unknown"; } @@ -410,7 +410,7 @@ for (int i = 1; i < this.readers.length; i++) { String compareString = this.readers[i].getText(); compareString = XMLUtil.normalizeWhitespace(compareString); - int differIndex = StringUtil.firstDifferent(baseString, + final int differIndex = StringUtil.firstDifferent(baseString, compareString); if (differIndex < 0) { return true; @@ -430,18 +430,19 @@ */ private boolean compareElements() { /* 1. Make sure the names are the same. */ - QName baseElementName = this.readers[0].getName(); + final QName baseElementName = this.readers[0].getName(); for (int i = 1; i < this.readers.length; i++) { - QName compareElementName = this.readers[i].getName(); + final QName compareElementName = this.readers[i].getName(); if (! baseElementName.equals((compareElementName))) { message("Document " + (i + 1) + " has different Element "); return false; } } /* 2. Make sure the attribute counts are the same. */ - int baseAttributeCount = this.readers[0].getAttributeCount(); + final int baseAttributeCount = this.readers[0].getAttributeCount(); for (int i = 1; i < this.readers.length; i++) { - int compareAttributeCount = this.readers[i].getAttributeCount(); + final int compareAttributeCount = + this.readers[i].getAttributeCount(); if (baseAttributeCount != compareAttributeCount) { message("Document " + (i + 1) + " has different Attribute " + "Count "); @@ -452,12 +453,14 @@ * others, and that their values are equal. */ /* Iterate through each attribute of the base element. */ for (int i = 0; i < baseAttributeCount; i++) { - QName baseAttributeName = this.readers[0].getAttributeName(i); - String baseAttributeValue = this.readers[0].getAttributeValue(i); + final QName baseAttributeName = + this.readers[0].getAttributeName(i); + final String baseAttributeValue = + this.readers[0].getAttributeValue(i); /* Iterate through each of the other documents. */ for (int j = 1; j < this.readers.length; j++) { - XMLStreamReader reader = this.readers[j]; - String compareAttributeValue = reader.getAttributeValue( + final XMLStreamReader reader = this.readers[j]; + final String compareAttributeValue = reader.getAttributeValue( baseAttributeName.getNamespaceURI(), baseAttributeName.getLocalPart()); if (compareAttributeValue == null) { @@ -479,27 +482,27 @@ * Command-line interface for {@link FOrayXDiff}. * @param args Two or more URLs that should be compared. */ - public static void main(String[] args) { - URL[] urlsToCompare = new URL[args.length]; + public static void main(final String[] args) { + final URL[] urlsToCompare = new URL[args.length]; URL context = null; try { context = URLFactory.createURL("file", null, "."); - } catch (MalformedURLException e1) { + } catch (final MalformedURLException e1) { System.out.println("Unable to get URL context."); } for (int i = 0; i < args.length; i++) { URL url = null; try { url = URLFactory.createURL(context, args[i]); - } catch (MalformedURLException e) { + } catch (final MalformedURLException e) { System.out.println("Malformed URL: " + args[i]); System.exit(1); } urlsToCompare[i] = url; } try { - FOrayXDiff processor = new FOrayXDiff(urlsToCompare); - boolean equivalent = processor.equivalent(); + final FOrayXDiff processor = new FOrayXDiff(urlsToCompare); + final boolean equivalent = processor.equivalent(); if (equivalent) { System.out.println("All XML Streams are equivalent."); System.exit(0); @@ -507,7 +510,7 @@ System.out.println("Differences(s) in XML Streams found."); System.exit(3); } - } catch (Exception e) { + } catch (final Exception e) { System.out.println("Error parsing input."); System.out.println(e.getMessage()); System.exit(2); Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTD.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTD.java 2006-07-23 21:15:10 UTC (rev 7825) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTD.java 2006-07-23 21:24:31 UTC (rev 7826) @@ -36,11 +36,11 @@ public DTD() { } - public void addElement(DTDElement element) { + public void addElement(final DTDElement element) { this.elements.put(element.getName(), element); } - public DTDElement getElement(String name) { + public DTDElement getElement(final String name) { return (DTDElement) this.elements.get(name); } Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDElement.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDElement.java 2006-07-23 21:15:10 UTC (rev 7825) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDElement.java 2006-07-23 21:24:31 UTC (rev 7826) @@ -36,18 +36,18 @@ boolean isEmpty = false; boolean hasElementChildren = false; - public DTDElement(String elementName, String contentModel) { + public DTDElement(final String elementName, final String contentModel) { this.elementName = elementName; parseContentModel(contentModel); } - private void parseContentModel(String contentModel) { + private void parseContentModel(final String contentModel) { /* All we really care about right now is a whether it is empty, PCDATA, * mixed, or element children only. */ if (contentModel.indexOf("#PCDATA") > -1) { this.hasPCDATA = true; } - String[] contentTokens = DTDTokenizer.tokenizeElementContent( + final String[] contentTokens = DTDTokenizer.tokenizeElementContent( contentModel); this.isEmpty = DTDTokenizer.isElementContentEmpty(contentTokens); this.hasPCDATA = DTDTokenizer.hasPCDATA(contentTokens); Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDTokenizer.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDTokenizer.java 2006-07-23 21:15:10 UTC (rev 7825) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/DTDTokenizer.java 2006-07-23 21:24:31 UTC (rev 7826) @@ -43,8 +43,8 @@ * @param content The Element content to be parsed. * @return An array of String tokens. */ - public static String[] tokenizeElementContent(String content) { - ArrayList tokens = new ArrayList(); + public static String[] tokenizeElementContent(final String content) { + final ArrayList tokens = new ArrayList(); int startIndex = 0; int currentIndex = 0; while (true) { @@ -54,7 +54,7 @@ } break; } - char character = content.charAt(currentIndex); + final char character = content.charAt(currentIndex); if (isWhitespace(character) || isElementDelimiter(character)) { if (currentIndex - 1 > startIndex) { tokens.add(content.substring(startIndex, currentIndex)); @@ -70,7 +70,7 @@ return arrayListToStrings(tokens); } - public static boolean isWhitespace(int character) { + public static boolean isWhitespace(final int character) { switch (character) { case ' ': case '\t': @@ -81,7 +81,7 @@ return false; } - public static boolean isElementDelimiter(int character) { + public static boolean isElementDelimiter(final int character) { switch (character) { case '|': case '(': @@ -96,9 +96,9 @@ return false; } - public static boolean isElementContentEmpty(String[] tokens) { + public static boolean isElementContentEmpty(final String[] tokens) { for (int i = 0; i < tokens.length; i++) { - String token = tokens[i]; + final String token = tokens[i]; if (token.equals("EMPTY")) { return true; } @@ -106,9 +106,9 @@ return false; } - public static boolean hasPCDATA(String[] tokens) { + public static boolean hasPCDATA(final String[] tokens) { for (int i = 0; i < tokens.length; i++) { - String token = tokens[i]; + final String token = tokens[i]; if (token.equals("#PCDATA")) { return true; } @@ -116,9 +116,9 @@ return false; } - public static boolean hasElementChildren(String[] tokens) { + public static boolean hasElementChildren(final String[] tokens) { for (int i = 0; i < tokens.length; i++) { - String token = tokens[i]; + final String token = tokens[i]; if (isElementChild(token)) { return true; } @@ -126,9 +126,9 @@ return false; } - private static boolean isElementChild(String token) { + private static boolean isElementChild(final String token) { if (token.length() == 1) { - int character = token.charAt(0); + final int character = token.charAt(0); if (isElementDelimiter(character)) { return false; } @@ -146,8 +146,8 @@ * @param arrayList * @return A String array with arrayList's contents. */ - public static String[] arrayListToStrings(ArrayList arrayList) { - String[] strings = new String[arrayList.size()]; + public static String[] arrayListToStrings(final ArrayList arrayList) { + final String[] strings = new String[arrayList.size()]; for (int i = 0; i < arrayList.size(); i++) { strings[i] = (String) arrayList.get(i); } Modified: trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/ElementStack.java =================================================================== --- trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/ElementStack.java 2006-07-23 21:15:10 UTC (rev 7825) +++ trunk/foray/foray-pretty/src/java/org/foray/pretty/dtd/ElementStack.java 2006-07-23 21:24:31 UTC (rev 7826) @@ -36,12 +36,12 @@ public ElementStack() { } - public void push(DTDElement element) { + public void push(final DTDElement element) { this.stack.add(element); } public DTDElement pop() { - DTDElement topElement = peek(); + final DTDElement topElement = peek(); if (topElement != null) { this.stack.remove(stack.size() - 1); } @@ -58,11 +58,11 @@ * down, set to 1, etc. * @return The nth item down the stack, where n is indexFromTop. */ - private DTDElement peek(int indexFromTop) { + private DTDElement peek(final int indexFromTop) { if (this.stack.size() <= indexFromTop) { return null; } - int index = this.stack.size() - indexFromTop - 1; + final int index = this.stack.size() - indexFromTop - 1; return (DTDElement) this.stack.get(index); } @@ -85,7 +85,7 @@ * the stack is empty. */ public boolean topIsBlockElement() { - DTDElement parentElement = peek(1); + final DTDElement parentElement = peek(1); if (parentElement == null) { return true; } @@ -105,7 +105,7 @@ /* Start the loop at 1, because we don't care whether the top of the * stack contains PCDATA or not. */ for (int i = 1; i < this.stack.size(); i++) { - DTDElement element = peek(i); + final DTDElement element = peek(i); if (element == null) { return false; } @@ -117,7 +117,7 @@ } public boolean topHasPCDATA() { - DTDElement topElement = peek(); + final DTDElement topElement = peek(); if (topElement == null) { return false; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |