[Japi-cvs] SF.net SVN: japi: [45] trunk/src/app/net/sf/japi/io
Status: Beta
Brought to you by:
christianhujer
From: <chr...@us...> - 2006-04-11 22:05:18
|
Revision: 45 Author: christianhujer Date: 2006-04-11 15:04:53 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/japi/?rev=45&view=rev Log Message: ----------- Cosmetic improvements. Modified Paths: -------------- trunk/src/app/net/sf/japi/io/BCD.java trunk/src/app/net/sf/japi/lang/SuperClassIterator.java trunk/src/app/net/sf/japi/swing/action.properties trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkManager.java trunk/src/app/net/sf/japi/util/Collections2.java trunk/src/app/net/sf/japi/util/EndianConverter.java trunk/src/app/net/sf/japi/util/EnumerationIterator.java trunk/src/app/net/sf/japi/util/Table.java trunk/src/app/net/sf/japi/xml/FilteredNodeList.java trunk/src/app/net/sf/japi/xml/NodeListIterator.java Modified: trunk/src/app/net/sf/japi/io/BCD.java =================================================================== --- trunk/src/app/net/sf/japi/io/BCD.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/io/BCD.java 2006-04-11 22:04:53 UTC (rev 45) @@ -23,14 +23,13 @@ /** A class with methods for converting BCD data from and to Binary data. * Currently only int is supported. - * Probably <code>code.itcqis.io</code> is not the ideal package for this class, yet it seems most appropriate. - * @author $Author: christianhujer $ - * @version $Revision: 1.2 $ + * Probably <code>net.sf.japi.io</code> is not the ideal package for this class, yet it seems most appropriate. */ public final class BCD { /** Private constructor - no instances needed. */ - private BCD() {} + private BCD() { + } /** Convert a BCD value to an int value. * @param bcd BCD value @@ -62,10 +61,11 @@ /** Check wether a BCD value is correct. * If the supplied value contains a nibble with a value >= 10, it will throw an IllegalArgumentException. * Otherwise it will simply return. + * @param bcd number to check */ public static void check(final int bcd) { for (int i = 0; i < 8; i++) { - if ( (0xF & bcd >> 4 * i) >= 10) { + if ((0xF & bcd >> 4 * i) >= 10) { throw new IllegalArgumentException(); } } @@ -77,7 +77,7 @@ */ public static boolean isBcd(final int bcd) { for (int i = 0; i < 8; i++) { - if ( (0xF & bcd >> 4 * i) >= 10) { + if ((0xF & bcd >> 4 * i) >= 10) { return false; } } @@ -105,7 +105,7 @@ public static int correct(final int bcd) { int newBcd = bcd; for (int i = 0; i < 8; i++) { - if ( (0xF & bcd >> 4 * i) >= 10) { + if ((0xF & bcd >> 4 * i) >= 10) { newBcd -= 10 << 4 * i; newBcd += 1 << 4 * (i + 1); } Modified: trunk/src/app/net/sf/japi/lang/SuperClassIterator.java =================================================================== --- trunk/src/app/net/sf/japi/lang/SuperClassIterator.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/lang/SuperClassIterator.java 2006-04-11 22:04:53 UTC (rev 45) @@ -18,7 +18,6 @@ * 02111-1307, USA. */ - package net.sf.japi.lang; import java.util.Iterator; Modified: trunk/src/app/net/sf/japi/swing/action.properties =================================================================== --- trunk/src/app/net/sf/japi/swing/action.properties 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/swing/action.properties 2006-04-11 22:04:53 UTC (rev 45) @@ -52,3 +52,4 @@ saxErrorClose.text=Close saxError.title=XML Errors dialogDontShowAgain=Show this dialog again next time. +laf=Look and Feel \ No newline at end of file Modified: trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkManager.java =================================================================== --- trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkManager.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/swing/bookmarks/BookmarkManager.java 2006-04-11 22:04:53 UTC (rev 45) @@ -81,7 +81,7 @@ private BookmarkFolder bookmarks = new BookmarkFolder(); /** Action Factory. */ - private static final ActionFactory actionFactory = ActionFactory.getFactory("com.itcqis.swing.bookmarks"); + private static final ActionFactory actionFactory = ActionFactory.getFactory("net.sf.japi.swing.bookmarks"); /** The ProgramFrame this BookmarkManager manages bookmarks for. */ private Bookmarkable bookmarkable; Modified: trunk/src/app/net/sf/japi/util/Collections2.java =================================================================== --- trunk/src/app/net/sf/japi/util/Collections2.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/util/Collections2.java 2006-04-11 22:04:53 UTC (rev 45) @@ -94,7 +94,7 @@ */ public static final <T, C extends Collection<T>> int removeFilter(final C collection, final Filter<? super T> filter) { int removed = 0; - for (T o : collection) { + for (final T o : collection) { if (!filter.accept(o)) { collection.remove(o); removed++; @@ -146,6 +146,7 @@ */ public static final <T> boolean isSorted(final List<T> list, final Comparator<? super T> c) { if (c == null) { + //noinspection unchecked,RawUseOfParameterizedType return isSorted((List) list); } if (list.size() < 2) { Modified: trunk/src/app/net/sf/japi/util/EndianConverter.java =================================================================== --- trunk/src/app/net/sf/japi/util/EndianConverter.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/util/EndianConverter.java 2006-04-11 22:04:53 UTC (rev 45) @@ -25,15 +25,20 @@ * endian integer to a big endian integer and vice versa. * @author <a href="mailto:Chr...@it...">Christian Hujer</a> */ +@SuppressWarnings({"UtilityClass"}) public class EndianConverter { + /** Private constructor to prevent instantiation. */ + private EndianConverter() { + } + /** Convert a double. * This method changes byte order from 1, 2, 3, 4, 5, 6, 7, 8 to 8, 7, 6, 5, 4, 3, 2, 1. * @param d double to convert * @return converted double */ - public static final double se(final double d) { - return Double.longBitsToDouble(se(Double.doubleToRawLongBits(d))); + public static final double swapEndianess(final double d) { + return Double.longBitsToDouble(swapEndianess(Double.doubleToRawLongBits(d))); } /** Convert a float. @@ -41,8 +46,8 @@ * @param f float to convert * @return converted float */ - public static final float se(final float f) { - return Float.intBitsToFloat(se(Float.floatToRawIntBits(f))); + public static final float swapEndianess(final float f) { + return Float.intBitsToFloat(swapEndianess(Float.floatToRawIntBits(f))); } /** Convert a long. @@ -50,16 +55,17 @@ * @param l long to convert * @return converted long */ - public static final long se(final long l) { + @SuppressWarnings("OverlyComplexBooleanExpression") + public static final long swapEndianess(final long l) { return - (l & 0x00000000000000FFl) << 56 | - (l & 0x000000000000FF00l) << 40 | - (l & 0x0000000000FF0000l) << 24 | - (l & 0x00000000FF000000l) << 8 | - (l & 0x000000FF00000000l) >>> 8 | - (l & 0x0000FF0000000000l) >>> 24 | - (l & 0x00FF000000000000l) >>> 40 | - (l & 0xFF00000000000000l) >>> 56; + (l & 0x00000000000000FFL) << 56 | + (l & 0x000000000000FF00L) << 40 | + (l & 0x0000000000FF0000L) << 24 | + (l & 0x00000000FF000000L) << 8 | + (l & 0x000000FF00000000L) >>> 8 | + (l & 0x0000FF0000000000L) >>> 24 | + (l & 0x00FF000000000000L) >>> 40 | + (l & 0xFF00000000000000L) >>> 56; } /** Convert an int. @@ -67,7 +73,8 @@ * @param i int to convert * @return converted int */ - public static final int se(final int i) { + @SuppressWarnings("OverlyComplexBooleanExpression") + public static final int swapEndianess(final int i) { return (i & 0x000000FF) << 24 | (i & 0x0000FF00) << 8 | @@ -80,7 +87,7 @@ * @param c char to convert * @return converted char */ - public static final char se(final char c) { + public static final char swapEndianess(final char c) { return (char) ((c & 0x00FF) << 8 | (c & 0xFF00) >>> 8); @@ -91,7 +98,7 @@ * @param s short to convert * @return converted short */ - public static final short se(final short s) { + public static final short swapEndianess(final short s) { return (short) ((s & 0x00FF) << 8 | (s & 0xFF00) >>> 8); @@ -102,7 +109,7 @@ * @param b byte to convert * @return converted byte (same as b) */ - public static final byte se(final byte b) { + public static final byte swapEndianess(final byte b) { return b; } @@ -111,7 +118,8 @@ * @param b boolean to convert * @return converted boolean (same as b) */ - public static final boolean se(final boolean b) { + @SuppressWarnings({"BooleanMethodNameMustStartWithQuestion"}) + public static final boolean swapEndianess(final boolean b) { return b; } Modified: trunk/src/app/net/sf/japi/util/EnumerationIterator.java =================================================================== --- trunk/src/app/net/sf/japi/util/EnumerationIterator.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/util/EnumerationIterator.java 2006-04-11 22:04:53 UTC (rev 45) @@ -51,6 +51,9 @@ } /** {@inheritDoc} */ + // SuppressWarnings here because of bug in IntelliJ. + // enumeration.nextElement actually can throw a NoSuchElementException. + @SuppressWarnings({"IteratorNextCanNotThrowNoSuchElementException"}) public T next() throws NoSuchElementException { return enumeration.nextElement(); } Modified: trunk/src/app/net/sf/japi/util/Table.java =================================================================== --- trunk/src/app/net/sf/japi/util/Table.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/util/Table.java 2006-04-11 22:04:53 UTC (rev 45) @@ -54,7 +54,7 @@ final Set<T1> firsts = new HashSet<T1>(); for (final Pair<T1, T2> pair : pairs) { final T2 pairSecond = pair.getSecond(); - if (pairSecond == second || pairSecond.equals(second)) { + if (pairSecond.equals(second)) { firsts.add(pair.getFirst()); } } @@ -69,7 +69,7 @@ final Set<Pair<T1,T2>> pairsByFirst = new HashSet<Pair<T1,T2>>(); for (Pair<T1, T2> pair : pairs) { final T1 pairFirst = pair.getFirst(); - if (pairFirst == first || pairFirst.equals(first)) { + if (pairFirst.equals(first)) { pairsByFirst.add(pair); } } @@ -84,7 +84,7 @@ final Set<Pair<T1,T2>> pairsBySecond = new HashSet<Pair<T1,T2>>(); for (Pair<T1, T2> pair : pairs) { final T2 pairSecond = pair.getSecond(); - if (pairSecond == second || pairSecond.equals(second)) { + if (pairSecond.equals(second)) { pairsBySecond.add(pair); } } @@ -99,7 +99,7 @@ final Set<T2> seconds = new HashSet<T2>(); for (final Pair<T1, T2> pair : pairs) { final T1 pairFirst = pair.getFirst(); - if (pairFirst == first || pairFirst.equals(first)) { + if (pairFirst.equals(first)) { seconds.add(pair.getSecond()); } } @@ -125,28 +125,42 @@ /** Remove all pairs that match a first. * @param first first to match + * @return whether a matching pair was removed + * @retval <code>true</code> if at least one pair was removed + * @retval <code>false</code> if no matching pairs were found */ - public void removeAllFirst(final T1 first) { + public boolean removeAllFirst(final T1 first) { + boolean ret = false; + //noinspection ForLoopWithMissingComponent for (final Iterator<Pair<T1,T2>> it = pairs.iterator(); it.hasNext();) { final Pair<T1,T2> pair = it.next(); final T1 pairFirst = pair.getFirst(); - if (pairFirst == first || pairFirst.equals(first)) { + if (pairFirst.equals(first)) { it.remove(); + ret = true; } } + return ret; } /** Remove all pairs that match a second. * @param second second to match + * @return whether a matching pair was removed + * @retval <code>true</code> if at least one pair was removed + * @retval <code>false</code> if no matching pairs were found */ - public void removeAllSecond(final T2 second) { + public boolean removeAllSecond(final T2 second) { + boolean ret = false; + //noinspection ForLoopWithMissingComponent for (final Iterator<Pair<T1,T2>> it = pairs.iterator(); it.hasNext();) { final Pair<T1,T2> pair = it.next(); final T2 pairSecond = pair.getSecond(); - if (pairSecond == second || pairSecond.equals(second)) { + if (pairSecond.equals(second)) { it.remove(); + ret = true; } } + return ret; } /** Remove a pair from the table. Modified: trunk/src/app/net/sf/japi/xml/FilteredNodeList.java =================================================================== --- trunk/src/app/net/sf/japi/xml/FilteredNodeList.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/xml/FilteredNodeList.java 2006-04-11 22:04:53 UTC (rev 45) @@ -52,6 +52,7 @@ tmpNodes.add(node); } } + //noinspection unchecked nodes = (T[]) tmpNodes.toArray(new Node[tmpNodes.size()]); } @@ -69,6 +70,7 @@ tmpNodes.add(node); } } + //noinspection unchecked nodes = (T[]) tmpNodes.toArray(new Node[tmpNodes.size()]); } Modified: trunk/src/app/net/sf/japi/xml/NodeListIterator.java =================================================================== --- trunk/src/app/net/sf/japi/xml/NodeListIterator.java 2006-04-11 22:03:07 UTC (rev 44) +++ trunk/src/app/net/sf/japi/xml/NodeListIterator.java 2006-04-11 22:04:53 UTC (rev 45) @@ -105,6 +105,7 @@ /** {@inheritDoc} */ @NotNull public T next() throws NoSuchElementException { + //noinspection unchecked final T item = (T) nodeList.item(index++); if (item == null) { throw new NoSuchElementException(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |