[Japi-cvs] SF.net SVN: japi: [475] tools/string2bytes/trunk/src/net/sf/japi/ string2bytes
Status: Beta
Brought to you by:
christianhujer
|
From: <chr...@us...> - 2007-06-30 12:20:10
|
Revision: 475
http://svn.sourceforge.net/japi/?rev=475&view=rev
Author: christianhujer
Date: 2007-06-30 05:20:08 -0700 (Sat, 30 Jun 2007)
Log Message:
-----------
Added missing @Nullable / @NotNull annotations.
Added missing @Override annotations.
Added missing final modifiers.
Added missing Javadoc comments.
Fixed possible NPE in URLEncodeCodec.
Modified Paths:
--------------
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/AbstractStringCodec.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecListModel.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecSelectionPanel.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStep.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStepsListModel.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/DoubleListController.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/EntityCodec.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/IdentityCodec.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/JavaBytesCodec.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/ListOrderController.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/String2Bytes.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/StringCodec.java
tools/string2bytes/trunk/src/net/sf/japi/string2bytes/URLEncodeCodec.java
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/AbstractStringCodec.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/AbstractStringCodec.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/AbstractStringCodec.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -33,7 +33,7 @@
}
/** {@inheritDoc} */
- public String toString() {
+ @Override @Nullable public String toString() {
return getDisplayName();
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecListModel.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecListModel.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecListModel.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -21,6 +21,7 @@
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
+import org.jetbrains.annotations.NotNull;
/**
* ListModel for codecs.
@@ -35,17 +36,17 @@
}
/** {@inheritDoc} */
- public Object getElementAt(final int i) {
+ @NotNull public Object getElementAt(final int i) {
return StringCodec.ALL_CODECS.get(i);
}
/** {@inheritDoc} */
- public void addListDataListener(final ListDataListener listDataListener) {
+ public void addListDataListener(@NotNull final ListDataListener listDataListener) {
// Because we don't fire events, we ignore listeners.
}
/** {@inheritDoc} */
- public void removeListDataListener(final ListDataListener listDataListener) {
+ public void removeListDataListener(@NotNull final ListDataListener listDataListener) {
// Because we don't fire events, we ignore listeners.
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecSelectionPanel.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecSelectionPanel.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecSelectionPanel.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -39,13 +39,13 @@
public class CodecSelectionPanel extends JPanel implements ListSelectionListener {
/** Action Factory. */
- private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
+ @NotNull private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
/** The list with the available codecs. */
- private JList availableCodecsList = new JList(new CodecListModel());
+ @NotNull private JList availableCodecsList = new JList(new CodecListModel());
/** The list with the configured codec steps. */
- private JList configuredCodecSteps = new JList(new CodecStepsListModel());
+ @NotNull private JList configuredCodecSteps = new JList(new CodecStepsListModel());
/**
* Creates a CodecSelectionPanel.
@@ -78,8 +78,8 @@
* Main method, used to try the CodecSelectionPanel.
* @param args Command line arguments (ignored)
*/
- public static void main(final String... args) {
- JFrame f = new JFrame();
+ public static void main(@NotNull final String... args) {
+ final JFrame f = new JFrame();
f.add(new CodecSelectionPanel());
f.pack();
f.setVisible(true);
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStep.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStep.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStep.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -76,7 +76,7 @@
}
/** {@inheritDoc} */
- public String toString() {
+ @Override @NotNull public String toString() {
return codec + " [" + getCharset() + "]";
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStepsListModel.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStepsListModel.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/CodecStepsListModel.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -22,6 +22,7 @@
import javax.swing.ListModel;
import javax.swing.JList;
import javax.swing.DefaultListModel;
+import org.jetbrains.annotations.NotNull;
/**
* The CodecStepsListModel is a {@link ListModel} for listing {@link CodecStep}s in a {@link JList}.
@@ -30,7 +31,7 @@
public class CodecStepsListModel extends DefaultListModel {
/** {@inheritDoc} */
- @Override public void insertElementAt(final Object object, final int i) {
+ @Override public void insertElementAt(@NotNull final Object object, final int i) {
if (!(object instanceof StringCodec)) {
throw new IllegalArgumentException(object + " not instanceof " + StringCodec.class);
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/DoubleListController.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/DoubleListController.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/DoubleListController.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -40,12 +40,13 @@
* Elements from the second list can be removed from the second list based on the selection made in the second list.
* The first list, which is not modified by this controller, is called source list.
* The second list, which can be modified by this controller, is called target list.
+ * @todo move to an appropriate JAPI swing library module.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class DoubleListController extends JComponent implements ListSelectionListener {
/** Action Factory. */
- private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
+ @NotNull private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
/**
* The first list (source list) to operate on.
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/EntityCodec.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/EntityCodec.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/EntityCodec.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -43,6 +43,7 @@
if (encoder.canEncode(c)) {
cooked.append(c);
} else {
+ //noinspection MagicNumber
format.format("&%x;", c & 0xFFFF);
}
}
@@ -50,7 +51,7 @@
}
/** {@inheritDoc} */
- @Nullable public String getDisplayName() {
+ @Override @Nullable public String getDisplayName() {
return "XML entities";
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/IdentityCodec.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/IdentityCodec.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/IdentityCodec.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -35,7 +35,7 @@
}
/** {@inheritDoc} */
- @Nullable public String getDisplayName() {
+ @Override @Nullable public String getDisplayName() {
return "Identity";
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/JavaBytesCodec.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/JavaBytesCodec.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/JavaBytesCodec.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -47,7 +47,7 @@
}
/** {@inheritDoc} */
- @Nullable public String getDisplayName() {
+ @Override @Nullable public String getDisplayName() {
return "Java Bytes";
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/ListOrderController.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/ListOrderController.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/ListOrderController.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -37,12 +37,13 @@
/**
* A Control for changing the order of items in a {@link JList}.
+ * @todo move to an appropriate JAPI swing library module.
* @author <a href="mailto:ch...@ri...">Christian Hujer</a>
*/
public class ListOrderController extends JComponent implements ListSelectionListener {
/** Action Factory. */
- private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
+ @NotNull private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
/**
* The JList to operate on.
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/String2Bytes.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/String2Bytes.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/String2Bytes.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -39,6 +39,7 @@
import net.sf.japi.swing.ActionMethod;
import net.sf.japi.swing.ToggleAction;
import net.sf.japi.swing.about.AboutDialog;
+import org.jetbrains.annotations.NotNull;
/**
* String2Bytes is a small tool that converts Strings into Bytes.
@@ -54,22 +55,22 @@
public class String2Bytes implements ItemListener {
/** Action Factory. */
- private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
+ @NotNull private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.string2bytes");
/** About Dialog. */
- private final AboutDialog aboutDialog = new AboutDialog("net.sf.japi.string2bytes");
+ @NotNull private final AboutDialog aboutDialog = new AboutDialog("net.sf.japi.string2bytes");
/** Preferences. */
- private static final Preferences PREFS = Preferences.userNodeForPackage(String2Bytes.class);
+ @NotNull private static final Preferences PREFS = Preferences.userNodeForPackage(String2Bytes.class);
/** Textfield for the input String. */
- private final JTextArea input = new JTextArea();
+ @NotNull private final JTextArea input = new JTextArea();
/** Textfield for the output String. */
- private final JTextArea output = new JTextArea();
+ @NotNull private final JTextArea output = new JTextArea();
/** ComboBox for selecting the encoding. */
- private final JComboBox encoding = new JComboBox(Charset.availableCharsets().keySet().toArray());
+ @NotNull private final JComboBox encoding = new JComboBox(Charset.availableCharsets().keySet().toArray());
/** Whether the Clipboard is used for input. */
private boolean usingClipboardForInput;
@@ -78,7 +79,7 @@
private boolean usingClipboardForOutput;
/** The application frame. */
- private final JFrame frame;
+ @NotNull private final JFrame frame;
String2Bytes() {
ACTION_FACTORY.createActions(true, this, "convert", "encodingDefault", "encodingSystem", "clearInput", "clearOutput");
@@ -141,7 +142,7 @@
* @return Converted String
* @throws UnsupportedEncodingException in case the selected encoding is not available (shouldn't happen).
*/
- public String convert(final String from) throws Exception {
+ @NotNull public String convert(@NotNull final String from) throws Exception {
return new JavaBytesCodec().code(from, encoding.getSelectedItem().toString());
}
@@ -185,7 +186,7 @@
* Creates the panel which holds the settings.
* @return Newly created panel which holds the settings.
*/
- private JPanel createSettingsPanel() {
+ @NotNull private JPanel createSettingsPanel() {
final JPanel settingsPanel = new JPanel();
settingsPanel.setBorder(BorderFactory.createTitledBorder("Settings"));
settingsPanel.add(createEncodingPanel());
@@ -196,7 +197,7 @@
* Creates the panel which allows the user to select the encoding.
* @return Newly created panel for selecting the encoding.
*/
- private JPanel createEncodingPanel() {
+ @NotNull private JPanel createEncodingPanel() {
encoding.setSelectedItem(PREFS.get("encoding", ACTION_FACTORY.getString("encoding.default")));
encoding.setEditable(true);
final JPanel encodingPanel = new JPanel();
@@ -211,7 +212,7 @@
* Creates the input panel.
* @return Newly created input panel.
*/
- private JPanel createInputPanel() {
+ @NotNull private JPanel createInputPanel() {
final JPanel inputPanel = new JPanel(new GridBagLayout());
inputPanel.setBorder(BorderFactory.createTitledBorder(ACTION_FACTORY.getString("border.input.title")));
final GridBagConstraints gbc = new GridBagConstraints();
@@ -233,7 +234,7 @@
* Creates the output panel.
* @return Newly created output panel.
*/
- private JPanel createOutputPanel() {
+ @NotNull private JPanel createOutputPanel() {
final JPanel outputPanel = new JPanel(new GridBagLayout());
outputPanel.setBorder(BorderFactory.createTitledBorder(ACTION_FACTORY.getString("border.output.title")));
final GridBagConstraints gbc = new GridBagConstraints();
@@ -255,7 +256,7 @@
* Creates the command panel which holds the button to perform the conversion.
* @return Newly created command panel.
*/
- private JPanel createCommandPanel() {
+ @NotNull private JPanel createCommandPanel() {
final JPanel commandPanel = new JPanel();
commandPanel.setBorder(BorderFactory.createTitledBorder("Commands"));
commandPanel.add(new JButton(ACTION_FACTORY.getAction("convert")));
@@ -263,7 +264,7 @@
}
/** {@inheritDoc} */
- public void itemStateChanged(final ItemEvent itemEvent) {
+ public void itemStateChanged(@NotNull final ItemEvent itemEvent) {
if (itemEvent.getStateChange() == ItemEvent.SELECTED) {
PREFS.put("encoding", encoding.getSelectedItem().toString());
}
@@ -273,7 +274,7 @@
* Main program.
* @param args Command line arguments (ignored)
*/
- public static void main(final String... args) {
+ public static void main(@NotNull final String... args) {
new String2Bytes();
}
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/StringCodec.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/StringCodec.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/StringCodec.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -36,7 +36,7 @@
* Unmodifiable list with all Codecs.
* @deprecated This will be replaced using a registry.
*/
- @Deprecated List<? extends StringCodec> ALL_CODECS = Collections.unmodifiableList(Arrays.asList(new IdentityCodec(), new JavaBytesCodec(), new EntityCodec(), new URLEncodeCodec()));
+ @Deprecated @NotNull List<? extends StringCodec> ALL_CODECS = Collections.unmodifiableList(Arrays.asList(new IdentityCodec(), new JavaBytesCodec(), new EntityCodec(), new URLEncodeCodec()));
/**
* Convert a String into another String.
Modified: tools/string2bytes/trunk/src/net/sf/japi/string2bytes/URLEncodeCodec.java
===================================================================
--- tools/string2bytes/trunk/src/net/sf/japi/string2bytes/URLEncodeCodec.java 2007-06-30 12:04:18 UTC (rev 474)
+++ tools/string2bytes/trunk/src/net/sf/japi/string2bytes/URLEncodeCodec.java 2007-06-30 12:20:08 UTC (rev 475)
@@ -32,12 +32,12 @@
public class URLEncodeCodec extends AbstractStringCodec {
/** {@inheritDoc} */
- @NotNull public String code(@NotNull final String input, final String charsetName) throws UnsupportedEncodingException {
- return URLEncoder.encode(input, charsetName);
+ @NotNull public String code(@NotNull final String input, @Nullable final String charsetName) throws UnsupportedEncodingException {
+ return charsetName == null ? URLEncoder.encode(input) : URLEncoder.encode(input, charsetName);
}
/** {@inheritDoc} */
- @Nullable public String getDisplayName() {
+ @Override @Nullable public String getDisplayName() {
return "URLEncode";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|