Performed code review and Javadoc review.

This commit is contained in:
Christian P. MOMON 2017-05-04 22:51:02 +02:00
parent 95fd884791
commit 3c87ba3f6d
11 changed files with 499 additions and 174 deletions

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2008-2015,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util; package fr.devinsy.util;
@ -35,6 +35,7 @@ import fr.devinsy.util.strings.StringList;
import fr.devinsy.util.strings.StringListUtils; import fr.devinsy.util.strings.StringListUtils;
/** /**
* The Class FileTools.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
@ -43,11 +44,12 @@ public class FileTools
public static final String DEFAULT_CHARSET_NAME = "UTF-8"; public static final String DEFAULT_CHARSET_NAME = "UTF-8";
/** /**
* * Adds the before extension.
* *
* @param fileName * @param fileName
* Source. * Source.
* * @param addition
* the addition
* @return Extension value or null. * @return Extension value or null.
*/ */
public static String addBeforeExtension(final String fileName, final String addition) public static String addBeforeExtension(final String fileName, final String addition)
@ -83,11 +85,12 @@ public class FileTools
} }
/** /**
* * Adds the to name.
* *
* @param file * @param file
* Source. * Source.
* * @param addition
* the addition
* @return Extension value or null. * @return Extension value or null.
*/ */
public static File addToName(final File file, final String addition) public static File addToName(final File file, final String addition)
@ -149,9 +152,8 @@ public class FileTools
* <li>getExtension("abc.efg") = "efg"</li> * <li>getExtension("abc.efg") = "efg"</li>
* </ul> * </ul>
* *
* @param file * @param fileName
* Source. * the file name
*
* @return Extension value or null. * @return Extension value or null.
* @deprecated See * @deprecated See
* <code>org.apache.commons.io.FilenameUtils.getExtension</code> * <code>org.apache.commons.io.FilenameUtils.getExtension</code>
@ -183,10 +185,13 @@ public class FileTools
} }
/** /**
* Load.
* *
* @param file * @param source
* @return * the source
* @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final File source) throws IOException 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 * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final File source, final String charsetName) throws IOException public static String load(final File source, final String charsetName) throws IOException
{ {
@ -214,10 +225,13 @@ public class FileTools
} }
/** /**
* Load.
* *
* @param file * @param source
* @return * the source
* @return the string
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final URL source) throws IOException 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 * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static String load(final URL source, final String charsetName) throws IOException 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 * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadStringList(final File source) throws IOException public static StringList loadStringList(final File source) throws IOException
{ {
@ -265,9 +289,15 @@ public class FileTools
} }
/** /**
* Load string list.
* *
* @param file * @param file
* the file
* @param charsetName
* the charset name
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadStringList(final File file, final String charsetName) throws IOException 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 * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringBuffer loadToStringBuffer(final File source) throws IOException public static StringBuffer loadToStringBuffer(final File source) throws IOException
{ {
@ -295,9 +329,15 @@ public class FileTools
} }
/** /**
* Load to string buffer.
* *
* @param file * @param file
* the file
* @param charsetName
* the charset name
* @return the string buffer
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringBuffer loadToStringBuffer(final File file, final String charsetName) throws IOException 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 * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final File source) throws IOException public static StringList loadToStringList(final File source) throws IOException
{ {
@ -360,9 +404,15 @@ public class FileTools
} }
/** /**
* Load to string list.
* *
* @param file * @param file
* the file
* @param charsetName
* the charset name
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final File file, final String charsetName) throws IOException 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 * @param source
* @return * the source
* @return the string list
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final URL source) throws IOException 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 * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static StringList loadToStringList(final URL source, final String charsetName) throws IOException 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 * @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 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 source
* @param extension * the source
* @return * @return the string
*
* @deprecated See * @deprecated See
* <code>org.apache.commons.io.FilenameUtils.removeExtension</code> * <code>org.apache.commons.io.FilenameUtils.removeExtension</code>
*/ */
@ -524,10 +590,16 @@ public class FileTools
} }
/** /**
* Save.
* *
* @param file * @param file
* @throws FileNotFoundException * the file
* @param source
* the source
* @throws UnsupportedEncodingException * @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 public static void save(final File file, final String source) throws UnsupportedEncodingException, FileNotFoundException
{ {
@ -548,10 +620,16 @@ public class FileTools
} }
/** /**
* Save.
* *
* @param file * @param file
* @throws FileNotFoundException * the file
* @param source
* the source
* @throws UnsupportedEncodingException * @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 public static void save(final File file, final StringBuffer source) throws UnsupportedEncodingException, FileNotFoundException
{ {
@ -559,10 +637,16 @@ public class FileTools
} }
/** /**
* Save.
* *
* @param file * @param file
* @throws FileNotFoundException * the file
* @param source
* the source
* @throws UnsupportedEncodingException * @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 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 * @param source
* the source
* @param extension * @param extension
* @return * the extension
* @return the file
*/ */
public static File setExtension(final File source, final String extension) public static File setExtension(final File source, final String extension)
{ {
@ -593,10 +680,13 @@ public class FileTools
} }
/** /**
* Sets the extension.
* *
* @param source * @param source
* the source
* @param extension * @param extension
* @return * the extension
* @return the string
*/ */
public static String setExtension(final String source, final String extension) public static String setExtension(final String source, final String extension)
{ {

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -27,16 +27,17 @@ import java.util.Set;
import javax.xml.stream.events.Attribute; import javax.xml.stream.events.Attribute;
/** /**
* The Class XMLAttributes.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class XMLAttributes extends HashMap<String, Attribute> implements Iterable<Attribute> public class XMLAttributes extends HashMap<String, Attribute> implements Iterable<Attribute>
{ {
private static final long serialVersionUID = 8456469741805779474L; private static final long serialVersionUID = 8456469741805779474L;
/** /**
* * Instantiates a new XML attributes.
*/ */
public XMLAttributes() public XMLAttributes()
{ {
@ -44,7 +45,10 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Instantiates a new XML attributes.
* *
* @param capacity
* the capacity
*/ */
public XMLAttributes(final int capacity) public XMLAttributes(final int capacity)
{ {
@ -52,7 +56,10 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Instantiates a new XML attributes.
* *
* @param source
* the source
*/ */
public XMLAttributes(final Iterator<Attribute> source) public XMLAttributes(final Iterator<Attribute> source)
{ {
@ -69,7 +76,10 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Instantiates a new XML attributes.
* *
* @param source
* the source
*/ */
public XMLAttributes(final XMLAttributes source) public XMLAttributes(final XMLAttributes source)
{ {
@ -78,8 +88,10 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Adds the.
* *
* @param attribute * @param attribute
* the attribute
*/ */
public void add(final Attribute attribute) public void add(final Attribute attribute)
{ {
@ -90,8 +102,10 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Adds the all.
* *
* @param source * @param source
* the source
*/ */
public void addAll(final XMLAttributes source) public void addAll(final XMLAttributes source)
{ {
@ -102,9 +116,11 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Gets the by label.
* *
* @param label * @param label
* @return * the label
* @return the by label
*/ */
public Attribute getByLabel(final String label) public Attribute getByLabel(final String label)
{ {
@ -116,8 +132,8 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
return result; return result;
} }
/** /* (non-Javadoc)
* * @see java.lang.Iterable#iterator()
*/ */
@Override @Override
public Iterator<Attribute> iterator() public Iterator<Attribute> iterator()
@ -131,8 +147,9 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* Labels.
* *
* @return * @return the sets the
*/ */
public Set<String> labels() public Set<String> labels()
{ {
@ -145,8 +162,9 @@ public class XMLAttributes extends HashMap<String, Attribute> implements Iterabl
} }
/** /**
* To list.
* *
* @return * @return the list
*/ */
public List<Attribute> toList() public List<Attribute> toList()
{ {

View file

@ -1,38 +1,39 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
import org.slf4j.helpers.MessageFormatter; import org.slf4j.helpers.MessageFormatter;
/** /**
* The Class XMLBadFormatException.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class XMLBadFormatException extends Exception public class XMLBadFormatException extends Exception
{ {
private static final long serialVersionUID = 768256303984176512L; private static final long serialVersionUID = 768256303984176512L;
/** /**
* Instantiates a new XML bad format exception.
* *
* @param code
* @param message * @param message
* the message
*/ */
public XMLBadFormatException(final String 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 * @param message
* the message
* @param exception * @param exception
* the exception
*/ */
public XMLBadFormatException(final String message, final Exception 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 * @param format
* the format
* @param arguments * @param arguments
* the arguments
*/ */
public XMLBadFormatException(final String format, final Object... 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 * @param message
* the message
* @param cause * @param cause
* the cause
*/ */
public XMLBadFormatException(final String message, final Throwable 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 * @param cause
* the cause
*/ */
public XMLBadFormatException(final Throwable cause) public XMLBadFormatException(final Throwable cause)
{ {

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -39,6 +39,7 @@ import fr.devinsy.util.strings.StringList;
import fr.devinsy.util.xml.XMLTag.TagType; import fr.devinsy.util.xml.XMLTag.TagType;
/** /**
* The Class XMLReader.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
@ -50,7 +51,7 @@ public class XMLReader
private XMLEvent nextEvent; private XMLEvent nextEvent;
/** /**
* * Instantiates a new XML reader.
*/ */
protected XMLReader() protected XMLReader()
{ {
@ -59,10 +60,14 @@ public class XMLReader
} }
/** /**
* Instantiates a new XML reader.
* *
* @param file * @param file
* @throws XMLStreamException * the file
* @throws FileNotFoundException * @throws FileNotFoundException
* the file not found exception
* @throws XMLStreamException
* the XML stream exception
*/ */
public XMLReader(final File file) throws FileNotFoundException, XMLStreamException 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 * @throws XMLStreamException
* the XML stream exception
*/ */
public XMLReader(final InputStream source) throws XMLStreamException 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 * @throws XMLStreamException
* the XML stream exception
*/ */
public XMLReader(final Reader source) throws XMLStreamException public XMLReader(final Reader source) throws XMLStreamException
{ {
@ -96,7 +107,10 @@ public class XMLReader
} }
/** /**
* Close.
*
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
*/ */
public void close() throws XMLStreamException 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. * This methods does a premonition act. Useful to detect end of a list.
* *
* @param label * @param label
* @return * the label
* @return true, if successful
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
*/ */
public boolean hasNextStartTag(final String label) throws XMLStreamException public boolean hasNextStartTag(final String label) throws XMLStreamException
{ {
@ -145,11 +161,15 @@ public class XMLReader
} }
/** /**
* Read content tag.
* *
* @param label * @param label
* @return * the label
* @return the XML tag
* @throws XMLBadFormatException * @throws XMLBadFormatException
* the XML bad format exception
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
*/ */
public XMLTag readContentTag(final String label) throws XMLBadFormatException, XMLStreamException public XMLTag readContentTag(final String label) throws XMLBadFormatException, XMLStreamException
{ {
@ -177,11 +197,15 @@ public class XMLReader
} }
/** /**
* Read end tag.
* *
* @param label * @param label
* @return * the label
* @return the XML tag
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* the XML bad format exception
*/ */
public XMLTag readEndTag(final String label) throws XMLStreamException, XMLBadFormatException public XMLTag readEndTag(final String label) throws XMLStreamException, XMLBadFormatException
{ {
@ -209,12 +233,15 @@ public class XMLReader
} }
/** /**
* Read list tag.
* *
* @param label * @param label
* @return * the label
* @return the XML tag
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* @throws Exception * the XML bad format exception
*/ */
public XMLTag readListTag(final String label) throws XMLStreamException, XMLBadFormatException public XMLTag readListTag(final String label) throws XMLStreamException, XMLBadFormatException
{ {
@ -242,12 +269,15 @@ public class XMLReader
} }
/** /**
* Read nullable content tag.
* *
* @param label * @param label
* @return * the label
* @return the XML tag
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* @throws Exception * the XML bad format exception
*/ */
public XMLTag readNullableContentTag(final String label) throws XMLStreamException, XMLBadFormatException public XMLTag readNullableContentTag(final String label) throws XMLStreamException, XMLBadFormatException
{ {
@ -275,12 +305,15 @@ public class XMLReader
} }
/** /**
* Read nullable start tag.
* *
* @param label * @param label
* @return * the label
* @return the XML tag
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* @throws Exception * the XML bad format exception
*/ */
public XMLTag readNullableStartTag(final String label) throws XMLStreamException, XMLBadFormatException public XMLTag readNullableStartTag(final String label) throws XMLStreamException, XMLBadFormatException
{ {
@ -308,12 +341,15 @@ public class XMLReader
} }
/** /**
* Read start tag.
* *
* @param label * @param label
* @return * the label
* @return the XML tag
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* @throws Exception * the XML bad format exception
*/ */
public XMLTag readStartTag(final String label) throws XMLStreamException, XMLBadFormatException public XMLTag readStartTag(final String label) throws XMLStreamException, XMLBadFormatException
{ {
@ -353,10 +389,13 @@ public class XMLReader
* <li>END_ELEMENT(X) => </X> => END TAG * <li>END_ELEMENT(X) => </X> => END TAG
* <li>END_DOCUMENT => FOOTER TAG * <li>END_DOCUMENT => FOOTER TAG
* </ul> * </ul>
* .
* *
* @return the XML tag
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* * the XML bad format exception
*/ */
public XMLTag readTag() throws XMLStreamException, XMLBadFormatException public XMLTag readTag() throws XMLStreamException, XMLBadFormatException
{ {
@ -489,11 +528,13 @@ public class XMLReader
} }
/** /**
* Read XML footer.
* *
* @param label * @return the XML tag
* @return
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* the XML bad format exception
*/ */
public XMLTag readXMLFooter() throws XMLStreamException, XMLBadFormatException public XMLTag readXMLFooter() throws XMLStreamException, XMLBadFormatException
{ {
@ -517,11 +558,13 @@ public class XMLReader
} }
/** /**
* Read XML header.
* *
* @return * @return the XML tag
* @throws XMLException
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException * @throws XMLBadFormatException
* the XML bad format exception
*/ */
public XMLTag readXMLHeader() throws XMLStreamException, XMLBadFormatException public XMLTag readXMLHeader() throws XMLStreamException, XMLBadFormatException
{ {
@ -545,9 +588,12 @@ public class XMLReader
} }
/** /**
* The main method.
* *
* @param args * @param args
* the arguments
* @throws Exception * @throws Exception
* the exception
*/ */
public static void main(final String args[]) throws Exception public static void main(final String args[]) throws Exception
{ {

View file

@ -1,32 +1,32 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
import javax.xml.namespace.QName; import javax.xml.namespace.QName;
/** /**
* The Class XMLTag.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class XMLTag public class XMLTag
{ {
public enum TagType public enum TagType
{ {
HEADER, HEADER,
@ -43,7 +43,14 @@ public class XMLTag
private String content; 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) public XMLTag(final QName name, final TagType type, final XMLAttributes attributes)
{ {
@ -53,19 +60,30 @@ public class XMLTag
this.content = null; this.content = null;
} }
/**
* Attributes.
*
* @return the XML attributes
*/
public XMLAttributes attributes() public XMLAttributes attributes()
{ {
return this.attributes; return this.attributes;
} }
/**
* Gets the content.
*
* @return the content
*/
public String getContent() public String getContent()
{ {
return this.content; return this.content;
} }
/** /**
* Gets the label.
* *
* @return * @return the label
*/ */
public String getLabel() public String getLabel()
{ {
@ -84,14 +102,20 @@ public class XMLTag
return result; return result;
} }
/**
* Gets the name.
*
* @return the name
*/
public QName getName() public QName getName()
{ {
return this.name; return this.name;
} }
/** /**
* Gets the namespace URI.
* *
* @return * @return the namespace URI
*/ */
public String getNamespaceURI() public String getNamespaceURI()
{ {
@ -111,8 +135,9 @@ public class XMLTag
} }
/** /**
* Gets the prefix.
* *
* @return * @return the prefix
*/ */
public String getPrefix() public String getPrefix()
{ {
@ -131,21 +156,44 @@ public class XMLTag
return result; return result;
} }
/**
* Gets the type.
*
* @return the type
*/
public TagType getType() public TagType getType()
{ {
return this.type; return this.type;
} }
/**
* Sets the content.
*
* @param content
* the new content
*/
public void setContent(final String content) public void setContent(final String content)
{ {
this.content = content; this.content = content;
} }
/**
* Sets the name.
*
* @param name
* the new name
*/
public void setName(final QName name) public void setName(final QName name)
{ {
this.name = name; this.name = name;
} }
/**
* Sets the type.
*
* @param type
* the new type
*/
public void setType(final TagType type) public void setType(final TagType type)
{ {
this.type = type; this.type = type;

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -40,15 +40,18 @@ import org.xml.sax.InputSource;
import org.xml.sax.SAXException; import org.xml.sax.SAXException;
/** /**
* The Class XMLTools.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class XMLTools public class XMLTools
{ {
/** /**
* Escape xml blank.
* *
* @param source * @param source
* @return * the source
* @return the string
*/ */
public static String escapeXmlBlank(final String source) public static String escapeXmlBlank(final String source)
{ {
@ -68,12 +71,17 @@ public class XMLTools
} }
/** /**
* Checks if is valid.
* *
* * @param xmlFile
* @param source * the xml file
* @param xsdFile
* the xsd file
* @return true, if is valid
* @throws SAXException * @throws SAXException
* the SAX exception
* @throws IOException * @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 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 xmlFile
* @param source * the xml file
* @param xsdSource
* the xsd source
* @return true, if is valid
* @throws SAXException * @throws SAXException
* the SAX exception
* @throws IOException * @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 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 xmlSource
* @param source * the xml source
* @param xsdSource
* the xsd source
* @return true, if is valid
* @throws SAXException * @throws SAXException
* the SAX exception
* @throws IOException * @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 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 * @param file
* @return * the file
* @return true, if is zip file
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public static boolean isZipFile(final File file) throws IOException 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 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 * @param source
* @return * the source
* @return the string
*/ */
public static String toHTLM5(final String source) public static String toHTLM5(final String source)
{ {
@ -279,9 +308,11 @@ public class XMLTools
} }
/** /**
* To string.
* *
* @param value * @param source
* @return * the source
* @return the string
*/ */
public static String toString(final XMLEvent source) public static String toString(final XMLEvent source)
{ {
@ -344,9 +375,11 @@ public class XMLTools
} }
/** /**
* To string.
* *
* @param event * @param source
* @return * the source
* @return the string
*/ */
public static String toString(final XMLTag source) public static String toString(final XMLTag source)
{ {
@ -366,9 +399,11 @@ public class XMLTools
} }
/** /**
* Unescape xml blank.
* *
* @param source * @param source
* @return * the source
* @return the string
*/ */
public static String unescapeXmlBlank(final String source) public static String unescapeXmlBlank(final String source)
{ {

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -31,12 +31,13 @@ import java.io.Writer;
import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.ArrayUtils;
/** /**
* The Class XMLWriter.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class XMLWriter public class XMLWriter
{ {
protected PrintWriter out; protected PrintWriter out;
/** /**
@ -52,9 +53,10 @@ public class XMLWriter
* *
* @param file * @param file
* Where write the XML data. * Where write the XML data.
*
* @throws FileNotFoundException
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* the unsupported encoding exception
* @throws FileNotFoundException
* the file not found exception
*/ */
public XMLWriter(final File file) throws UnsupportedEncodingException, FileNotFoundException public XMLWriter(final File file) throws UnsupportedEncodingException, FileNotFoundException
{ {
@ -66,8 +68,8 @@ public class XMLWriter
* *
* @param target * @param target
* Where write the XML data. * Where write the XML data.
*
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* the unsupported encoding exception
*/ */
public XMLWriter(final OutputStream target) throws UnsupportedEncodingException public XMLWriter(final OutputStream target) throws UnsupportedEncodingException
{ {
@ -79,8 +81,8 @@ public class XMLWriter
* *
* @param target * @param target
* Where write the XML data. * Where write the XML data.
*
* @throws UnsupportedEncodingException * @throws UnsupportedEncodingException
* the unsupported encoding exception
*/ */
public XMLWriter(final Writer target) throws UnsupportedEncodingException public XMLWriter(final Writer target) throws UnsupportedEncodingException
{ {
@ -89,6 +91,9 @@ public class XMLWriter
/** /**
* This method closes the target stream. * This method closes the target stream.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public void close() throws IOException public void close() throws IOException
{ {
@ -101,6 +106,9 @@ public class XMLWriter
/** /**
* This method flushes the target stream. * This method flushes the target stream.
*
* @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public void flush() throws IOException public void flush() throws IOException
{ {
@ -128,6 +136,11 @@ public class XMLWriter
/** /**
* This method writes a XML tag with no content. * 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) public void writeEmptyTag(final String label, final String... attributes)
{ {
@ -139,6 +152,9 @@ public class XMLWriter
/** /**
* This method writes a XML ender tag. * This method writes a XML ender tag.
*
* @param label
* the label
*/ */
public void writeEndTag(final String label) public void writeEndTag(final String label)
{ {
@ -149,6 +165,11 @@ public class XMLWriter
/** /**
* This method writes a XML start tag. * This method writes a XML start tag.
*
* @param label
* the label
* @param attributes
* the attributes
*/ */
public void writeStartTag(final String label, final String... 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. * This method write a XML tag with attributes and boolean content data.
* *
* @param label * @param label
* the label
* @param content * @param content
* the content
* @param attributes * @param attributes
* the attributes
*/ */
public void writeTag(final String label, final boolean content, final String... 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. * This method write a XML tag with attributes and long content data.
* *
* @param label * @param label
* the label
* @param content * @param content
* the content
* @param attributes * @param attributes
* the attributes
*/ */
public void writeTag(final String label, final long content, final String... 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. * data are converted in XML format.
* *
* @param label * @param label
* the label
* @param content * @param content
* the content
* @param attributes * @param attributes
* the attributes
*/ */
public void writeTag(final String label, final String content, final String... 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. * This method writes attributes of a tag.
* *
* @param attributes * @param attributes
* the attributes
*/ */
private void writeTagAttributes(final String... attributes) private void writeTagAttributes(final String... attributes)
{ {
//
if ((attributes != null) && (attributes.length > 0)) if ((attributes != null) && (attributes.length > 0))
{ {
for (int count = 0; count < attributes.length; count += 2) for (int count = 0; count < attributes.length; count += 2)
@ -237,10 +267,8 @@ public class XMLWriter
*/ */
private void writeTagContent(final String content) private void writeTagContent(final String content)
{ {
//
for (int count = 0; count < content.length(); count++) for (int count = 0; count < content.length(); count++)
{ {
//
char car = content.charAt(count); char car = content.charAt(count);
switch (car) switch (car)
@ -270,6 +298,7 @@ public class XMLWriter
* This method writes a XML header with attributes. * This method writes a XML header with attributes.
* *
* @param attributes * @param attributes
* the attributes
*/ */
public void writeXMLHeader(final String... attributes) public void writeXMLHeader(final String... attributes)
{ {

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -28,6 +28,7 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
/** /**
* The Class XMLZipReader.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @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 * @param file
* the file
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
*/ */
public XMLZipReader(final File file) throws IOException, XMLStreamException 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 * @throws IOException
* Signals that an I/O exception has occurred.
* @throws XMLStreamException * @throws XMLStreamException
* the XML stream exception
*/ */
public XMLZipReader(final InputStream source) throws IOException, XMLStreamException public XMLZipReader(final InputStream source) throws IOException, XMLStreamException
{ {

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2013-2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -31,6 +31,7 @@ import java.util.zip.ZipOutputStream;
import fr.devinsy.util.FileTools; import fr.devinsy.util.FileTools;
/** /**
* The Class XMLZipWriter.
* *
* @author Christian Pierre MOMON (christian.momon@devinsy.fr) * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
@ -39,9 +40,12 @@ public class XMLZipWriter extends XMLWriter
private ZipOutputStream zos; private ZipOutputStream zos;
/** /**
* Instantiates a new XML zip writer.
* *
* @param file * @param file
* the file
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public XMLZipWriter(final File file) throws IOException public XMLZipWriter(final File file) throws IOException
{ {
@ -56,9 +60,14 @@ public class XMLZipWriter extends XMLWriter
} }
/** /**
* Instantiates a new XML zip writer.
* *
* @param file * @param file
* the file
* @param generator
* the generator
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public XMLZipWriter(final File file, final String generator) throws IOException 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 * @param target
* the target
* @param generator
* the generator
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public XMLZipWriter(final OutputStream target, final String generator) throws IOException 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 * @param target
* the target
* @param fileName
* the file name
* @param generator
* the generator
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public XMLZipWriter(final OutputStream target, final String fileName, final String generator) throws IOException 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 @Override
public void close() throws IOException 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 public void closeEntry() throws IOException
{ {
@ -131,9 +156,12 @@ public class XMLZipWriter extends XMLWriter
} }
/** /**
* Open entry.
* *
* @param fileName * @param fileName
* the file name
* @throws IOException * @throws IOException
* Signals that an I/O exception has occurred.
*/ */
public void openEntry(final String fileName) throws IOException public void openEntry(final String fileName) throws IOException
{ {

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util; package fr.devinsy.util;
@ -30,15 +30,16 @@ import org.junit.Test;
import fr.devinsy.util.strings.StringList; import fr.devinsy.util.strings.StringList;
/** /**
* The Class FileToolsTest.
* *
* @author Christian P. Momon * @author Christian Pierre MOMON (christian.momon@devinsy.fr)
*/ */
public class FileToolsTest 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 @Before
public void 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 @Test
public void loadToStringListURL01() throws IOException 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")); 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)); Assert.assertEquals("trois", source.get(3 - 1));
// //
logger.debug("===== test done."); this.logger.debug("===== test done.");
} }
/** /**
* @throws IOException * Test get extension.
*
*/ */
@Test @Test
public void testGetExtension() public void testGetExtension()
{ {
// //
logger.debug("===== test starting..."); this.logger.debug("===== test starting...");
// //
String extension = FileTools.getExtension("test.ext"); String extension = FileTools.getExtension("test.ext");
@ -83,6 +86,6 @@ public class FileToolsTest
Assert.assertEquals(extension, "ext"); Assert.assertEquals(extension, "ext");
// //
logger.debug("===== test done."); this.logger.debug("===== test done.");
} }
} }

View file

@ -1,20 +1,20 @@
/** /*
* Copyright (C) 2014,2017 Christian Pierre MOMON * 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 * 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 * the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version. * (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 * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details.
* *
* You should have received a copy of the GNU Lesser General Public License * You should have received a copy of the GNU Lesser General Public License
* along with Devinsy-strings. If not, see <http://www.gnu.org/licenses/> * along with Devinsy-xml. If not, see <http://www.gnu.org/licenses/>
*/ */
package fr.devinsy.util.xml; package fr.devinsy.util.xml;
@ -31,15 +31,16 @@ import org.junit.Before;
import fr.devinsy.util.strings.StringList; import fr.devinsy.util.strings.StringList;
/** /**
* The Class XMLReaderTest.
* *
* @author Christian P. Momon * @author Christian P. Momon
*/ */
public class XMLReaderTest 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 @Before
public void before() public void before()
@ -49,16 +50,20 @@ public class XMLReaderTest
} }
/** /**
* @throws XMLStreamException * Test foo 01.
* @throws FileNotFoundException
* @throws XMLBadFormatException
* *
* @throws FileNotFoundException
* the file not found exception
* @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException
* the XML bad format exception
*/ */
// @Test // @Test
public void testFoo01() throws FileNotFoundException, XMLStreamException, XMLBadFormatException public void testFoo01() throws FileNotFoundException, XMLStreamException, XMLBadFormatException
{ {
// //
logger.debug("===== test starting..."); this.logger.debug("===== test starting...");
// XMLReader in = new XMLReader(new // XMLReader in = new XMLReader(new
// File("/home/cpm/C/Puck/TY/Ebrei 08.puc")); // 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"); System.out.println("over");
} }
/** /**
* @throws XMLStreamException * Test foo 02.
* @throws FileNotFoundException
* @throws XMLBadFormatException
* *
* @throws FileNotFoundException
* the file not found exception
* @throws XMLStreamException
* the XML stream exception
* @throws XMLBadFormatException
* the XML bad format exception
*/ */
// @Test // @Test
public void testFoo02() throws FileNotFoundException, XMLStreamException, XMLBadFormatException public void testFoo02() throws FileNotFoundException, XMLStreamException, XMLBadFormatException
{ {
// //
logger.debug("===== test starting..."); this.logger.debug("===== test starting...");
// XMLReader in = new XMLReader(new // XMLReader in = new XMLReader(new
// File("/home/cpm/C/Puck/TY/Ebrei 08.puc")); // 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"); System.out.println("over");
} }
} }