mirror of https://github.com/apache/archiva.git
clean warnings in xml tools module
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@755323 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
643ac963f2
commit
c01c25cf0a
|
@ -33,7 +33,7 @@ import java.util.List;
|
||||||
public class ElementTextListClosure
|
public class ElementTextListClosure
|
||||||
implements Closure
|
implements Closure
|
||||||
{
|
{
|
||||||
private List list = new ArrayList();
|
private List<String> list = new ArrayList<String>();
|
||||||
|
|
||||||
public void execute( Object input )
|
public void execute( Object input )
|
||||||
{
|
{
|
||||||
|
@ -44,7 +44,7 @@ public class ElementTextListClosure
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List getList()
|
public List<String> getList()
|
||||||
{
|
{
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,11 +29,11 @@ import java.util.Map;
|
||||||
*/
|
*/
|
||||||
public class LatinEntities
|
public class LatinEntities
|
||||||
{
|
{
|
||||||
private static final Map defaultEntityMap;
|
private static final Map<String, String> defaultEntityMap;
|
||||||
|
|
||||||
static
|
static
|
||||||
{
|
{
|
||||||
defaultEntityMap = new HashMap();
|
defaultEntityMap = new HashMap<String, String>();
|
||||||
|
|
||||||
defaultEntityMap.put( "nbsp", "\u00a0" );
|
defaultEntityMap.put( "nbsp", "\u00a0" );
|
||||||
defaultEntityMap.put( "iexcl", "\u00a1" );
|
defaultEntityMap.put( "iexcl", "\u00a1" );
|
||||||
|
|
|
@ -204,6 +204,7 @@ public class XMLReader
|
||||||
/**
|
/**
|
||||||
* Remove namespaces from element recursively.
|
* Remove namespaces from element recursively.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public void removeNamespaces( Element elem )
|
public void removeNamespaces( Element elem )
|
||||||
{
|
{
|
||||||
elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) );
|
elem.setQName( QName.get( elem.getName(), Namespace.NO_NAMESPACE, elem.getQualifiedName() ) );
|
||||||
|
@ -275,6 +276,7 @@ public class XMLReader
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
public List<Element> getElementList( String xpathExpr )
|
public List<Element> getElementList( String xpathExpr )
|
||||||
throws XMLException
|
throws XMLException
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,13 +19,12 @@ package org.apache.maven.archiva.xml;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.dom4j.Element;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.dom4j.Element;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* XMLReaderTest
|
* XMLReaderTest
|
||||||
*
|
*
|
||||||
|
@ -34,14 +33,13 @@ import java.util.List;
|
||||||
public class XMLReaderTest
|
public class XMLReaderTest
|
||||||
extends AbstractArchivaXmlTestCase
|
extends AbstractArchivaXmlTestCase
|
||||||
{
|
{
|
||||||
private void assertElementTexts( List elementList, String[] expectedTexts )
|
private void assertElementTexts( List<Element> elementList, String[] expectedTexts )
|
||||||
{
|
{
|
||||||
assertEquals( "Element List Size", expectedTexts.length, elementList.size() );
|
assertEquals( "Element List Size", expectedTexts.length, elementList.size() );
|
||||||
|
|
||||||
List texts = new ArrayList();
|
List<String> texts = new ArrayList<String>();
|
||||||
for ( Iterator iter = elementList.iterator(); iter.hasNext(); )
|
for ( Element element : elementList )
|
||||||
{
|
{
|
||||||
Element element = (Element) iter.next();
|
|
||||||
texts.add( element.getTextTrim() );
|
texts.add( element.getTextTrim() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -58,7 +56,7 @@ public class XMLReaderTest
|
||||||
File xmlFile = getExampleXml( "no-prolog-basic.xml" );
|
File xmlFile = getExampleXml( "no-prolog-basic.xml" );
|
||||||
XMLReader reader = new XMLReader( "basic", xmlFile );
|
XMLReader reader = new XMLReader( "basic", xmlFile );
|
||||||
|
|
||||||
List fruits = reader.getElementList( "//basic/fruits/fruit" );
|
List<Element> fruits = reader.getElementList( "//basic/fruits/fruit" );
|
||||||
assertElementTexts( fruits, new String[] { "apple", "cherry", "pear", "peach" } );
|
assertElementTexts( fruits, new String[] { "apple", "cherry", "pear", "peach" } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +66,7 @@ public class XMLReaderTest
|
||||||
File xmlFile = getExampleXml( "no-prolog-with-entities.xml" );
|
File xmlFile = getExampleXml( "no-prolog-with-entities.xml" );
|
||||||
XMLReader reader = new XMLReader( "basic", xmlFile );
|
XMLReader reader = new XMLReader( "basic", xmlFile );
|
||||||
|
|
||||||
List names = reader.getElementList( "//basic/names/name" );
|
List<Element> names = reader.getElementList( "//basic/names/name" );
|
||||||
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
|
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,7 +76,7 @@ public class XMLReaderTest
|
||||||
File xmlFile = getExampleXml( "no-prolog-with-utf8.xml" );
|
File xmlFile = getExampleXml( "no-prolog-with-utf8.xml" );
|
||||||
XMLReader reader = new XMLReader( "basic", xmlFile );
|
XMLReader reader = new XMLReader( "basic", xmlFile );
|
||||||
|
|
||||||
List names = reader.getElementList( "//basic/names/name" );
|
List<Element> names = reader.getElementList( "//basic/names/name" );
|
||||||
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
|
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,7 +86,7 @@ public class XMLReaderTest
|
||||||
File xmlFile = getExampleXml( "prolog-with-utf8.xml" );
|
File xmlFile = getExampleXml( "prolog-with-utf8.xml" );
|
||||||
XMLReader reader = new XMLReader( "basic", xmlFile );
|
XMLReader reader = new XMLReader( "basic", xmlFile );
|
||||||
|
|
||||||
List names = reader.getElementList( "//basic/names/name" );
|
List<Element> names = reader.getElementList( "//basic/names/name" );
|
||||||
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
|
assertElementTexts( names, new String[] { TRYGVIS, INFINITE_ARCHIVA } );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue