1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2024-11-22 20:12:07 +01:00

add pmd for codecheck

add generic to the smackx bookmark

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@11023 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Michael Will 2009-06-04 09:56:20 +00:00 committed by michael.will
parent f943d27a3b
commit 634afb2cad
6 changed files with 40 additions and 23 deletions

BIN
build/asm.jar Normal file

Binary file not shown.

View file

@ -339,6 +339,24 @@
<ant antfile="${basedir}/build/release.xml" /> <ant antfile="${basedir}/build/release.xml" />
</target> </target>
<!-- checkcode -->
<!-- ======================================================================================= -->
<target name="checkcode" >
<taskdef name="pmd" classname="net.sourceforge.pmd.ant.PMDTask">
<classpath>
<pathelement location="${basedir}/build/pmd.jar" />
<pathelement location="${basedir}/build/asm.jar" />
<pathelement location="${basedir}/build/jaxen.jar" />
</classpath>
</taskdef>
<pmd shortFilenames="true">
<ruleset>migrating</ruleset>
<formatter type="html" toFile="target/pmd_report.html" toConsole="true" />
<fileset dir="source/">
<include name="**/*.java" />
</fileset>
</pmd>
</target>
<!-- release-exists --> <!-- release-exists -->
<!-- ======================================================================================= --> <!-- ======================================================================================= -->

BIN
build/jaxen.jar Normal file

Binary file not shown.

BIN
build/pmd.jar Normal file

Binary file not shown.

View file

@ -36,7 +36,7 @@ import java.util.*;
* @author Alexander Wenckus * @author Alexander Wenckus
*/ */
public class BookmarkManager { public class BookmarkManager {
private static final Map bookmarkManagerMap = new HashMap(); private static final Map<XMPPConnection, BookmarkManager> bookmarkManagerMap = new HashMap<XMPPConnection, BookmarkManager>();
static { static {
PrivateDataManager.addPrivateDataProvider("storage", "storage:bookmarks", PrivateDataManager.addPrivateDataProvider("storage", "storage:bookmarks",
new Bookmarks.Provider()); new Bookmarks.Provider());
@ -87,7 +87,7 @@ public class BookmarkManager {
* the server. * the server.
* @see BookmarkedConference * @see BookmarkedConference
*/ */
public Collection getBookmarkedConferences() throws XMPPException { public Collection<BookmarkedConference> getBookmarkedConferences() throws XMPPException {
retrieveBookmarks(); retrieveBookmarks();
return Collections.unmodifiableCollection(bookmarks.getBookmarkedConferences()); return Collections.unmodifiableCollection(bookmarks.getBookmarkedConferences());
} }
@ -109,10 +109,9 @@ public class BookmarkManager {
retrieveBookmarks(); retrieveBookmarks();
BookmarkedConference bookmark BookmarkedConference bookmark
= new BookmarkedConference(name, jid, isAutoJoin, nickname, password); = new BookmarkedConference(name, jid, isAutoJoin, nickname, password);
List conferences = bookmarks.getBookmarkedConferences(); List<BookmarkedConference> conferences = bookmarks.getBookmarkedConferences();
if(conferences.contains(bookmark)) { if(conferences.contains(bookmark)) {
BookmarkedConference oldConference = (BookmarkedConference) BookmarkedConference oldConference = conferences.get(conferences.indexOf(bookmark));
conferences.get(conferences.indexOf(bookmark));
if(oldConference.isShared()) { if(oldConference.isShared()) {
throw new IllegalArgumentException("Cannot modify shared bookmark"); throw new IllegalArgumentException("Cannot modify shared bookmark");
} }
@ -138,9 +137,9 @@ public class BookmarkManager {
*/ */
public void removeBookmarkedConference(String jid) throws XMPPException { public void removeBookmarkedConference(String jid) throws XMPPException {
retrieveBookmarks(); retrieveBookmarks();
Iterator it = bookmarks.getBookmarkedConferences().iterator(); Iterator<BookmarkedConference> it = bookmarks.getBookmarkedConferences().iterator();
while(it.hasNext()) { while(it.hasNext()) {
BookmarkedConference conference = (BookmarkedConference) it.next(); BookmarkedConference conference = it.next();
if(conference.getJid().equalsIgnoreCase(jid)) { if(conference.getJid().equalsIgnoreCase(jid)) {
if(conference.isShared()) { if(conference.isShared()) {
throw new IllegalArgumentException("Conference is shared and can't be removed"); throw new IllegalArgumentException("Conference is shared and can't be removed");
@ -158,7 +157,7 @@ public class BookmarkManager {
* @return returns an unmodifiable collection of all bookmarked urls. * @return returns an unmodifiable collection of all bookmarked urls.
* @throws XMPPException thrown when there is a problem retriving bookmarks from the server. * @throws XMPPException thrown when there is a problem retriving bookmarks from the server.
*/ */
public Collection getBookmarkedURLs() throws XMPPException { public Collection<BookmarkedURL> getBookmarkedURLs() throws XMPPException {
retrieveBookmarks(); retrieveBookmarks();
return Collections.unmodifiableCollection(bookmarks.getBookmarkedURLS()); return Collections.unmodifiableCollection(bookmarks.getBookmarkedURLS());
} }
@ -175,9 +174,9 @@ public class BookmarkManager {
public void addBookmarkedURL(String URL, String name, boolean isRSS) throws XMPPException { public void addBookmarkedURL(String URL, String name, boolean isRSS) throws XMPPException {
retrieveBookmarks(); retrieveBookmarks();
BookmarkedURL bookmark = new BookmarkedURL(URL, name, isRSS); BookmarkedURL bookmark = new BookmarkedURL(URL, name, isRSS);
List urls = bookmarks.getBookmarkedURLS(); List<BookmarkedURL> urls = bookmarks.getBookmarkedURLS();
if(urls.contains(bookmark)) { if(urls.contains(bookmark)) {
BookmarkedURL oldURL = (BookmarkedURL) urls.get(urls.indexOf(bookmark)); BookmarkedURL oldURL = urls.get(urls.indexOf(bookmark));
if(oldURL.isShared()) { if(oldURL.isShared()) {
throw new IllegalArgumentException("Cannot modify shared bookmarks"); throw new IllegalArgumentException("Cannot modify shared bookmarks");
} }
@ -199,9 +198,9 @@ public class BookmarkManager {
*/ */
public void removeBookmarkedURL(String bookmarkURL) throws XMPPException { public void removeBookmarkedURL(String bookmarkURL) throws XMPPException {
retrieveBookmarks(); retrieveBookmarks();
Iterator it = bookmarks.getBookmarkedURLS().iterator(); Iterator<BookmarkedURL> it = bookmarks.getBookmarkedURLS().iterator();
while(it.hasNext()) { while(it.hasNext()) {
BookmarkedURL bookmark = (BookmarkedURL) it.next(); BookmarkedURL bookmark = it.next();
if(bookmark.getURL().equalsIgnoreCase(bookmarkURL)) { if(bookmark.getURL().equalsIgnoreCase(bookmarkURL)) {
if(bookmark.isShared()) { if(bookmark.isShared()) {
throw new IllegalArgumentException("Cannot delete a shared bookmark."); throw new IllegalArgumentException("Cannot delete a shared bookmark.");

View file

@ -62,15 +62,15 @@ import java.util.List;
*/ */
public class Bookmarks implements PrivateData { public class Bookmarks implements PrivateData {
private List bookmarkedURLS; private List<BookmarkedURL> bookmarkedURLS;
private List bookmarkedConferences; private List<BookmarkedConference> bookmarkedConferences;
/** /**
* Required Empty Constructor to use Bookmarks. * Required Empty Constructor to use Bookmarks.
*/ */
public Bookmarks() { public Bookmarks() {
bookmarkedURLS = new ArrayList(); bookmarkedURLS = new ArrayList<BookmarkedURL>();
bookmarkedConferences = new ArrayList(); bookmarkedConferences = new ArrayList<BookmarkedConference>();
} }
/** /**
@ -128,7 +128,7 @@ public class Bookmarks implements PrivateData {
* *
* @return a collection of all Bookmarked URLs. * @return a collection of all Bookmarked URLs.
*/ */
public List getBookmarkedURLS() { public List<BookmarkedURL> getBookmarkedURLS() {
return bookmarkedURLS; return bookmarkedURLS;
} }
@ -137,7 +137,7 @@ public class Bookmarks implements PrivateData {
* *
* @return a collection of all Bookmarked Conferences. * @return a collection of all Bookmarked Conferences.
*/ */
public List getBookmarkedConferences() { public List<BookmarkedConference> getBookmarkedConferences() {
return bookmarkedConferences; return bookmarkedConferences;
} }
@ -169,9 +169,9 @@ public class Bookmarks implements PrivateData {
StringBuilder buf = new StringBuilder(); StringBuilder buf = new StringBuilder();
buf.append("<storage xmlns=\"storage:bookmarks\">"); buf.append("<storage xmlns=\"storage:bookmarks\">");
final Iterator urls = getBookmarkedURLS().iterator(); final Iterator<BookmarkedURL> urls = getBookmarkedURLS().iterator();
while (urls.hasNext()) { while (urls.hasNext()) {
BookmarkedURL urlStorage = (BookmarkedURL) urls.next(); BookmarkedURL urlStorage = urls.next();
if(urlStorage.isShared()) { if(urlStorage.isShared()) {
continue; continue;
} }
@ -184,9 +184,9 @@ public class Bookmarks implements PrivateData {
} }
// Add Conference additions // Add Conference additions
final Iterator conferences = getBookmarkedConferences().iterator(); final Iterator<BookmarkedConference> conferences = getBookmarkedConferences().iterator();
while (conferences.hasNext()) { while (conferences.hasNext()) {
BookmarkedConference conference = (BookmarkedConference) conferences.next(); BookmarkedConference conference = conferences.next();
if(conference.isShared()) { if(conference.isShared()) {
continue; continue;
} }