diff --git a/src/fr/devinsy/util/FileTools.java b/src/fr/devinsy/util/FileTools.java index bb06d5d..9ab0414 100644 --- a/src/fr/devinsy/util/FileTools.java +++ b/src/fr/devinsy/util/FileTools.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2008-2015,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util; @@ -35,6 +35,7 @@ import fr.devinsy.util.strings.StringList; import fr.devinsy.util.strings.StringListUtils; /** + * The Class FileTools. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ @@ -43,11 +44,12 @@ public class FileTools public static final String DEFAULT_CHARSET_NAME = "UTF-8"; /** - * + * Adds the before extension. * * @param fileName * Source. - * + * @param addition + * the addition * @return Extension value or null. */ public static String addBeforeExtension(final String fileName, final String addition) @@ -83,11 +85,12 @@ public class FileTools } /** - * + * Adds the to name. * * @param file * Source. - * + * @param addition + * the addition * @return Extension value or null. */ public static File addToName(final File file, final String addition) @@ -149,9 +152,8 @@ public class FileTools *
  • getExtension("abc.efg") = "efg"
  • * * - * @param file - * Source. - * + * @param fileName + * the file name * @return Extension value or null. * @deprecated See * org.apache.commons.io.FilenameUtils.getExtension @@ -183,10 +185,13 @@ public class FileTools } /** + * Load. * - * @param file - * @return + * @param source + * the source + * @return the string * @throws IOException + * Signals that an I/O exception has occurred. */ public static String load(final File source) throws IOException { @@ -199,9 +204,15 @@ public class FileTools } /** + * Load. * - * @param file + * @param source + * the source + * @param charsetName + * the charset name + * @return the string * @throws IOException + * Signals that an I/O exception has occurred. */ public static String load(final File source, final String charsetName) throws IOException { @@ -214,10 +225,13 @@ public class FileTools } /** + * Load. * - * @param file - * @return + * @param source + * the source + * @return the string * @throws IOException + * Signals that an I/O exception has occurred. */ public static String load(final URL source) throws IOException { @@ -230,9 +244,15 @@ public class FileTools } /** + * Load. * - * @param file + * @param source + * the source + * @param charsetName + * the charset name + * @return the string * @throws IOException + * Signals that an I/O exception has occurred. */ public static String load(final URL source, final String charsetName) throws IOException { @@ -250,9 +270,13 @@ public class FileTools } /** + * Load string list. * - * @param file + * @param source + * the source + * @return the string list * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringList loadStringList(final File source) throws IOException { @@ -265,9 +289,15 @@ public class FileTools } /** + * Load string list. * * @param file + * the file + * @param charsetName + * the charset name + * @return the string list * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringList loadStringList(final File file, final String charsetName) throws IOException { @@ -280,9 +310,13 @@ public class FileTools } /** + * Load to string buffer. * - * @param file + * @param source + * the source + * @return the string buffer * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringBuffer loadToStringBuffer(final File source) throws IOException { @@ -295,9 +329,15 @@ public class FileTools } /** + * Load to string buffer. * * @param file + * the file + * @param charsetName + * the charset name + * @return the string buffer * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringBuffer loadToStringBuffer(final File file, final String charsetName) throws IOException { @@ -345,9 +385,13 @@ public class FileTools } /** + * Load to string list. * - * @param file + * @param source + * the source + * @return the string list * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringList loadToStringList(final File source) throws IOException { @@ -360,9 +404,15 @@ public class FileTools } /** + * Load to string list. * * @param file + * the file + * @param charsetName + * the charset name + * @return the string list * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringList loadToStringList(final File file, final String charsetName) throws IOException { @@ -410,10 +460,13 @@ public class FileTools } /** + * Load to string list. * - * @param file - * @return + * @param source + * the source + * @return the string list * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringList loadToStringList(final URL source) throws IOException { @@ -426,9 +479,15 @@ public class FileTools } /** + * Load to string list. * - * @param file + * @param source + * the source + * @param charsetName + * the charset name + * @return the string list * @throws IOException + * Signals that an I/O exception has occurred. */ public static StringList loadToStringList(final URL source, final String charsetName) throws IOException { @@ -442,9 +501,16 @@ public class FileTools } /** + * Read. * - * @param file + * @param out + * the out + * @param is + * the is + * @param charsetName + * the charset name * @throws IOException + * Signals that an I/O exception has occurred. */ public static void read(final StringBuffer out, final InputStream is, final String charsetName) throws IOException { @@ -487,11 +553,11 @@ public class FileTools } /** + * Removes the extension. * * @param source - * @param extension - * @return - * + * the source + * @return the string * @deprecated See * org.apache.commons.io.FilenameUtils.removeExtension */ @@ -524,10 +590,16 @@ public class FileTools } /** + * Save. * * @param file - * @throws FileNotFoundException + * the file + * @param source + * the source * @throws UnsupportedEncodingException + * the unsupported encoding exception + * @throws FileNotFoundException + * the file not found exception */ public static void save(final File file, final String source) throws UnsupportedEncodingException, FileNotFoundException { @@ -548,10 +620,16 @@ public class FileTools } /** + * Save. * * @param file - * @throws FileNotFoundException + * the file + * @param source + * the source * @throws UnsupportedEncodingException + * the unsupported encoding exception + * @throws FileNotFoundException + * the file not found exception */ public static void save(final File file, final StringBuffer source) throws UnsupportedEncodingException, FileNotFoundException { @@ -559,10 +637,16 @@ public class FileTools } /** + * Save. * * @param file - * @throws FileNotFoundException + * the file + * @param source + * the source * @throws UnsupportedEncodingException + * the unsupported encoding exception + * @throws FileNotFoundException + * the file not found exception */ public static void save(final File file, final StringList source) throws UnsupportedEncodingException, FileNotFoundException { @@ -570,10 +654,13 @@ public class FileTools } /** + * Sets the extension. * * @param source + * the source * @param extension - * @return + * the extension + * @return the file */ public static File setExtension(final File source, final String extension) { @@ -593,10 +680,13 @@ public class FileTools } /** + * Sets the extension. * * @param source + * the source * @param extension - * @return + * the extension + * @return the string */ public static String setExtension(final String source, final String extension) { diff --git a/src/fr/devinsy/util/xml/XMLAttributes.java b/src/fr/devinsy/util/xml/XMLAttributes.java index 9e0c678..a3cf61f 100644 --- a/src/fr/devinsy/util/xml/XMLAttributes.java +++ b/src/fr/devinsy/util/xml/XMLAttributes.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -27,16 +27,17 @@ import java.util.Set; import javax.xml.stream.events.Attribute; /** + * The Class XMLAttributes. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ + public class XMLAttributes extends HashMap implements Iterable { - private static final long serialVersionUID = 8456469741805779474L; /** - * + * Instantiates a new XML attributes. */ public XMLAttributes() { @@ -44,7 +45,10 @@ public class XMLAttributes extends HashMap implements Iterabl } /** - * + * Instantiates a new XML attributes. + * + * @param capacity + * the capacity */ public XMLAttributes(final int capacity) { @@ -52,7 +56,10 @@ public class XMLAttributes extends HashMap implements Iterabl } /** - * + * Instantiates a new XML attributes. + * + * @param source + * the source */ public XMLAttributes(final Iterator source) { @@ -69,7 +76,10 @@ public class XMLAttributes extends HashMap implements Iterabl } /** - * + * Instantiates a new XML attributes. + * + * @param source + * the source */ public XMLAttributes(final XMLAttributes source) { @@ -78,8 +88,10 @@ public class XMLAttributes extends HashMap implements Iterabl } /** + * Adds the. * * @param attribute + * the attribute */ public void add(final Attribute attribute) { @@ -90,8 +102,10 @@ public class XMLAttributes extends HashMap implements Iterabl } /** + * Adds the all. * * @param source + * the source */ public void addAll(final XMLAttributes source) { @@ -102,9 +116,11 @@ public class XMLAttributes extends HashMap implements Iterabl } /** + * Gets the by label. * * @param label - * @return + * the label + * @return the by label */ public Attribute getByLabel(final String label) { @@ -116,8 +132,8 @@ public class XMLAttributes extends HashMap implements Iterabl return result; } - /** - * + /* (non-Javadoc) + * @see java.lang.Iterable#iterator() */ @Override public Iterator iterator() @@ -131,8 +147,9 @@ public class XMLAttributes extends HashMap implements Iterabl } /** + * Labels. * - * @return + * @return the sets the */ public Set labels() { @@ -145,8 +162,9 @@ public class XMLAttributes extends HashMap implements Iterabl } /** + * To list. * - * @return + * @return the list */ public List toList() { diff --git a/src/fr/devinsy/util/xml/XMLBadFormatException.java b/src/fr/devinsy/util/xml/XMLBadFormatException.java index d6b3e40..c434ce7 100644 --- a/src/fr/devinsy/util/xml/XMLBadFormatException.java +++ b/src/fr/devinsy/util/xml/XMLBadFormatException.java @@ -1,38 +1,39 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; import org.slf4j.helpers.MessageFormatter; /** + * The Class XMLBadFormatException. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ public class XMLBadFormatException extends Exception { - private static final long serialVersionUID = 768256303984176512L; /** + * Instantiates a new XML bad format exception. * - * @param code * @param message + * the message */ public XMLBadFormatException(final String message) { @@ -40,10 +41,12 @@ public class XMLBadFormatException extends Exception } /** + * Instantiates a new XML bad format exception. * - * @param code * @param message + * the message * @param exception + * the exception */ public XMLBadFormatException(final String message, final Exception exception) { @@ -51,9 +54,12 @@ public class XMLBadFormatException extends Exception } /** + * Instantiates a new XML bad format exception. * * @param format + * the format * @param arguments + * the arguments */ public XMLBadFormatException(final String format, final Object... arguments) { @@ -61,9 +67,12 @@ public class XMLBadFormatException extends Exception } /** + * Instantiates a new XML bad format exception. * * @param message + * the message * @param cause + * the cause */ public XMLBadFormatException(final String message, final Throwable cause) { @@ -71,8 +80,10 @@ public class XMLBadFormatException extends Exception } /** + * Instantiates a new XML bad format exception. * * @param cause + * the cause */ public XMLBadFormatException(final Throwable cause) { diff --git a/src/fr/devinsy/util/xml/XMLReader.java b/src/fr/devinsy/util/xml/XMLReader.java index 2dcd87d..541f032 100644 --- a/src/fr/devinsy/util/xml/XMLReader.java +++ b/src/fr/devinsy/util/xml/XMLReader.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -39,6 +39,7 @@ import fr.devinsy.util.strings.StringList; import fr.devinsy.util.xml.XMLTag.TagType; /** + * The Class XMLReader. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ @@ -50,7 +51,7 @@ public class XMLReader private XMLEvent nextEvent; /** - * + * Instantiates a new XML reader. */ protected XMLReader() { @@ -59,10 +60,14 @@ public class XMLReader } /** + * Instantiates a new XML reader. * * @param file - * @throws XMLStreamException + * the file * @throws FileNotFoundException + * the file not found exception + * @throws XMLStreamException + * the XML stream exception */ public XMLReader(final File file) throws FileNotFoundException, XMLStreamException { @@ -72,9 +77,12 @@ public class XMLReader } /** + * Instantiates a new XML reader. * - * @param target + * @param source + * the source * @throws XMLStreamException + * the XML stream exception */ public XMLReader(final InputStream source) throws XMLStreamException { @@ -84,9 +92,12 @@ public class XMLReader } /** + * Instantiates a new XML reader. * - * @param target + * @param source + * the source * @throws XMLStreamException + * the XML stream exception */ public XMLReader(final Reader source) throws XMLStreamException { @@ -96,7 +107,10 @@ public class XMLReader } /** + * Close. + * * @throws XMLStreamException + * the XML stream exception */ public void close() throws XMLStreamException { @@ -110,8 +124,10 @@ public class XMLReader * This methods does a premonition act. Useful to detect end of a list. * * @param label - * @return + * the label + * @return true, if successful * @throws XMLStreamException + * the XML stream exception */ public boolean hasNextStartTag(final String label) throws XMLStreamException { @@ -145,11 +161,15 @@ public class XMLReader } /** + * Read content tag. * * @param label - * @return + * the label + * @return the XML tag * @throws XMLBadFormatException + * the XML bad format exception * @throws XMLStreamException + * the XML stream exception */ public XMLTag readContentTag(final String label) throws XMLBadFormatException, XMLStreamException { @@ -177,11 +197,15 @@ public class XMLReader } /** + * Read end tag. * * @param label - * @return + * the label + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException + * the XML bad format exception */ public XMLTag readEndTag(final String label) throws XMLStreamException, XMLBadFormatException { @@ -209,12 +233,15 @@ public class XMLReader } /** + * Read list tag. * * @param label - * @return + * the label + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException - * @throws Exception + * the XML bad format exception */ public XMLTag readListTag(final String label) throws XMLStreamException, XMLBadFormatException { @@ -242,12 +269,15 @@ public class XMLReader } /** + * Read nullable content tag. * * @param label - * @return + * the label + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException - * @throws Exception + * the XML bad format exception */ public XMLTag readNullableContentTag(final String label) throws XMLStreamException, XMLBadFormatException { @@ -275,12 +305,15 @@ public class XMLReader } /** + * Read nullable start tag. * * @param label - * @return + * the label + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException - * @throws Exception + * the XML bad format exception */ public XMLTag readNullableStartTag(final String label) throws XMLStreamException, XMLBadFormatException { @@ -308,12 +341,15 @@ public class XMLReader } /** + * Read start tag. * * @param label - * @return + * the label + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException - * @throws Exception + * the XML bad format exception */ public XMLTag readStartTag(final String label) throws XMLStreamException, XMLBadFormatException { @@ -353,10 +389,13 @@ public class XMLReader *
  • END_ELEMENT(X) => => END TAG *
  • END_DOCUMENT => FOOTER TAG * + * . * + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException - * + * the XML bad format exception */ public XMLTag readTag() throws XMLStreamException, XMLBadFormatException { @@ -489,11 +528,13 @@ public class XMLReader } /** + * Read XML footer. * - * @param label - * @return + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException + * the XML bad format exception */ public XMLTag readXMLFooter() throws XMLStreamException, XMLBadFormatException { @@ -517,11 +558,13 @@ public class XMLReader } /** + * Read XML header. * - * @return - * @throws XMLException + * @return the XML tag * @throws XMLStreamException + * the XML stream exception * @throws XMLBadFormatException + * the XML bad format exception */ public XMLTag readXMLHeader() throws XMLStreamException, XMLBadFormatException { @@ -545,9 +588,12 @@ public class XMLReader } /** + * The main method. * * @param args + * the arguments * @throws Exception + * the exception */ public static void main(final String args[]) throws Exception { diff --git a/src/fr/devinsy/util/xml/XMLTag.java b/src/fr/devinsy/util/xml/XMLTag.java index 7721ee7..caceddd 100644 --- a/src/fr/devinsy/util/xml/XMLTag.java +++ b/src/fr/devinsy/util/xml/XMLTag.java @@ -1,32 +1,32 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; import javax.xml.namespace.QName; /** + * The Class XMLTag. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ public class XMLTag { - public enum TagType { HEADER, @@ -43,7 +43,14 @@ public class XMLTag private String content; /** + * Instantiates a new XML tag. * + * @param name + * the name + * @param type + * the type + * @param attributes + * the attributes */ public XMLTag(final QName name, final TagType type, final XMLAttributes attributes) { @@ -53,19 +60,30 @@ public class XMLTag this.content = null; } + /** + * Attributes. + * + * @return the XML attributes + */ public XMLAttributes attributes() { return this.attributes; } + /** + * Gets the content. + * + * @return the content + */ public String getContent() { return this.content; } /** + * Gets the label. * - * @return + * @return the label */ public String getLabel() { @@ -84,14 +102,20 @@ public class XMLTag return result; } + /** + * Gets the name. + * + * @return the name + */ public QName getName() { return this.name; } /** + * Gets the namespace URI. * - * @return + * @return the namespace URI */ public String getNamespaceURI() { @@ -111,8 +135,9 @@ public class XMLTag } /** + * Gets the prefix. * - * @return + * @return the prefix */ public String getPrefix() { @@ -131,21 +156,44 @@ public class XMLTag return result; } + /** + * Gets the type. + * + * @return the type + */ public TagType getType() { return this.type; } + /** + * Sets the content. + * + * @param content + * the new content + */ public void setContent(final String content) { this.content = content; } + /** + * Sets the name. + * + * @param name + * the new name + */ public void setName(final QName name) { this.name = name; } + /** + * Sets the type. + * + * @param type + * the new type + */ public void setType(final TagType type) { this.type = type; diff --git a/src/fr/devinsy/util/xml/XMLTools.java b/src/fr/devinsy/util/xml/XMLTools.java index e3bf573..003975d 100644 --- a/src/fr/devinsy/util/xml/XMLTools.java +++ b/src/fr/devinsy/util/xml/XMLTools.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -40,15 +40,18 @@ import org.xml.sax.InputSource; import org.xml.sax.SAXException; /** + * The Class XMLTools. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ public class XMLTools { /** + * Escape xml blank. * * @param source - * @return + * the source + * @return the string */ public static String escapeXmlBlank(final String source) { @@ -68,12 +71,17 @@ public class XMLTools } /** + * Checks if is valid. * - * - * @param source + * @param xmlFile + * the xml file + * @param xsdFile + * the xsd file + * @return true, if is valid * @throws SAXException + * the SAX exception * @throws IOException - * @throws PuckException + * Signals that an I/O exception has occurred. */ public static boolean isValid(final File xmlFile, final File xsdFile) throws SAXException, IOException { @@ -100,12 +108,17 @@ public class XMLTools } /** + * Checks if is valid. * - * - * @param source + * @param xmlFile + * the xml file + * @param xsdSource + * the xsd source + * @return true, if is valid * @throws SAXException + * the SAX exception * @throws IOException - * @throws PuckException + * Signals that an I/O exception has occurred. */ public static boolean isValid(final File xmlFile, final InputStream xsdSource) throws SAXException, IOException { @@ -132,12 +145,17 @@ public class XMLTools } /** + * Checks if is valid. * - * - * @param source + * @param xmlSource + * the xml source + * @param xsdSource + * the xsd source + * @return true, if is valid * @throws SAXException + * the SAX exception * @throws IOException - * @throws PuckException + * Signals that an I/O exception has occurred. */ public static boolean isValid(final InputStream xmlSource, final InputStream xsdSource) throws SAXException, IOException { @@ -175,10 +193,13 @@ public class XMLTools } /** + * Checks if is zip file. * * @param file - * @return + * the file + * @return true, if is zip file * @throws IOException + * Signals that an I/O exception has occurred. */ public static boolean isZipFile(final File file) throws IOException { @@ -215,7 +236,13 @@ public class XMLTools } /** - * + * Read tag. + * + * @param in + * the in + * @return the string + * @throws Exception + * the exception */ public static String readTag(final BufferedReader in) throws Exception { @@ -253,13 +280,15 @@ public class XMLTools } // - return (result); + return result; } /** + * To HTLM 5. * * @param source - * @return + * the source + * @return the string */ public static String toHTLM5(final String source) { @@ -279,9 +308,11 @@ public class XMLTools } /** + * To string. * - * @param value - * @return + * @param source + * the source + * @return the string */ public static String toString(final XMLEvent source) { @@ -344,9 +375,11 @@ public class XMLTools } /** + * To string. * - * @param event - * @return + * @param source + * the source + * @return the string */ public static String toString(final XMLTag source) { @@ -366,9 +399,11 @@ public class XMLTools } /** + * Unescape xml blank. * * @param source - * @return + * the source + * @return the string */ public static String unescapeXmlBlank(final String source) { diff --git a/src/fr/devinsy/util/xml/XMLWriter.java b/src/fr/devinsy/util/xml/XMLWriter.java index a44ba02..192cb0c 100644 --- a/src/fr/devinsy/util/xml/XMLWriter.java +++ b/src/fr/devinsy/util/xml/XMLWriter.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -31,12 +31,13 @@ import java.io.Writer; import org.apache.commons.lang3.ArrayUtils; /** + * The Class XMLWriter. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ + public class XMLWriter { - protected PrintWriter out; /** @@ -52,9 +53,10 @@ public class XMLWriter * * @param file * Where write the XML data. - * - * @throws FileNotFoundException * @throws UnsupportedEncodingException + * the unsupported encoding exception + * @throws FileNotFoundException + * the file not found exception */ public XMLWriter(final File file) throws UnsupportedEncodingException, FileNotFoundException { @@ -66,8 +68,8 @@ public class XMLWriter * * @param target * Where write the XML data. - * * @throws UnsupportedEncodingException + * the unsupported encoding exception */ public XMLWriter(final OutputStream target) throws UnsupportedEncodingException { @@ -79,8 +81,8 @@ public class XMLWriter * * @param target * Where write the XML data. - * * @throws UnsupportedEncodingException + * the unsupported encoding exception */ public XMLWriter(final Writer target) throws UnsupportedEncodingException { @@ -89,6 +91,9 @@ public class XMLWriter /** * This method closes the target stream. + * + * @throws IOException + * Signals that an I/O exception has occurred. */ public void close() throws IOException { @@ -101,6 +106,9 @@ public class XMLWriter /** * This method flushes the target stream. + * + * @throws IOException + * Signals that an I/O exception has occurred. */ public void flush() throws IOException { @@ -128,6 +136,11 @@ public class XMLWriter /** * This method writes a XML tag with no content. + * + * @param label + * the label + * @param attributes + * the attributes */ public void writeEmptyTag(final String label, final String... attributes) { @@ -139,6 +152,9 @@ public class XMLWriter /** * This method writes a XML ender tag. + * + * @param label + * the label */ public void writeEndTag(final String label) { @@ -149,6 +165,11 @@ public class XMLWriter /** * This method writes a XML start tag. + * + * @param label + * the label + * @param attributes + * the attributes */ public void writeStartTag(final String label, final String... attributes) { @@ -162,8 +183,11 @@ public class XMLWriter * This method write a XML tag with attributes and boolean content data. * * @param label + * the label * @param content + * the content * @param attributes + * the attributes */ public void writeTag(final String label, final boolean content, final String... attributes) { @@ -176,8 +200,11 @@ public class XMLWriter * This method write a XML tag with attributes and long content data. * * @param label + * the label * @param content + * the content * @param attributes + * the attributes */ public void writeTag(final String label, final long content, final String... attributes) { @@ -191,8 +218,11 @@ public class XMLWriter * data are converted in XML format. * * @param label + * the label * @param content + * the content * @param attributes + * the attributes */ public void writeTag(final String label, final String content, final String... attributes) { @@ -212,10 +242,10 @@ public class XMLWriter * This method writes attributes of a tag. * * @param attributes + * the attributes */ private void writeTagAttributes(final String... attributes) { - // if ((attributes != null) && (attributes.length > 0)) { for (int count = 0; count < attributes.length; count += 2) @@ -237,10 +267,8 @@ public class XMLWriter */ private void writeTagContent(final String content) { - // for (int count = 0; count < content.length(); count++) { - // char car = content.charAt(count); switch (car) @@ -270,6 +298,7 @@ public class XMLWriter * This method writes a XML header with attributes. * * @param attributes + * the attributes */ public void writeXMLHeader(final String... attributes) { diff --git a/src/fr/devinsy/util/xml/XMLZipReader.java b/src/fr/devinsy/util/xml/XMLZipReader.java index 14cbe36..6c48d5e 100644 --- a/src/fr/devinsy/util/xml/XMLZipReader.java +++ b/src/fr/devinsy/util/xml/XMLZipReader.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -28,6 +28,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLStreamException; /** + * The Class XMLZipReader. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ @@ -35,10 +36,14 @@ public class XMLZipReader extends XMLReader { /** + * Instantiates a new XML zip reader. * * @param file + * the file * @throws IOException + * Signals that an I/O exception has occurred. * @throws XMLStreamException + * the XML stream exception */ public XMLZipReader(final File file) throws IOException, XMLStreamException { @@ -51,10 +56,14 @@ public class XMLZipReader extends XMLReader } /** + * Instantiates a new XML zip reader. * - * @param target + * @param source + * the source * @throws IOException + * Signals that an I/O exception has occurred. * @throws XMLStreamException + * the XML stream exception */ public XMLZipReader(final InputStream source) throws IOException, XMLStreamException { diff --git a/src/fr/devinsy/util/xml/XMLZipWriter.java b/src/fr/devinsy/util/xml/XMLZipWriter.java index 7cde068..63e4ac8 100644 --- a/src/fr/devinsy/util/xml/XMLZipWriter.java +++ b/src/fr/devinsy/util/xml/XMLZipWriter.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2013-2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -31,6 +31,7 @@ import java.util.zip.ZipOutputStream; import fr.devinsy.util.FileTools; /** + * The Class XMLZipWriter. * * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ @@ -39,9 +40,12 @@ public class XMLZipWriter extends XMLWriter private ZipOutputStream zos; /** + * Instantiates a new XML zip writer. * * @param file + * the file * @throws IOException + * Signals that an I/O exception has occurred. */ public XMLZipWriter(final File file) throws IOException { @@ -56,9 +60,14 @@ public class XMLZipWriter extends XMLWriter } /** + * Instantiates a new XML zip writer. * * @param file + * the file + * @param generator + * the generator * @throws IOException + * Signals that an I/O exception has occurred. */ public XMLZipWriter(final File file, final String generator) throws IOException { @@ -73,9 +82,14 @@ public class XMLZipWriter extends XMLWriter } /** + * Instantiates a new XML zip writer. * * @param target + * the target + * @param generator + * the generator * @throws IOException + * Signals that an I/O exception has occurred. */ public XMLZipWriter(final OutputStream target, final String generator) throws IOException { @@ -91,9 +105,16 @@ public class XMLZipWriter extends XMLWriter } /** + * Instantiates a new XML zip writer. * * @param target + * the target + * @param fileName + * the file name + * @param generator + * the generator * @throws IOException + * Signals that an I/O exception has occurred. */ public XMLZipWriter(final OutputStream target, final String fileName, final String generator) throws IOException { @@ -110,8 +131,10 @@ public class XMLZipWriter extends XMLWriter } /** - * @throws IOException + * Close. * + * @throws IOException + * Signals that an I/O exception has occurred. */ @Override public void close() throws IOException @@ -121,8 +144,10 @@ public class XMLZipWriter extends XMLWriter } /** - * @throws IOException + * Close entry. * + * @throws IOException + * Signals that an I/O exception has occurred. */ public void closeEntry() throws IOException { @@ -131,9 +156,12 @@ public class XMLZipWriter extends XMLWriter } /** + * Open entry. * * @param fileName + * the file name * @throws IOException + * Signals that an I/O exception has occurred. */ public void openEntry(final String fileName) throws IOException { diff --git a/test/fr/devinsy/util/FileToolsTest.java b/test/fr/devinsy/util/FileToolsTest.java index 8c190ef..d7e3826 100644 --- a/test/fr/devinsy/util/FileToolsTest.java +++ b/test/fr/devinsy/util/FileToolsTest.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util; @@ -30,15 +30,16 @@ import org.junit.Test; import fr.devinsy.util.strings.StringList; /** + * The Class FileToolsTest. * - * @author Christian P. Momon + * @author Christian Pierre MOMON (christian.momon@devinsy.fr) */ public class FileToolsTest { - static protected org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FileToolsTest.class); + public final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(FileToolsTest.class); /** - * + * Before. */ @Before public void before() @@ -48,13 +49,16 @@ public class FileToolsTest } /** - * - */ + * Load to string list URL 01. + * + * @throws IOException + * Signals that an I/O exception has occurred. + */ @Test public void loadToStringListURL01() throws IOException { // - logger.debug("===== test starting..."); + this.logger.debug("===== test starting..."); // StringList source = FileTools.loadToStringList(FileTools.class.getResource("/fr/devinsy/util/lines.txt")); @@ -63,18 +67,17 @@ public class FileToolsTest Assert.assertEquals("trois", source.get(3 - 1)); // - logger.debug("===== test done."); + this.logger.debug("===== test done."); } /** - * @throws IOException - * + * Test get extension. */ @Test public void testGetExtension() { // - logger.debug("===== test starting..."); + this.logger.debug("===== test starting..."); // String extension = FileTools.getExtension("test.ext"); @@ -83,6 +86,6 @@ public class FileToolsTest Assert.assertEquals(extension, "ext"); // - logger.debug("===== test done."); + this.logger.debug("===== test done."); } } diff --git a/test/fr/devinsy/util/xml/XMLReaderTest.java b/test/fr/devinsy/util/xml/XMLReaderTest.java index 13f4529..55c7f5a 100644 --- a/test/fr/devinsy/util/xml/XMLReaderTest.java +++ b/test/fr/devinsy/util/xml/XMLReaderTest.java @@ -1,20 +1,20 @@ -/** +/* * Copyright (C) 2014,2017 Christian Pierre MOMON * - * This file is part of Devinsy-strings. + * This file is part of Devinsy-xml. * - * Devinsy-strings is free software: you can redistribute it and/or modify + * Devinsy-xml is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * - * Devinsy-strings is distributed in the hope that it will be useful, + * Devinsy-xml is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License - * along with Devinsy-strings. If not, see + * along with Devinsy-xml. If not, see */ package fr.devinsy.util.xml; @@ -31,15 +31,16 @@ import org.junit.Before; import fr.devinsy.util.strings.StringList; /** + * The Class XMLReaderTest. * * @author Christian P. Momon */ public class XMLReaderTest { - static private org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(XMLReaderTest.class); + private final org.apache.log4j.Logger logger = org.apache.log4j.Logger.getLogger(XMLReaderTest.class); /** - * + * Before. */ @Before public void before() @@ -49,16 +50,20 @@ public class XMLReaderTest } /** - * @throws XMLStreamException - * @throws FileNotFoundException - * @throws XMLBadFormatException + * Test foo 01. * + * @throws FileNotFoundException + * the file not found exception + * @throws XMLStreamException + * the XML stream exception + * @throws XMLBadFormatException + * the XML bad format exception */ // @Test public void testFoo01() throws FileNotFoundException, XMLStreamException, XMLBadFormatException { // - logger.debug("===== test starting..."); + this.logger.debug("===== test starting..."); // XMLReader in = new XMLReader(new // File("/home/cpm/C/Puck/TY/Ebrei 08.puc")); @@ -81,22 +86,26 @@ public class XMLReaderTest } // - logger.debug("===== test done."); + this.logger.debug("===== test done."); } System.out.println("over"); } /** - * @throws XMLStreamException - * @throws FileNotFoundException - * @throws XMLBadFormatException + * Test foo 02. * + * @throws FileNotFoundException + * the file not found exception + * @throws XMLStreamException + * the XML stream exception + * @throws XMLBadFormatException + * the XML bad format exception */ // @Test public void testFoo02() throws FileNotFoundException, XMLStreamException, XMLBadFormatException { // - logger.debug("===== test starting..."); + this.logger.debug("===== test starting..."); // XMLReader in = new XMLReader(new // File("/home/cpm/C/Puck/TY/Ebrei 08.puc")); @@ -123,9 +132,8 @@ public class XMLReaderTest } // - logger.debug("===== test done."); + this.logger.debug("===== test done."); } System.out.println("over"); } - }