diff --git a/src/org/daisy/dotify/common/braille/BrailleNotationConverter.java b/src/org/daisy/dotify/common/braille/BrailleNotationConverter.java index f7316d6..41427a0 100644 --- a/src/org/daisy/dotify/common/braille/BrailleNotationConverter.java +++ b/src/org/daisy/dotify/common/braille/BrailleNotationConverter.java @@ -16,6 +16,11 @@ public BrailleNotationConverter(String separator) { this.separator = separator; } + /** + * Parses a string for braille notation and converts it to Unicode braille patterns + * @param p the string to parse + * @return returns the parsed string + */ public String parseBrailleNotation(String p) { String[] s = p.split(separator); if (s.length == 0) { diff --git a/src/org/daisy/dotify/common/collection/ArrayStack.java b/src/org/daisy/dotify/common/collection/ArrayStack.java index 43f11cb..b430d2e 100644 --- a/src/org/daisy/dotify/common/collection/ArrayStack.java +++ b/src/org/daisy/dotify/common/collection/ArrayStack.java @@ -8,6 +8,7 @@ * Provides an unsynchronized stack based on ArrayList instead of Vector. * * @author Joel Håkansson + * @param the type of array */ public class ArrayStack extends ArrayList { diff --git a/src/org/daisy/dotify/common/collection/CompoundIterable.java b/src/org/daisy/dotify/common/collection/CompoundIterable.java index 52c5802..9cbd81f 100644 --- a/src/org/daisy/dotify/common/collection/CompoundIterable.java +++ b/src/org/daisy/dotify/common/collection/CompoundIterable.java @@ -12,6 +12,10 @@ public class CompoundIterable implements Iterable { private final Iterable> iterables; + /** + * Creates a new compound iterable + * @param iterables the iterables to use + */ public CompoundIterable(Iterable> iterables) { this.iterables = iterables; } diff --git a/src/org/daisy/dotify/common/collection/CompoundIterator.java b/src/org/daisy/dotify/common/collection/CompoundIterator.java index 6488e8a..c89aad9 100644 --- a/src/org/daisy/dotify/common/collection/CompoundIterator.java +++ b/src/org/daisy/dotify/common/collection/CompoundIterator.java @@ -13,6 +13,10 @@ public class CompoundIterator implements Iterator { ArrayList> iterators; + /** + * Creates a new compound iterator + * @param iterables the iterables to use in this iterator + */ public CompoundIterator(Iterable> iterables) { iterators = new ArrayList<>(); for (Iterable e : iterables) { diff --git a/src/org/daisy/dotify/common/collection/SplitList.java b/src/org/daisy/dotify/common/collection/SplitList.java index 0acb883..1f6ee32 100644 --- a/src/org/daisy/dotify/common/collection/SplitList.java +++ b/src/org/daisy/dotify/common/collection/SplitList.java @@ -13,6 +13,11 @@ public class SplitList { private final List first, second; + /** + * Creates a new split list + * @param first the first part of the list + * @param second the second part of the list + */ public SplitList(List first, List second) { this.first = first; this.second = second; diff --git a/src/org/daisy/dotify/common/io/AbstractResourceLocator.java b/src/org/daisy/dotify/common/io/AbstractResourceLocator.java index 3179e3f..b6563a6 100644 --- a/src/org/daisy/dotify/common/io/AbstractResourceLocator.java +++ b/src/org/daisy/dotify/common/io/AbstractResourceLocator.java @@ -12,10 +12,20 @@ public abstract class AbstractResourceLocator implements ResourceLocator { private final String basePath; + /** + * Creates a new abstract resource locator. Resources are resolved relative + * to the location of the concrete implementation. + */ public AbstractResourceLocator() { this(null); } + /** + * Creates a new abstract resource locator with the specified sub-path prefix, in other + * words a sub-path from where all resources are resolved. Resources are resolved relative + * to the location of the concrete implementation. + * @param basePath the sub-path prefix + */ public AbstractResourceLocator(String basePath) { if (basePath==null || basePath.equals("")) { this.basePath = ""; diff --git a/src/org/daisy/dotify/common/io/ByteArrayInputStreamMaker.java b/src/org/daisy/dotify/common/io/ByteArrayInputStreamMaker.java index 4097b1e..9bebdde 100644 --- a/src/org/daisy/dotify/common/io/ByteArrayInputStreamMaker.java +++ b/src/org/daisy/dotify/common/io/ByteArrayInputStreamMaker.java @@ -4,9 +4,18 @@ import java.io.IOException; import java.io.InputStream; +/** + * Provides a in-memory input stream maker. + * @author Joel Håkansson + * + */ public class ByteArrayInputStreamMaker implements InputStreamMaker { private final byte[] buf; + /** + * Creates a new byte array input stream maker with the specified data. + * @param buf the data + */ public ByteArrayInputStreamMaker(byte[] buf) { this.buf = buf; } diff --git a/src/org/daisy/dotify/common/io/ByteArrayStreamJuggler.java b/src/org/daisy/dotify/common/io/ByteArrayStreamJuggler.java index d38b9f1..d1e28c8 100644 --- a/src/org/daisy/dotify/common/io/ByteArrayStreamJuggler.java +++ b/src/org/daisy/dotify/common/io/ByteArrayStreamJuggler.java @@ -8,6 +8,11 @@ import java.io.IOException; import java.io.OutputStream; +/** + * Provides an in-memory stream juggler. + * + * @author Joel Håkansson + */ public class ByteArrayStreamJuggler implements StreamJuggler { private final int BUF_SIZE = 65536; private InputStreamMaker ci; diff --git a/src/org/daisy/dotify/common/io/FileIO.java b/src/org/daisy/dotify/common/io/FileIO.java index ffcc454..1508760 100644 --- a/src/org/daisy/dotify/common/io/FileIO.java +++ b/src/org/daisy/dotify/common/io/FileIO.java @@ -11,6 +11,11 @@ import java.nio.channels.FileChannel; import java.util.logging.Logger; +/** + * Provides file IO tools. + * @author Joel Håkansson + * + */ public class FileIO { /** @@ -35,10 +40,22 @@ public static void copy(InputStream is, OutputStream os) throws IOException { bis.close(); } + /** + * Copies an input file to an output file + * @param input the input file + * @param output the output file + * @throws IOException if IO fails + */ public static void copy(File input, File output) throws IOException { copy(new FileInputStream(input), new FileOutputStream(output)); } + /** + * Copies an input file to an output file + * @param sourceFile the source file + * @param destFile the destination file + * @throws IOException if IO fails + */ public static void copyFile(File sourceFile, File destFile) throws IOException { if (!destFile.exists()) { destFile.createNewFile(); @@ -60,12 +77,22 @@ public static void copyFile(File sourceFile, File destFile) throws IOException { } } + /** + * Creates a temp file + * @return returns a the created file + * @throws IOException if IO fails + */ public static File createTempFile() throws IOException { File ret = File.createTempFile("temp", null, null); ret.deleteOnExit(); return ret; } + /** + * Creates a temp folder + * @return returns the created folder + * @throws IOException if IO fails + */ public static File createTempDir() throws IOException { File temp = File.createTempFile("temp", Long.toString(System.nanoTime())); if (!temp.delete()) { @@ -87,6 +114,11 @@ public static File createTempDir() throws IOException { return f; } + /** + * Copies a folder recursively + * @param f the source folder + * @param out the destination folder + */ public static void copyRecursive(File f, File out) { if (f.isDirectory()) { out.mkdirs(); @@ -102,6 +134,10 @@ public static void copyRecursive(File f, File out) { } } + /** + * Deletes a folder recursively + * @param f the folder to delete + */ public static void deleteRecursive(File f) { if (f.isDirectory()) { for (File f1 : f.listFiles()) { diff --git a/src/org/daisy/dotify/common/io/FileInputStreamMaker.java b/src/org/daisy/dotify/common/io/FileInputStreamMaker.java index 1cab5c2..e52842c 100644 --- a/src/org/daisy/dotify/common/io/FileInputStreamMaker.java +++ b/src/org/daisy/dotify/common/io/FileInputStreamMaker.java @@ -5,9 +5,18 @@ import java.io.IOException; import java.io.InputStream; +/** + * Provides a file based input stream maker + * @author Joel Håkansson + * + */ public class FileInputStreamMaker implements InputStreamMaker { private final File f; + /** + * Creates a new input stream maker with the specified file as source + * @param f the file containing the stream source + */ public FileInputStreamMaker(File f) { this.f = f; } diff --git a/src/org/daisy/dotify/common/io/StreamJuggler.java b/src/org/daisy/dotify/common/io/StreamJuggler.java index 1633c5a..63cecc7 100644 --- a/src/org/daisy/dotify/common/io/StreamJuggler.java +++ b/src/org/daisy/dotify/common/io/StreamJuggler.java @@ -4,6 +4,15 @@ import java.io.IOException; import java.io.OutputStream; +/** + *

Provides a juggler for streams.

+ *

This interface can be used to limit the code needed to handle temporary streams + * in a sequence of read/write operations. After each step (stream written) + * the juggler can be reset by calling reset() and the streams are ready to be used + * again. Very convenient together with optional steps.

+ * + * @author Joel Håkansson + */ public interface StreamJuggler extends Closeable { /** diff --git a/src/org/daisy/dotify/common/layout/SplitPoint.java b/src/org/daisy/dotify/common/layout/SplitPoint.java index 4eac552..e987e2c 100644 --- a/src/org/daisy/dotify/common/layout/SplitPoint.java +++ b/src/org/daisy/dotify/common/layout/SplitPoint.java @@ -4,7 +4,8 @@ import java.util.List; /** - * Provides a data object to keep the information about a split point result. + * Provides a data object to keep the information about a split point result. + * @param the type of split point units * @author Joel Håkansson */ public class SplitPoint { diff --git a/src/org/daisy/dotify/common/layout/SplitPointCost.java b/src/org/daisy/dotify/common/layout/SplitPointCost.java index 6aabc92..47a82a3 100644 --- a/src/org/daisy/dotify/common/layout/SplitPointCost.java +++ b/src/org/daisy/dotify/common/layout/SplitPointCost.java @@ -5,6 +5,7 @@ /** * * @author Joel Håkansson + * @param the type of split point unit * */ // @FunctionalInterface diff --git a/src/org/daisy/dotify/common/layout/SplitPointData.java b/src/org/daisy/dotify/common/layout/SplitPointData.java index 7aaeaa6..1a66507 100644 --- a/src/org/daisy/dotify/common/layout/SplitPointData.java +++ b/src/org/daisy/dotify/common/layout/SplitPointData.java @@ -3,19 +3,38 @@ import java.util.Arrays; import java.util.List; +/** + * Provides split point data + * @author Joel Håkansson + * + * @param the type of split point units + */ public final class SplitPointData { private final List units; private final Supplements supplements; + /** + * Creates a new instance with the specified units + * @param units the units + */ @SafeVarargs public SplitPointData(T ... units) { this(Arrays.asList(units)); } + /** + * Creates a new instance with the specified units + * @param units the units + */ public SplitPointData(List units) { this(units, null); } + /** + * Creates a new instance with the specified units and supplements + * @param units the units + * @param supplements the supplements + */ public SplitPointData(List units, Supplements supplements) { this.units = units; if (supplements==null) { @@ -29,10 +48,18 @@ public T get(String id) { } } + /** + * Gets the split point data units + * @return returns the units + */ public List getUnits() { return units; } + /** + * Gets the split point data supplements + * @return the supplements + */ public Supplements getSupplements() { return supplements; } diff --git a/src/org/daisy/dotify/common/layout/SplitPointHandler.java b/src/org/daisy/dotify/common/layout/SplitPointHandler.java index 97edae7..b104d8b 100644 --- a/src/org/daisy/dotify/common/layout/SplitPointHandler.java +++ b/src/org/daisy/dotify/common/layout/SplitPointHandler.java @@ -13,6 +13,7 @@ * * @author Joel Håkansson * + * @param the type of split point units */ public class SplitPointHandler { private final List EMPTY_LIST = Collections.emptyList(); @@ -34,7 +35,6 @@ public double getCost(List units, int breakpoint) { }; } - @SafeVarargs /** * Splits the data at, or before, the supplied breakPoint according to the rules * in the data. If force is used, rules may be broken to achieve a result. @@ -43,6 +43,7 @@ public double getCost(List units, int breakpoint) { * @param units the data * @return returns a split point result */ + @SafeVarargs public final SplitPoint split(float breakPoint, boolean force, T ... units) { return split(breakPoint, force, new SplitPointData<>(units)); } diff --git a/src/org/daisy/dotify/common/text/BreakPointHandler.java b/src/org/daisy/dotify/common/text/BreakPointHandler.java index 2803a4e..7e3c15d 100644 --- a/src/org/daisy/dotify/common/text/BreakPointHandler.java +++ b/src/org/daisy/dotify/common/text/BreakPointHandler.java @@ -7,7 +7,7 @@ /** * Breaks a paragraph of text into rows. It is assumed that all - * preferred break points are supplied with the input String. + * preferred break points are supplied with the input string. * * Soft hyphen (0x00ad) and zero width space (0x200b) characters * can also be used for non-standard hyphenation. @@ -29,10 +29,21 @@ public class BreakPointHandler { private int offset; private TreeMap meta; + /** + * Provides a builder for break point handlers + * @author Joel Håkansson + * + */ public static class Builder { private final String str; private final TreeMap meta; + /** + * Creates a new builder with the string to break. + * All regular break points must be in supplied with the input string, + * represented by hyphen 0x2d, soft hyphen 0xad or space 0x20. + * @param str the string + */ public Builder(String str) { this.str = str; this.meta = new TreeMap<>(); @@ -82,11 +93,7 @@ public BreakPointHandler build() { public BreakPointHandler(String str) { this(str, null, 0); } -/* - public BreakPointHandler(String str, TreeMap meta) { - this(str, meta, 0); - }*/ - + @SuppressWarnings("unchecked") private BreakPointHandler(String str, TreeMap meta, int offset) { if (str==null) { @@ -216,6 +223,10 @@ private BreakPoint finalizeBreakpointTrimTail(String head, String tail, boolean return new BreakPoint(head, tail, hard); } + /** + * Counts the remaining characters, excluding unused breakpoints. + * @return returns the number of remaining characters + */ public int countRemaining() { if (charsStr==null) { return 0; @@ -223,6 +234,10 @@ public int countRemaining() { return getRemaining().length(); } + /** + * Gets the remaining characters, removing unused breakpoint characters. + * @return returns the remaining characters + */ public String getRemaining() { return finalizeResult(charsStr); } diff --git a/src/org/daisy/dotify/common/text/FilterLocale.java b/src/org/daisy/dotify/common/text/FilterLocale.java index f9af0db..3b4bc5e 100644 --- a/src/org/daisy/dotify/common/text/FilterLocale.java +++ b/src/org/daisy/dotify/common/text/FilterLocale.java @@ -17,6 +17,12 @@ private FilterLocale(String lang, String country, String variant) { this.str = (lang + ("".equals(country) ? "" : "-" + country + ("".equals(variant) ? "" : "-" + variant))).intern(); } + /** + * Parses the string into a locale + * @param locale the locale string + * @return returns a new filter locale + * @throws IllegalArgumentException if the locale is not valid as defined by IETF RFC 3066 + */ public static FilterLocale parse(String locale) { if (!locale.matches("([a-zA-Z]{1,8}(\\-[0-9a-zA-Z]{1,8})*)?")) { throw new IllegalArgumentException("Not a valid locale as defined by IETF RFC 3066: " + locale); @@ -34,18 +40,34 @@ public static FilterLocale parse(String locale) { return new FilterLocale(lang, country, variant); } + /** + * Returns this filter locale as a standard java Locale object + * @return returns a standard Locale object + */ public Locale toLocale() { return new Locale(lang, country, variant); } + /** + * Gets the language of this locale + * @return returns the language + */ public String getLanguage() { return lang; } + /** + * Gets the country of this locale + * @return returns the locale + */ public String getCountry() { return country; } + /** + * Gets the variant of this locale + * @return returns the variant + */ public String getVariant() { return variant; } diff --git a/src/org/daisy/dotify/common/text/IdentityFilter.java b/src/org/daisy/dotify/common/text/IdentityFilter.java index 9da5630..a64c365 100644 --- a/src/org/daisy/dotify/common/text/IdentityFilter.java +++ b/src/org/daisy/dotify/common/text/IdentityFilter.java @@ -1,7 +1,10 @@ package org.daisy.dotify.common.text; - - +/** + * Provides an identity filter, in other words the input is returned unchanged. + * @author Joel Håkansson + * + */ public class IdentityFilter implements StringFilter { @Override diff --git a/src/org/daisy/dotify/common/text/SimpleUCharReplacer.java b/src/org/daisy/dotify/common/text/SimpleUCharReplacer.java index 1c6fe1f..453e9ca 100644 --- a/src/org/daisy/dotify/common/text/SimpleUCharReplacer.java +++ b/src/org/daisy/dotify/common/text/SimpleUCharReplacer.java @@ -73,10 +73,19 @@ public class SimpleUCharReplacer extends HashMap { */ private static final long serialVersionUID = -3238811228931823883L; + /** + * Creates a new instance. + */ public SimpleUCharReplacer() { super(); } + /** + * Adds a substitution table to this instance. See the class description for + * the format. + * @param table the url to the substitution table. + * @throws IOException + */ public void addSubstitutionTable(URL table) throws IOException { try { loadTable(table); @@ -85,6 +94,11 @@ public void addSubstitutionTable(URL table) throws IOException { } } + /** + * Replaces characters in the input according to this object's current configuration. + * @param input the input + * @return returns a modified string + */ public CharSequence replace(String input) { int codePoint; diff --git a/src/org/daisy/dotify/common/text/TextFileReader.java b/src/org/daisy/dotify/common/text/TextFileReader.java index fbbb614..f196c85 100644 --- a/src/org/daisy/dotify/common/text/TextFileReader.java +++ b/src/org/daisy/dotify/common/text/TextFileReader.java @@ -24,16 +24,30 @@ public class TextFileReader implements Closeable { private int limit; private int currentLine; + /** + * Provides a builder for a text file reader + * @author Joel Håkansson + * + */ public static class Builder { private final InputStream is; private Charset cs = DEFAULT_CHARSET; private String regex = DEFAULT_EXPRESSION; private int limit = DEFAULT_LIMIT; + /** + * Creates a new builder with the specified input stream + * @param value the input stream + */ public Builder(InputStream value) { this.is = value; } + /** + * Sets the charset for this builder + * @param value the charset + * @return returns this builder + */ public Builder charset(Charset value) { this.cs = value; return this; @@ -52,11 +66,21 @@ public Builder regex(String value) { return this; } + /** + * Sets the maximum number of times that the specified regular expression is matched + * on a single row + * @param value the limit + * @return returns this builder + */ public Builder limit(int value) { this.limit = value; return this; } + /** + * Creates a new text file reader with the current configuration + * @return returns a new text file reader + */ public TextFileReader build() { return new TextFileReader(this); } @@ -126,6 +150,11 @@ public void close() throws IOException { lnr.close(); } + /** + * Provides the data about a single line + * @author Joel Håkansson + * + */ public class LineData { private final String line; private final String[] fields; diff --git a/src/org/daisy/dotify/common/xml/CachingURIResolver.java b/src/org/daisy/dotify/common/xml/CachingURIResolver.java index 3dc24fb..1922d6a 100644 --- a/src/org/daisy/dotify/common/xml/CachingURIResolver.java +++ b/src/org/daisy/dotify/common/xml/CachingURIResolver.java @@ -42,10 +42,19 @@ public class CachingURIResolver implements URIResolver { private final XMLReader reader; + /** + * Creates a new uri resolver + * @throws XMLToolsException if something goes wrong + */ public CachingURIResolver() throws XMLToolsException { this(SAXParserFactory.newInstance()); } + /** + * Creates a new uri resolver with the specified sax parser factory + * @param parserFactory the parser factory + * @throws XMLToolsException if something goes wrong + */ public CachingURIResolver(SAXParserFactory parserFactory) throws XMLToolsException { parserFactory.setNamespaceAware(true); SAXParser parser; diff --git a/src/org/daisy/dotify/common/xml/EntityResolverCache.java b/src/org/daisy/dotify/common/xml/EntityResolverCache.java index 547456c..6f0ee94 100644 --- a/src/org/daisy/dotify/common/xml/EntityResolverCache.java +++ b/src/org/daisy/dotify/common/xml/EntityResolverCache.java @@ -9,10 +9,18 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; +/** + * Provides an entity resolver with cache + * @author Joel Håkansson + * + */ public class EntityResolverCache implements EntityResolver { private final URLCache cache; + /** + * Creates a new entity resolver with cache + */ public EntityResolverCache() { cache = new URLCache(); } diff --git a/src/org/daisy/dotify/common/xml/XMLInfo.java b/src/org/daisy/dotify/common/xml/XMLInfo.java index 35b7370..984cf45 100644 --- a/src/org/daisy/dotify/common/xml/XMLInfo.java +++ b/src/org/daisy/dotify/common/xml/XMLInfo.java @@ -2,6 +2,11 @@ import org.xml.sax.Attributes; +/** + * Provides basic information about an XML-document. + * + * @author Joel Håkansson + */ public class XMLInfo { private final String uri; private final String localName; @@ -10,6 +15,9 @@ public class XMLInfo { private final String publicId; private final String systemId; + /** + * Provides a builder for XML info. + */ public static class Builder { private String uri = null; private String localName = null; @@ -18,38 +26,81 @@ public static class Builder { private String publicId = null; private String systemId = null; - public Builder() { } - + /** + * Creates a new empty builder. + */ + public Builder() { + //no required parameters for this builder + } + + /** + * Sets the uri. + * @param value The Namespace URI, or the empty string if the + * element has no Namespace URI or if Namespace + * processing is not being performed. + * @return returns this builder + */ public Builder uri(String value) { this.uri = value; return this; } + /** + * Sets the local name. + * @param value The local name (without prefix), or the empty string + * if Namespace processing is not being performed. + * @return returns this builder + */ public Builder localName(String value) { this.localName = value; return this; } + /** + * Sets the qualified name. + * @param value The qualified name (with prefix), or the + * empty string if qualified names are not available. + * @return returns this builder + */ public Builder qName(String value) { this.qName = value; return this; } + /** + * Sets the attributes. + * @param value The attributes attached to the element. + * @return returns this builder + */ public Builder attributes(Attributes value) { this.attributes = value; return this; } - + + /** + * Sets the public identifier of the DTD declaration. + * @param value The public identifier, or null if none is available. + * @return returns this builder + */ public Builder publicId(String value) { this.publicId = value; return this; } + /** + * Sets the system identifier of the DTD declaration. + * @param value The system identifier provided in the XML document, or null if none is available. + * @return returns this builder + */ public Builder systemId(String value) { this.systemId = value; return this; } + /** + * Creates a new XMLInfo instance using the current state of the builder. + * @return returns a new XMLInfo instance + */ public XMLInfo build() { return new XMLInfo(this); } @@ -64,26 +115,59 @@ private XMLInfo(Builder builder) { this.systemId = builder.systemId; } + /** + * Gets the Namespace URI, or the empty string if the element has + * no Namespace URI or if Namespace processing is not being performed. + * Or null, if the uri has not been set. + * @return returns the namespace uri, or null + */ public String getUri() { return uri; } + /** + * Gets the local name (without prefix), or the empty string if Namespace + * processing is not being performed. + * Or null, if the local name has not been set. + * @return returns the local name, or null + */ public String getLocalName() { return localName; } + /** + * Gets the qualified name (with prefix), or the empty string if qualified + * names are not available. + * Or null, if the qualified name has not been set. + * @return returns the qualified name, or null + */ public String getqName() { return qName; } + /** + * Gets the attributes attached to the element or null if the attributes has + * not been set. + * @return returns the attributes, or null + */ public Attributes getAttributes() { return attributes; } + /** + * Gets the public identifier of the DTD declaration or null if the public + * identifier has not been set or if the document doesn't contain a public identifier. + * @return returns the public identifier, or null + */ public String getPublicId() { return publicId; } + /** + * Gets the system identifier provided in the XML document or null if the system + * identifier has not been set or if the document doesn't contain a system identifier. + * @return returns the system identifier, or null + */ public String getSystemId() { return systemId; } diff --git a/src/org/daisy/dotify/common/xml/XMLResolverAdapter.java b/src/org/daisy/dotify/common/xml/XMLResolverAdapter.java index ae090d2..91ce2e1 100644 --- a/src/org/daisy/dotify/common/xml/XMLResolverAdapter.java +++ b/src/org/daisy/dotify/common/xml/XMLResolverAdapter.java @@ -30,19 +30,22 @@ import org.xml.sax.SAXException; /** - * An XMLResolver that uses a SAX EntityResolver for entity resolution. + * Provides an XMLResolver that uses a SAX EntityResolver for entity resolution. * @author Linus Ericson */ public class XMLResolverAdapter implements XMLResolver { private final EntityResolver resolver; + /** + * Creates a new xml resolver adapter. + * @param entityResolver the entity resolver to use + */ public XMLResolverAdapter(EntityResolver entityResolver) { resolver = entityResolver; } @Override - @SuppressWarnings("unused") public Object resolveEntity(String publicID, String systemID, String baseURI, String namespace) throws XMLStreamException { try { InputSource is = resolver.resolveEntity(publicID, systemID); diff --git a/src/org/daisy/dotify/common/xml/XMLTools.java b/src/org/daisy/dotify/common/xml/XMLTools.java index 34ff6f0..dee87db 100644 --- a/src/org/daisy/dotify/common/xml/XMLTools.java +++ b/src/org/daisy/dotify/common/xml/XMLTools.java @@ -30,20 +30,79 @@ import org.xml.sax.ext.LexicalHandler; import org.xml.sax.helpers.DefaultHandler; +/** + * Provides some xml tools. + * + * @author Joel Håkansson + */ public class XMLTools { + + private XMLTools() {} + /** + *

Transforms the xml with the specified parameters. By default, this method will set up a caching entity resolver, which + * will reduce the amount of fetching of dtd's from the Internet.

+ * + *

This method will attempt to create Source and Result objects from the supplied source, result and xslt objects. + * This process supports several types of objects from which Sources and Results are typically created, such as files, + * strings and URLs.

+ * + *

This method will create its own instance of a transformer factory.

+ * + * @param source the source xml + * @param result the result xml + * @param xslt the xslt + * @param params xslt parameters + * @throws XMLToolsException if the transformation is unsuccessful + */ public static void transform(Object source, Object result, Object xslt, Map params) throws XMLToolsException { transform(toSource(source), toResult(result), toSource(xslt), params); } + /** + *

Transforms the xml with the specified parameters. By default, this method will set up a caching entity resolver, which + * will reduce the amount of fetching of dtd's from the Internet.

+ * + *

This method will attempt to create Source and Result objects from the supplied source, result and xslt objects. + * This process supports several types of objects from which Sources and Results are typically created, such as files, + * strings and URLs.

+ * + * @param source the source xml + * @param result the result xml + * @param xslt the xslt + * @param params xslt parameters + * @param factory the transformer factory + * @throws XMLToolsException if the transformation is unsuccessful + */ public static void transform(Object source, Object result, Object xslt, Map params, TransformerFactory factory) throws XMLToolsException { transform(toSource(source), toResult(result), toSource(xslt), params, factory); } + /** + * Transforms the xml with the specified parameters. By default, this method will set up a caching entity resolver, which + * will reduce the amount of fetching of dtd's from the Internet. + * + *

This method will create its own instance of a transformer factory.

+ * @param source the source xml + * @param result the result xml + * @param xslt the xslt + * @param params xslt parameters + * @throws XMLToolsException if the transformation is unsuccessful + */ public static void transform(Source source, Result result, Source xslt, Map params) throws XMLToolsException { transform(source, result, xslt, params, TransformerFactory.newInstance()); } + /** + *

Transforms the xml with the specified parameters. By default, this method will set up a caching entity resolver, which + * will reduce the amount of fetching of dtd's from the Internet.

+ * @param source the source xml + * @param result the result xml + * @param xslt the xslt + * @param params xslt parameters + * @param factory the transformer factory + * @throws XMLToolsException if the transformation is unsuccessful + */ public static void transform(Source source, Result result, Source xslt, Map params, TransformerFactory factory) throws XMLToolsException { Transformer transformer; try { @@ -145,6 +204,15 @@ public static final XMLInfo parseXML(File f) throws XMLToolsException { return parseXML(f, false); } + /** + * Returns some root node information and optionally asserts that the specified + * file is well formed. + * @param f the file + * @param peek true if the parsing should stop after reading the root element. If true, + * the file may or may not be well formed beyond the first start tag. + * @return returns the root node, or null if file is not well formed + * @throws XMLToolsException if a parser cannot be configured or if parsing fails + */ public static final XMLInfo parseXML(File f, boolean peek) throws XMLToolsException { SAXParserFactory factory = SAXParserFactory.newInstance(); factory.setNamespaceAware(true); diff --git a/src/org/daisy/dotify/common/xml/XMLToolsException.java b/src/org/daisy/dotify/common/xml/XMLToolsException.java index 63d2b31..4eb8447 100644 --- a/src/org/daisy/dotify/common/xml/XMLToolsException.java +++ b/src/org/daisy/dotify/common/xml/XMLToolsException.java @@ -1,24 +1,62 @@ package org.daisy.dotify.common.xml; +/** + * Provides an exception indicating a problem with an XML tool. + * @author Joel Håkansson + */ public class XMLToolsException extends Exception { - /** - * - */ private static final long serialVersionUID = 1153805097179534210L; + /** + * Constructs a new exception with {@code null} as its detail message. + * The cause is not initialized, and may subsequently be initialized by a + * call to {@link #initCause}. + */ public XMLToolsException() { + super(); } + /** + * Constructs a new exception with the specified detail message. The + * cause is not initialized, and may subsequently be initialized by + * a call to {@link #initCause}. + * + * @param message the detail message. The detail message is saved for + * later retrieval by the {@link #getMessage()} method. + */ public XMLToolsException(String message) { super(message); } + /** + * Constructs a new exception with the specified cause and a detail + * message of (cause==null ? null : cause.toString()) (which + * typically contains the class and detail message of cause). + * + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ public XMLToolsException(Throwable cause) { super(cause); } + /** + * Constructs a new exception with the specified detail message and + * cause.

Note that the detail message associated with + * {@code cause} is not automatically incorporated in + * this exception's detail message. + * + * @param message the detail message (which is saved for later retrieval + * by the {@link #getMessage()} method). + * @param cause the cause (which is saved for later retrieval by the + * {@link #getCause()} method). (A null value is + * permitted, and indicates that the cause is nonexistent or + * unknown.) + */ public XMLToolsException(String message, Throwable cause) { super(message, cause); } diff --git a/test/org/daisy/dotify/common/braille/BrailleNotationConverterTest.java b/test/org/daisy/dotify/common/braille/BrailleNotationConverterTest.java index 40abd4c..4095c2e 100644 --- a/test/org/daisy/dotify/common/braille/BrailleNotationConverterTest.java +++ b/test/org/daisy/dotify/common/braille/BrailleNotationConverterTest.java @@ -2,6 +2,7 @@ import org.junit.Test; +@SuppressWarnings("javadoc") public class BrailleNotationConverterTest { @Test diff --git a/test/org/daisy/dotify/common/io/StateObjectTest.java b/test/org/daisy/dotify/common/io/StateObjectTest.java index a729d54..f4dfe49 100644 --- a/test/org/daisy/dotify/common/io/StateObjectTest.java +++ b/test/org/daisy/dotify/common/io/StateObjectTest.java @@ -4,6 +4,7 @@ import org.daisy.dotify.common.io.StateObject; import org.junit.Test; +@SuppressWarnings("javadoc") public class StateObjectTest { @Test diff --git a/test/org/daisy/dotify/common/layout/SplitPointHandlerTest.java b/test/org/daisy/dotify/common/layout/SplitPointHandlerTest.java index ac27835..ab4b6f7 100644 --- a/test/org/daisy/dotify/common/layout/SplitPointHandlerTest.java +++ b/test/org/daisy/dotify/common/layout/SplitPointHandlerTest.java @@ -8,6 +8,7 @@ import org.junit.Test; +@SuppressWarnings("javadoc") public class SplitPointHandlerTest { DummySplitPoint c = new DummySplitPoint.Builder().breakable(false).skippable(false).size(1).build(); diff --git a/test/org/daisy/dotify/common/text/BreakPointHandlerTest.java b/test/org/daisy/dotify/common/text/BreakPointHandlerTest.java index 95dcfe1..0923d99 100644 --- a/test/org/daisy/dotify/common/text/BreakPointHandlerTest.java +++ b/test/org/daisy/dotify/common/text/BreakPointHandlerTest.java @@ -6,6 +6,7 @@ import org.daisy.dotify.common.text.BreakPointHandler; import org.junit.Test; +@SuppressWarnings("javadoc") public class BreakPointHandlerTest { @Test diff --git a/test/org/daisy/dotify/common/text/FilterLocaleTest.java b/test/org/daisy/dotify/common/text/FilterLocaleTest.java index 8b6d8ea..ed03bdb 100644 --- a/test/org/daisy/dotify/common/text/FilterLocaleTest.java +++ b/test/org/daisy/dotify/common/text/FilterLocaleTest.java @@ -4,6 +4,7 @@ import org.daisy.dotify.common.text.FilterLocale; import org.junit.Test; +@SuppressWarnings("javadoc") public class FilterLocaleTest { @Test diff --git a/test/org/daisy/dotify/common/text/NonStandardHyphenationRuleTest.java b/test/org/daisy/dotify/common/text/NonStandardHyphenationRuleTest.java index 556a9e6..7673077 100644 --- a/test/org/daisy/dotify/common/text/NonStandardHyphenationRuleTest.java +++ b/test/org/daisy/dotify/common/text/NonStandardHyphenationRuleTest.java @@ -5,6 +5,7 @@ import org.daisy.dotify.common.text.NonStandardHyphenationInfo; import org.junit.Test; +@SuppressWarnings("javadoc") public class NonStandardHyphenationRuleTest { @Test diff --git a/test/org/daisy/dotify/common/text/StringToolsTest.java b/test/org/daisy/dotify/common/text/StringToolsTest.java index 1bb2958..4f42862 100644 --- a/test/org/daisy/dotify/common/text/StringToolsTest.java +++ b/test/org/daisy/dotify/common/text/StringToolsTest.java @@ -5,6 +5,7 @@ import org.daisy.dotify.common.text.StringTools; import org.junit.Test; +@SuppressWarnings("javadoc") public class StringToolsTest { @Test diff --git a/test/org/daisy/dotify/common/text/TestNSH.java b/test/org/daisy/dotify/common/text/TestNSH.java index 5e47fa4..679b315 100644 --- a/test/org/daisy/dotify/common/text/TestNSH.java +++ b/test/org/daisy/dotify/common/text/TestNSH.java @@ -4,6 +4,7 @@ import org.daisy.dotify.common.text.BreakPointHandler; +@SuppressWarnings("javadoc") public class TestNSH { public static void main(String[] args) { diff --git a/test/org/daisy/dotify/common/xml/URLCacheTest.java b/test/org/daisy/dotify/common/xml/URLCacheTest.java index 272c308..04c8ec7 100644 --- a/test/org/daisy/dotify/common/xml/URLCacheTest.java +++ b/test/org/daisy/dotify/common/xml/URLCacheTest.java @@ -10,6 +10,7 @@ import org.daisy.dotify.common.xml.URLCache; import org.junit.Test; +@SuppressWarnings("javadoc") public class URLCacheTest { @Test diff --git a/test/org/daisy/dotify/common/xml/XMLToolsTest.java b/test/org/daisy/dotify/common/xml/XMLToolsTest.java index 6cddc7b..b7c0d13 100644 --- a/test/org/daisy/dotify/common/xml/XMLToolsTest.java +++ b/test/org/daisy/dotify/common/xml/XMLToolsTest.java @@ -13,6 +13,7 @@ import org.daisy.dotify.common.xml.XMLToolsException; import org.junit.Test; +@SuppressWarnings("javadoc") public class XMLToolsTest { @Test