japi-cvs Mailing List for JAPI (Page 36)
Status: Beta
Brought to you by:
christianhujer
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
(115) |
May
(11) |
Jun
(5) |
Jul
(2) |
Aug
(10) |
Sep
(35) |
Oct
(14) |
Nov
(49) |
Dec
(27) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(57) |
Feb
(1) |
Mar
|
Apr
(2) |
May
(25) |
Jun
(134) |
Jul
(76) |
Aug
(34) |
Sep
(27) |
Oct
(5) |
Nov
|
Dec
(1) |
2008 |
Jan
(3) |
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(63) |
Nov
(30) |
Dec
(43) |
2009 |
Jan
(10) |
Feb
(420) |
Mar
(67) |
Apr
(3) |
May
(61) |
Jun
(21) |
Jul
(19) |
Aug
|
Sep
(6) |
Oct
(16) |
Nov
(1) |
Dec
|
2010 |
Jan
(1) |
Feb
|
Mar
|
Apr
(7) |
May
(3) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
(1) |
From: <chr...@us...> - 2007-07-14 10:34:56
|
Revision: 535 http://svn.sourceforge.net/japi/?rev=535&view=rev Author: christianhujer Date: 2007-07-14 03:34:54 -0700 (Sat, 14 Jul 2007) Log Message: ----------- Added panel for controlling a MutableListModel's order. Added Paths: ----------- libs/swing-list/trunk/src/net/sf/japi/swing/list/ListControlPanel.java libs/swing-list/trunk/src/net/sf/japi/swing/list/action.properties libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ListControlPanelTest.java Added: libs/swing-list/trunk/src/net/sf/japi/swing/list/ListControlPanel.java =================================================================== --- libs/swing-list/trunk/src/net/sf/japi/swing/list/ListControlPanel.java (rev 0) +++ libs/swing-list/trunk/src/net/sf/japi/swing/list/ListControlPanel.java 2007-07-14 10:34:54 UTC (rev 535) @@ -0,0 +1,144 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.swing.list; + +import java.awt.GridLayout; +import javax.swing.Action; +import javax.swing.JButton; +import javax.swing.JComponent; +import javax.swing.JList; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; +import net.sf.japi.swing.ActionFactory; +import net.sf.japi.swing.ActionMethod; +import org.jetbrains.annotations.NotNull; + +/** A Panel for a {@link MutableListModel} rendered by a {@link JList}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @todo the selection should automatically change with the move. + */ +public class ListControlPanel extends JComponent implements ListSelectionListener { + + /** The ActionFactory for creating the actions. */ + @NotNull private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.list"); + + /** Action for moving to top. */ + @NotNull private final Action moveToTop = ACTION_FACTORY.createAction(false, "moveToTop", this); + + /** Action for moving up. */ + @NotNull private final Action moveUp = ACTION_FACTORY.createAction(false, "moveUp", this); + + /** Action for moving down. */ + @NotNull private final Action moveDown = ACTION_FACTORY.createAction(false, "moveDown", this); + + /** Action for moving to bottom. */ + @NotNull private final Action moveToBottom = ACTION_FACTORY.createAction(false, "moveToBottom", this); + + /** The list that provides the information about the current selection. */ + @NotNull private JList list; + + /** The model to control. */ + @NotNull private MutableListModel model; + + /** Creates a ListControlPanel. + * @param list JList that provides the list selection information. + * @param model Model to control. + */ + public ListControlPanel(@NotNull final JList list, @NotNull final MutableListModel model) { + setLayout(new GridLayout(4, 1, 5, 5)); + setList(list); + setModel(model); + add(new JButton(moveToTop)); + add(new JButton(moveUp)); + add(new JButton(moveDown)); + add(new JButton(moveToBottom)); + updateActionStates(); + } + + /** Action for moving the currently selected element to top. */ + @ActionMethod public void moveToTop() { + model.moveToTop(list.getSelectedIndex()); + } + + /** Action for moving the currently selected element up. */ + @ActionMethod public void moveUp() { + model.moveUp(list.getSelectedIndex()); + } + + /** Action for moving the currently selected element down. */ + @ActionMethod public void moveDown() { + model.moveDown(list.getSelectedIndex()); + } + + /** Action for moving the currently selected element to bottom. */ + @ActionMethod public void moveToBottom() { + model.moveToBottom(list.getSelectedIndex()); + } + + /** Returns the list that provides the information about the current selection. + * @return JList queried for selection. + */ + @NotNull public JList getList() { + return list; + } + + /** Sets the list that provides the information about the current selection. + * @param list JList to query for selection. + */ + public void setList(@NotNull final JList list) { + if (this.list != null) { + this.list.removeListSelectionListener(this); + } + this.list = list; + list.addListSelectionListener(this); + } + + /** Returns the model that's controlled by this ListControlPanel. + * @return The controlled model. + */ + @NotNull public MutableListModel getModel() { + return model; + } + + /** Sets the model to control by this ListControlPanel. + * @param model The model to control. + */ + public void setModel(@NotNull final MutableListModel model) { + this.model = model; + } + + /** {@inheritDoc} */ + public void valueChanged(@NotNull final ListSelectionEvent e) { + if (!e.getValueIsAdjusting()) { + updateActionStates(); + } + } + + private void updateActionStates() { + assert list == null || list.getModel() == model; + final boolean top = list == null || list.getSelectedIndex() == 0; + final boolean bottom = list == null || list.getSelectedIndex() == model.getSize() - 1; + moveToTop.setEnabled(!top); + moveUp.setEnabled(!top); + moveDown.setEnabled(!bottom); + moveToBottom.setEnabled(!bottom); + } + +} // class ListControlPanel Property changes on: libs/swing-list/trunk/src/net/sf/japi/swing/list/ListControlPanel.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/net/sf/japi/swing/list/action.properties =================================================================== --- libs/swing-list/trunk/src/net/sf/japi/swing/list/action.properties (rev 0) +++ libs/swing-list/trunk/src/net/sf/japi/swing/list/action.properties 2007-07-14 10:34:54 UTC (rev 535) @@ -0,0 +1,23 @@ +# +# JAPI libs-swing-list is a library for lists in swing. +# Copyright (C) 2007 Christian Hujer. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +moveToTop.text=Top +moveUp.text=Up +moveDown.text=Down +moveToBottom.text=Bottom Property changes on: libs/swing-list/trunk/src/net/sf/japi/swing/list/action.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ListControlPanelTest.java =================================================================== --- libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ListControlPanelTest.java (rev 0) +++ libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ListControlPanelTest.java 2007-07-14 10:34:54 UTC (rev 535) @@ -0,0 +1,56 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package test.net.sf.japi.swing.list; + +import java.awt.BorderLayout; +import javax.swing.JFrame; +import javax.swing.JList; +import javax.swing.JScrollPane; +import net.sf.japi.swing.list.ArrayListModel; +import net.sf.japi.swing.list.ListControlPanel; +import org.junit.Test; + +/** Test for {@link ListControlPanel}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ListControlPanelTest { + + /** Tests that a ListControlPanel works. */ + @Test + public void testListControlPanel() { + final ArrayListModel<String> model = new ArrayListModel<String>(); + model.add("foo"); + model.add("bar"); + model.add("buzz"); + final JList list = new JList(model); + final JFrame f = new JFrame("Test"); + final ListControlPanel testling = new ListControlPanel(list, model); + f.add(new JScrollPane(list)); + f.add(testling, BorderLayout.LINE_END); + f.pack(); + f.setVisible(true); + try { + Thread.sleep(100000); + } catch (final InterruptedException ignore) { + // ignore + } + } + +} // class ListControlPanelTest Property changes on: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ListControlPanelTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-14 09:49:50
|
Revision: 534 http://svn.sourceforge.net/japi/?rev=534&view=rev Author: christianhujer Date: 2007-07-14 02:49:47 -0700 (Sat, 14 Jul 2007) Log Message: ----------- Added swing-list. Added Paths: ----------- libs/swing-list/ libs/swing-list/trunk/ libs/swing-list/trunk/libs-swing-list.iml libs/swing-list/trunk/src/ libs/swing-list/trunk/src/net/ libs/swing-list/trunk/src/net/sf/ libs/swing-list/trunk/src/net/sf/japi/ libs/swing-list/trunk/src/net/sf/japi/swing/ libs/swing-list/trunk/src/net/sf/japi/swing/list/ libs/swing-list/trunk/src/net/sf/japi/swing/list/AbstractMutableListModel.java libs/swing-list/trunk/src/net/sf/japi/swing/list/ArrayListModel.java libs/swing-list/trunk/src/net/sf/japi/swing/list/MutableListModel.java libs/swing-list/trunk/src/net/sf/japi/swing/list/package-info.java libs/swing-list/trunk/src/test/ libs/swing-list/trunk/src/test/net/ libs/swing-list/trunk/src/test/net/sf/ libs/swing-list/trunk/src/test/net/sf/japi/ libs/swing-list/trunk/src/test/net/sf/japi/swing/ libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ArrayListModelTest.java libs/swing-list/trunk/src/test/net/sf/japi/swing/list/MockListDataListener.java libs/swing-list/trunk/src/test/net/sf/japi/swing/list/package-info.java Property changes on: libs/swing-list/trunk ___________________________________________________________________ Name: svn:ignore + classes dest developer.properties dist docs Name: svn:externals + common https://japi.svn.sourceforge.net/svnroot/japi/common/trunk Added: libs/swing-list/trunk/libs-swing-list.iml =================================================================== --- libs/swing-list/trunk/libs-swing-list.iml (rev 0) +++ libs/swing-list/trunk/libs-swing-list.iml 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,191 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module relativePaths="true" type="JAVA_MODULE" version="4"> + <component name="ModuleRootManager" /> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" packagePrefix="test" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="library" name="annotations" level="project" /> + <orderEntry type="library" name="junit" level="project" /> + <orderEntry type="module" module-name="libs-swing-action" /> + <orderEntryProperties /> + </component> + <component name="copyright"> + <Base> + <setting name="state" value="0" /> + </Base> + <LanguageOptions name="$TEMPLATE$"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="JAPI libs-swing-list is a library for lists in swing. Copyright (C) &#36;today.year Christian Hujer. This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version. This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA" /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="4" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="CSS"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="HTML"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JAVA"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JSP"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JavaScript"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="Properties"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="XML"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + </component> +</module> + Property changes on: libs/swing-list/trunk/libs-swing-list.iml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/net/sf/japi/swing/list/AbstractMutableListModel.java =================================================================== --- libs/swing-list/trunk/src/net/sf/japi/swing/list/AbstractMutableListModel.java (rev 0) +++ libs/swing-list/trunk/src/net/sf/japi/swing/list/AbstractMutableListModel.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,28 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.swing.list; + +import javax.swing.AbstractListModel; + +/** The abstract definition for the data model that provides a List with its contents in a mutable fashion. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public abstract class AbstractMutableListModel<E> extends AbstractListModel implements MutableListModel<E> { +} // class AbstractMutableListModel Property changes on: libs/swing-list/trunk/src/net/sf/japi/swing/list/AbstractMutableListModel.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/net/sf/japi/swing/list/ArrayListModel.java =================================================================== --- libs/swing-list/trunk/src/net/sf/japi/swing/list/ArrayListModel.java (rev 0) +++ libs/swing-list/trunk/src/net/sf/japi/swing/list/ArrayListModel.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,174 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.swing.list; + +import java.util.List; +import java.util.ArrayList; +import org.jetbrains.annotations.Nullable; + +/** + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ArrayListModel<E> extends AbstractMutableListModel<E> { + + /** The ArrayList that backs this ArrayListModel. */ + private final List<E> list = new ArrayList<E>(); + + /** Creates a new ArrayListModel. + */ + public ArrayListModel() { + } + + /** {@inheritDoc} */ + public int getSize() { + return list.size(); + } + + /** {@inheritDoc} */ + public E getElementAt(final int index) { + return list.get(index); + } + + /** {@inheritDoc} */ + public boolean add(final E e) { + if (list.contains(e)) { + return false; + } + final int index; + final boolean retVal; + synchronized (list) { + index = list.size(); + retVal = list.add(e); + } + fireIntervalAdded(this, index, index); + return retVal; + } + + /** {@inheritDoc} */ + public boolean remove(final E e) { + if (!list.contains(e)) { + return false; + } + final int index; + final boolean retVal; + synchronized (list) { + index = list.indexOf(e); + retVal = list.remove(e); + } + fireIntervalRemoved(this, index, index); + return retVal; + } + + /** {@inheritDoc} */ + public boolean moveToTop(final E e) { + synchronized (list) { + if (!list.contains(e)) { + throw new IllegalArgumentException("Element " + e + " not part of " + this); + } + final int oldIndex = list.indexOf(e); + final int newIndex = 0; + return move(e, oldIndex, newIndex); + } + + } + + /** {@inheritDoc} */ + public boolean moveToTop(final int index) { + synchronized (list) { + return move(null, index, 0); + } + } + + /** {@inheritDoc} */ + public boolean moveUp(final E e) { + synchronized (list) { + if (!list.contains(e)) { + throw new IllegalArgumentException("Element " + e + " not part of " + this); + } + final int oldIndex = list.indexOf(e); + final int newIndex = oldIndex - 1; + return move(e, oldIndex, newIndex); + } + } + + /** {@inheritDoc} */ + public boolean moveUp(final int index) { + synchronized (list) { + return move(null, index, index - 1); + } + } + + /** {@inheritDoc} */ + public boolean moveDown(final E e) { + synchronized (list) { + if (!list.contains(e)) { + throw new IllegalArgumentException("Element " + e + " not part of " + this); + } + final int oldIndex = list.indexOf(e); + final int newIndex = oldIndex + 1; + return move(e, oldIndex, newIndex); + } + } + + /** {@inheritDoc} */ + public boolean moveDown(final int index) { + synchronized (list) { + return move(null, index, index + 1); + } + } + + /** {@inheritDoc} */ + public boolean moveToBottom(final E e) { + synchronized (list) { + if (!list.contains(e)) { + throw new IllegalArgumentException("Element " + e + " not part of " + this); + } + final int oldIndex = list.indexOf(e); + final int newIndex = list.size() - 1; + return move(e, oldIndex, newIndex); + } + } + + /** {@inheritDoc} */ + public boolean moveToBottom(final int index) { + synchronized (list) { + return move(null, index, list.size() - 1); + } + } + + /** Performs the move operation of an element. + * @param e Element to move + * @param oldIndex old index of the element + * @param newIndex new index of the element + * @return <code>true</code> if the element was moved and the event was fired, otherwise <code>false</code>. + */ + private boolean move(@Nullable final E e, final int oldIndex, final int newIndex) { + if (oldIndex == newIndex || oldIndex < 0 || newIndex < 0 || newIndex >= list.size()) { + return false; + } + assert e == null || list.indexOf(e) == oldIndex; + final E moving = list.remove(oldIndex); + list.add(newIndex, moving); + assert e == null || list.indexOf(e) == newIndex; + fireContentsChanged(this, oldIndex, newIndex); + return true; + } + +} // class ArrayListModel Property changes on: libs/swing-list/trunk/src/net/sf/japi/swing/list/ArrayListModel.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/net/sf/japi/swing/list/MutableListModel.java =================================================================== --- libs/swing-list/trunk/src/net/sf/japi/swing/list/MutableListModel.java (rev 0) +++ libs/swing-list/trunk/src/net/sf/japi/swing/list/MutableListModel.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,92 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.swing.list; + +import javax.swing.ListModel; + +/** A MutableListModel is a list model that additionally provides operations for adding and moving the list's elements. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public interface MutableListModel<E> extends ListModel { + + /** {@inheritDoc} */ + E getElementAt(final int index); + + /** Addes the specified element to this model. + * @param e Element to add. + * @return <code>true</code> if the element was successfully added, otherwise <code>false</code>. + */ + boolean add(E e); + + /** Removes the specified element from this model. + * @param e Element to remove. + * @return <code>true</code> if the element was successfully removed, otherwise <code>false</code>. + */ + boolean remove(E e); + + /** Moves the specified element to top. + * @param e Element to move to top. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveToTop(E e); + + /** Moves the element with the specified index to top. + * @param index Index of the element to move to top. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveToTop(int index); + + /** Moves the specified element up. + * @param e Element to move up. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveUp(E e); + + /** Moves the element with the specified index up. + * @param index Index of the element to move up. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveUp(int index); + + /** Moves the specified element down. + * @param e Element to move down. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveDown(E e); + + /** Moves the element with the specified index down. + * @param index Index of the element to move down. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveDown(int index); + + /** Moves the specified element to bottom. + * @param e Element to move to bottom. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveToBottom(E e); + + /** Moves the element with the specified index to bottom. + * @param index Index of the element to move to bottom. + * @return <code>true</code> if the move was successful, otherwise <code>false</code>. + */ + boolean moveToBottom(int index); + +} // interface MutableListModel Property changes on: libs/swing-list/trunk/src/net/sf/japi/swing/list/MutableListModel.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/net/sf/japi/swing/list/package-info.java =================================================================== --- libs/swing-list/trunk/src/net/sf/japi/swing/list/package-info.java (rev 0) +++ libs/swing-list/trunk/src/net/sf/japi/swing/list/package-info.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,20 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.swing.list; Property changes on: libs/swing-list/trunk/src/net/sf/japi/swing/list/package-info.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ArrayListModelTest.java =================================================================== --- libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ArrayListModelTest.java (rev 0) +++ libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ArrayListModelTest.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,242 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package test.net.sf.japi.swing.list; + +import javax.swing.event.ListDataEvent; +import net.sf.japi.swing.list.ArrayListModel; +import org.jetbrains.annotations.NotNull; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; +import org.junit.Test; + +/** Test for {@link ArrayListModel}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class ArrayListModelTest { + + /** Tests that an empty ArrayListModel behaves as expected. */ + @Test + public void testEmpty() { + final ArrayListModel testling = new ArrayListModel(); + assertEquals("Newly created ArrayListModel must contain no elements.", 0, testling.getSize()); + } + + /** Tests that an ArrayListModel with one element behaves as expected. */ + @Test + public void testSingle() { + final ArrayListModel<String> testling = new ArrayListModel<String>(); + final String foo = "foo"; + testling.add(foo); + assertEquals("ArrayListModel now must contain one element.", 1, testling.getSize()); + assertSame("ArrayListModel must return the stored element.", foo, testling.getElementAt(0)); + } + + /** Tests that an ArrayListModel with one element does not accept duplicates. */ + @Test + public void testSingleDuplicate() { + final ArrayListModel<String> testling = new ArrayListModel<String>(); + final String foo = "foo"; + testling.add(foo); + testling.add(foo); + assertEquals("ArrayListModel now must contain one element.", 1, testling.getSize()); + assertSame("ArrayListModel must return the stored element.", foo, testling.getElementAt(0)); + } + + /** Tests that the move operations with elements work as expected for non-exception cases. */ + @Test + public void testMoveElement() { + final ArrayListModel<String> testling = new ArrayListModel<String>(); + final String test1 = "Test1"; + final String test2 = "Test2"; + final String test3 = "Test3"; + final String test4 = "Test4"; + final String test5 = "Test5"; + assertTrue("Adding " + test1 + " must work.", testling.add(test1)); + assertTrue("Adding " + test1 + " must work.", testling.add(test2)); + assertTrue("Adding " + test1 + " must work.", testling.add(test3)); + assertTrue("Adding " + test1 + " must work.", testling.add(test4)); + assertTrue("Adding " + test1 + " must work.", testling.add(test5)); + assertMove("Original order must match.", testling, test1, test2, test3, test4, test5); + assertTrue("Moving " + test5 + " to top must work.", testling.moveToTop(test5)); + assertMove("Test5 now must be first.", testling, test5, test1, test2, test3, test4); + assertFalse("Moving " + test5 + " to top must fail.", testling.moveToTop(test5)); + assertMove("Test5 now must still be first.", testling, test5, test1, test2, test3, test4); + assertTrue("Moving " + test5 + " down must work.", testling.moveDown(test5)); + assertMove("Test5 now must be second.", testling, test1, test5, test2, test3, test4); + assertTrue("Moving " + test5 + " down must work.", testling.moveDown(test5)); + assertMove("Test5 now must be third.", testling, test1, test2, test5, test3, test4); + assertTrue("Moving " + test5 + " down must work.", testling.moveDown(test5)); + assertMove("Test5 now must be fourth.", testling, test1, test2, test3, test5, test4); + assertTrue("Moving " + test5 + " down must work.", testling.moveDown(test5)); + assertMove("Test5 now must be last.", testling, test1, test2, test3, test4, test5); + assertFalse("Moving " + test5 + " down must work.", testling.moveDown(test5)); + assertMove("Test5 now still must be last.", testling, test1, test2, test3, test4, test5); + assertTrue("Moving " + test5 + " up must work.", testling.moveUp(test5)); + assertMove("Test5 now must be fourth.", testling, test1, test2, test3, test5, test4); + assertTrue("Moving " + test5 + " up must work.", testling.moveUp(test5)); + assertMove("Test5 now must be third.", testling, test1, test2, test5, test3, test4); + assertTrue("Moving " + test5 + " up must work.", testling.moveUp(test5)); + assertMove("Test5 now must be second.", testling, test1, test5, test2, test3, test4); + assertTrue("Moving " + test5 + " up must work.", testling.moveUp(test5)); + assertMove("Test5 now must be first.", testling, test5, test1, test2, test3, test4); + assertFalse("Moving " + test5 + " up must fail.", testling.moveUp(test5)); + assertMove("Test5 now still must be first.", testling, test5, test1, test2, test3, test4); + assertTrue("Moving " + test5 + " to bottom must work.", testling.moveToBottom(test5)); + assertMove("Test5 now must be last.", testling, test1, test2, test3, test4, test5); + assertFalse("Moving " + test5 + " to bottom must fail.", testling.moveToBottom(test5)); + assertMove("Test5 now must still be last.", testling, test1, test2, test3, test4, test5); + } + + /** Tests that the move operations with indices work as expected for non-exception cases. */ + @Test + public void testMoveIndex() { + final ArrayListModel<String> testling = new ArrayListModel<String>(); + final String test1 = "Test1"; + final String test2 = "Test2"; + final String test3 = "Test3"; + final String test4 = "Test4"; + final String test5 = "Test5"; + testling.add(test1); + testling.add(test2); + testling.add(test3); + testling.add(test4); + testling.add(test5); + assertMove("Original order must match.", testling, test1, test2, test3, test4, test5); + assertTrue("Moving >0 to top must work.", testling.moveToTop(4)); + assertMove("Test5 now must be first.", testling, test5, test1, test2, test3, test4); + assertFalse("Moving 0 to top must fail.", testling.moveToTop(0)); + assertMove("Test5 now must still be first.", testling, test5, test1, test2, test3, test4); + assertTrue("Moving <end down must work.", testling.moveDown(0)); + assertMove("Test5 now must be second.", testling, test1, test5, test2, test3, test4); + assertTrue("Moving <end down must work.", testling.moveDown(1)); + assertMove("Test5 now must be third.", testling, test1, test2, test5, test3, test4); + assertTrue("Moving <end down must work.", testling.moveDown(2)); + assertMove("Test5 now must be fourth.", testling, test1, test2, test3, test5, test4); + assertTrue("Moving <end down must work.", testling.moveDown(3)); + assertMove("Test5 now must be last.", testling, test1, test2, test3, test4, test5); + assertFalse("Moving end down must fail.", testling.moveDown(4)); + assertMove("Test5 now still must be last.", testling, test1, test2, test3, test4, test5); + assertTrue("Moving >0 up must work.", testling.moveUp(4)); + assertMove("Test5 now must be fourth.", testling, test1, test2, test3, test5, test4); + assertTrue("Moving >0 up must work.", testling.moveUp(3)); + assertMove("Test5 now must be third.", testling, test1, test2, test5, test3, test4); + assertTrue("Moving >0 up must work.", testling.moveUp(2)); + assertMove("Test5 now must be second.", testling, test1, test5, test2, test3, test4); + assertTrue("Moving >0 up must work.", testling.moveUp(1)); + assertMove("Test5 now must be first.", testling, test5, test1, test2, test3, test4); + assertFalse("Moving 0 up must fail.", testling.moveUp(0)); + assertMove("Test5 now still must be first.", testling, test5, test1, test2, test3, test4); + assertTrue("Moving <end to bottom must work.", testling.moveToBottom(0)); + assertMove("Test5 now must be last.", testling, test1, test2, test3, test4, test5); + assertFalse("Moving end to bottom must fail.", testling.moveToBottom(4)); + assertMove("Test5 now must still be last.", testling, test1, test2, test3, test4, test5); + } + + /** Tests that add and remove operations fire the correct events. */ + @Test + public void testAddRemoveEvents() { + final ArrayListModel<String> testling = new ArrayListModel<String>(); + final String test1 = "Test1"; + final String test2 = "Test2"; + final String test3 = "Test3"; + final String test4 = "Test4"; + final MockListDataListener listenerMock = new MockListDataListener(); + testling.addListDataListener(listenerMock); + testling.add(test1); + listenerMock.assertEvent(ListDataEvent.INTERVAL_ADDED, 0, 0); + testling.add(test2); + listenerMock.assertEvent(ListDataEvent.INTERVAL_ADDED, 1, 1); + testling.add(test3); + listenerMock.assertEvent(ListDataEvent.INTERVAL_ADDED, 2, 2); + testling.removeListDataListener(listenerMock); + testling.add(test4); + listenerMock.assertNoEvent(); + testling.addListDataListener(listenerMock); + testling.remove(test1); + listenerMock.assertEvent(ListDataEvent.INTERVAL_REMOVED, 0, 0); + testling.remove(test4); + listenerMock.assertEvent(ListDataEvent.INTERVAL_REMOVED, 2, 2); + testling.removeListDataListener(listenerMock); + testling.remove(test3); + listenerMock.assertNoEvent(); + } + + /** Tests that move element operations fire the correct events. */ + @Test + public void testMoveElementEvents() { + final ArrayListModel<String> testling = new ArrayListModel<String>(); + final String test1 = "Test1"; + final String test2 = "Test2"; + final String test3 = "Test3"; + final String test4 = "Test4"; + final String test5 = "Test5"; + final MockListDataListener listenerMock = new MockListDataListener(); + testling.add(test1); + testling.add(test2); + testling.add(test3); + testling.add(test4); + testling.add(test5); + testling.addListDataListener(listenerMock); + testling.moveToTop(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 0, 4); + testling.moveToTop(test5); + listenerMock.assertNoEvent(); + testling.moveDown(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 0, 1); + testling.moveDown(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 1, 2); + testling.moveDown(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 2, 3); + testling.moveDown(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 3, 4); + testling.moveDown(test5); + listenerMock.assertNoEvent(); + testling.moveUp(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 3, 4); + testling.moveUp(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 2, 3); + testling.moveUp(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 1, 2); + testling.moveUp(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 0, 1); + testling.moveUp(test5); + listenerMock.assertNoEvent(); + testling.moveToBottom(test5); + listenerMock.assertEvent(ListDataEvent.CONTENTS_CHANGED, 0, 4); + testling.moveToBottom(test5); + listenerMock.assertNoEvent(); + testling.removeListDataListener(listenerMock); + } + + /** Asserts a certain size and order after a move. + * @param message Message to issue in case the size and order are not as expected. + * @param model Testling to check. + * @param elements Elements in expected order. + */ + public static <E> void assertMove(@NotNull final String message, @NotNull final ArrayListModel<E> model, @NotNull final E... elements) { + assertEquals("ArrayListModel now must contain " + elements.length + " elements.", elements.length, model.getSize()); + for (int i = 0; i < elements.length; i++) { + assertSame(message + " / ArrayList must contain element " + elements[i] + " at index " + i + ".", elements[i], model.getElementAt(i)); + } + } + +} // class ArrayListModelTest Property changes on: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/ArrayListModelTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/MockListDataListener.java =================================================================== --- libs/swing-list/trunk/src/test/net/sf/japi/swing/list/MockListDataListener.java (rev 0) +++ libs/swing-list/trunk/src/test/net/sf/japi/swing/list/MockListDataListener.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,95 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package test.net.sf.japi.swing.list; + +import javax.swing.event.ListDataEvent; +import javax.swing.event.ListDataListener; +import net.sf.japi.swing.list.ArrayListModel; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.fail; + +/** A ListDataListener useful for testing that the event system in {@link ArrayListModel} works. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class MockListDataListener implements ListDataListener { + + /** Last event. */ + @Nullable + private ListDataEvent lastEvent; + + /** {@inheritDoc} */ + public void intervalAdded(@NotNull final ListDataEvent e) { + lastEvent = e; + assertEquals("intervalAdded() must be invoked with a ListDataEvent of type INTERVAL_ADDED.", ListDataEvent.INTERVAL_ADDED, e.getType()); + } + + /** {@inheritDoc} */ + public void intervalRemoved(@NotNull final ListDataEvent e) { + lastEvent = e; + assertEquals("intervalRemoved() must be invoked with a ListDataEvent of type INTERVAL_REMOVED.", ListDataEvent.INTERVAL_REMOVED, e.getType()); + } + + /** {@inheritDoc} */ + public void contentsChanged(@NotNull final ListDataEvent e) { + lastEvent = e; + assertEquals("contentsChanged() must be invoked with a ListDataEvent of type CONTENTS_CHANGED.", ListDataEvent.CONTENTS_CHANGED, e.getType()); + } + + /** Asserts that there was an event and it has the expected properties. + * @param type Type of the event to assert. + * @param index0 Lower bound of the event's range. + * @param index1 Upper bound of the event's range. + */ + public void assertEvent(final int type, final int index0, final int index1) { + @Nullable final ListDataEvent lastEvent = this.lastEvent; + assertNotNull("Expected to have an event.", lastEvent); + assert lastEvent != null; + assertEquals("Expecting last event to be of type " + getTypeName(type) + ".", type, lastEvent.getType()); + assertEquals("Expecting last event to have correct index0.", index0, lastEvent.getIndex0()); + assertEquals("Expecting last event to have correct index1.", index1, lastEvent.getIndex1()); + this.lastEvent = null; + } + + /** Asserts that there was no event. */ + public void assertNoEvent() { + assertNull("Expected to not have an event.", lastEvent); + } + + /** Returns the name of an event type. + * @param type Type to return name for. + * @return Name for <var>type</var> + */ + private static String getTypeName(final int type) { + switch (type) { + case 0: return "CONTENTS_CHANGED"; + case 1: return "INTERVAL_ADDED"; + case 2: return "INTERVAL_REMOVED"; + default: + fail("Internal test error: unexpected event type for check " + type); + assert false; + return ""; // Never reaches this statement, but the compiler expects a return. + } + } + +} // class MockListDataListener Property changes on: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/MockListDataListener.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/package-info.java =================================================================== --- libs/swing-list/trunk/src/test/net/sf/japi/swing/list/package-info.java (rev 0) +++ libs/swing-list/trunk/src/test/net/sf/japi/swing/list/package-info.java 2007-07-14 09:49:47 UTC (rev 534) @@ -0,0 +1,20 @@ +/* + * JAPI libs-swing-list is a library for lists in swing. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package test.net.sf.japi.swing.list; Property changes on: libs/swing-list/trunk/src/test/net/sf/japi/swing/list/package-info.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-13 20:17:34
|
Revision: 533 http://svn.sourceforge.net/japi/?rev=533&view=rev Author: christianhujer Date: 2007-07-13 13:17:32 -0700 (Fri, 13 Jul 2007) Log Message: ----------- Improved test documentation. The text about what a test does now is more clear. Modified Paths: -------------- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/MethodOptionComparatorTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -42,7 +42,7 @@ public class ArgParserTest { /** - * Tests whether {@link ArgParser#getOptionMethods(Command)} works. + * Tests that {@link ArgParser#getOptionMethods(Command)} works. * @throws Exception (unexpected) */ @Test @@ -53,7 +53,7 @@ } /** - * Tests whether {@link ArgParser#getOptionMethods(Class)} works. + * Tests that {@link ArgParser#getOptionMethods(Class)} works. * @throws Exception (unexpected) */ @Test @@ -63,7 +63,7 @@ } /** - * Tests whether {@link ArgParser#simpleParseAndRun(Command, String[])} works. + * Tests that {@link ArgParser#simpleParseAndRun(Command, String[])} works. * @throws Exception (unexpected) */ @Test @@ -73,7 +73,7 @@ } /** - * Tests whether {@link ArgParser#parseAndRun(Command, String[])} works. + * Tests that {@link ArgParser#parseAndRun(Command, String[])} works. * @throws Exception (unexpected) */ @Test @@ -83,7 +83,7 @@ } /** - * Tests whether supplying a required option with argument in short form works. + * Tests that supplying a required option with argument in short form works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -99,7 +99,7 @@ } /** - * Tests whether supplying a required option with argument in long form with separate argument works. + * Tests that supplying a required option with argument in long form with separate argument works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -115,7 +115,7 @@ } /** - * Tests whether supplying a required option with argument in long form with integrated argument works. + * Tests that supplying a required option with argument in long form with integrated argument works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -131,7 +131,7 @@ } /** - * Tests whether it's detected that a required option is missing. + * Tests that it's detected that a required option is missing. * @throws RequiredOptionsMissingException (expected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -148,7 +148,7 @@ } /** - * Tests whether it's not detected that a required option is missing if the command doesn't want it. + * Tests that it's not detected that a required option is missing if the command doesn't want it. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -163,7 +163,7 @@ } /** - * Tests whether it's detected that an unknown option was given. + * Tests that it's detected that an unknown option was given. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (expected) @@ -180,7 +180,7 @@ } /** - * Tests whether it's detected that the argument of an option that requires an argument is missing. + * Tests that it's detected that the argument of an option that requires an argument is missing. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -197,7 +197,7 @@ } /** - * Tests whether specifying an option twice works. + * Tests that specifying an option twice works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -213,7 +213,7 @@ } /** - * Tests whether help works. + * Tests that help works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (expected) * @throws UnknownOptionException (unexpected) @@ -226,7 +226,7 @@ } /** - * Tests whether stopping option parsing with -- works. + * Tests that stopping option parsing with -- works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) @@ -242,7 +242,7 @@ } /** - * Tests whether reading options from a file works. + * Tests that reading options from a file works. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/BasicCommandTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -19,11 +19,11 @@ package test.net.sf.japi.io.args; +import java.util.ArrayList; +import java.util.ResourceBundle; import net.sf.japi.io.args.BasicCommand; import org.junit.Assert; import org.junit.Test; -import java.util.ArrayList; -import java.util.ResourceBundle; /** * Test for {@link BasicCommand}. @@ -33,7 +33,7 @@ public class BasicCommandTest { /** - * Tests whether {@link BasicCommand#BasicCommand()} works. + * Tests that {@link BasicCommand#BasicCommand()} works. * @throws Exception (unexpected) */ @Test @@ -43,7 +43,7 @@ } /** - * Tests whether {@link BasicCommand#setExiting(Boolean)} works. + * Tests that {@link BasicCommand#setExiting(Boolean)} works. * @throws Exception (unexpected) */ @Test @@ -56,7 +56,7 @@ } /** - * Tests whether {@link BasicCommand#isExiting()} works. + * Tests that {@link BasicCommand#isExiting()} works. * @throws Exception (unexpected) */ @Test @@ -65,7 +65,7 @@ } /** - * Tests whether {@link BasicCommand#help()} works. + * Tests that {@link BasicCommand#help()} works. * @throws Exception (unexpected) */ @Test @@ -75,7 +75,7 @@ } /** - * Tests whether {@link BasicCommand#getBundle()} works. + * Tests that {@link BasicCommand#getBundle()} works. * @throws Exception (unexpected) */ @Test @@ -86,7 +86,7 @@ } /** - * Tests whether {@link BasicCommand#getString(String)} returns the value from the correct bundle. + * Tests that {@link BasicCommand#getString(String)} returns the value from the correct bundle. * testGetString1 must be defined in RBMockCommand.properties with value String1FromDefaultBundle. * testGetString1 must be defined in RBMockCommandMyBundle.properties with value String1FromMyBundle. * testGetString2 must be defined in RBMockCommand.properties with value String2FromDefaultBundle. @@ -104,7 +104,7 @@ } /** - * Tests whether {@link BasicCommand#getHelpHeader()} returns the value from the correct bundle. + * Tests that {@link BasicCommand#getHelpHeader()} returns the value from the correct bundle. */ @Test public void testGetHelpHeader() { Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/MethodOptionComparatorTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/MethodOptionComparatorTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/MethodOptionComparatorTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -35,7 +35,7 @@ */ public class MethodOptionComparatorTest { - /** Tests whether comparing two methods yields the expected result. + /** Tests that comparing two methods yields the expected result. * @throws NoSuchMethodException (unexpected) */ @Test @@ -53,7 +53,7 @@ Assert.assertTrue("-f / --foo must be sorted before -Z.", comparator.compare(mFoo, mZ) < 0); } - /** Tests whether comparing two methods that only differ in case yields the difference. + /** Tests that comparing two methods that only differ in case yields the difference. * Test for <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1748308&group_id=149894&atid=776737">[ 1748308 ] Options that only differ in case are not listed in --help</a> * @throws NoSuchMethodException (unexpected) */ Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/MissingArgumentExceptionTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -31,7 +31,7 @@ public class MissingArgumentExceptionTest { /** - * Tests whether {@link MissingArgumentException#MissingArgumentException(String)} works. + * Tests that {@link MissingArgumentException#MissingArgumentException(String)} works. * @throws Exception (unexpected) */ @Test @@ -41,7 +41,7 @@ } /** - * Tests whether {@link MissingArgumentException#getOption()} works. + * Tests that {@link MissingArgumentException#getOption()} works. * @throws Exception (unexpected) */ @Test Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/OptionTypeTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -19,10 +19,10 @@ package test.net.sf.japi.io.args; +import java.util.Locale; import net.sf.japi.io.args.OptionType; import org.junit.Assert; import org.junit.Test; -import java.util.Locale; /** * Test for {@link OptionType}. @@ -32,7 +32,7 @@ public class OptionTypeTest { /** - * Tests whether {@link OptionType#getName()} and {@link OptionType#getName(Locale)} work. + * Tests that {@link OptionType#getName()} and {@link OptionType#getName(Locale)} work. * @throws Exception (unexpected) */ @Test @@ -46,7 +46,7 @@ } /** - * Tests whether {@link OptionType#toString()} works. + * Tests that {@link OptionType#toString()} works. * @throws Exception (unexpected) */ @Test @@ -57,7 +57,7 @@ } /** - * Tests whether {@link OptionType#getDescription()} and {@link OptionType#getDescription(Locale)} work. + * Tests that {@link OptionType#getDescription()} and {@link OptionType#getDescription(Locale)} work. * @throws Exception (unexpected) */ @Test Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/RequiredOptionsMissingExceptionTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -19,10 +19,10 @@ package test.net.sf.japi.io.args; +import java.util.Arrays; import net.sf.japi.io.args.RequiredOptionsMissingException; import org.junit.Assert; import org.junit.Test; -import java.util.Arrays; /** * Test for {@link RequiredOptionsMissingException}. @@ -32,7 +32,7 @@ public class RequiredOptionsMissingExceptionTest { /** - * Tests whether {@link RequiredOptionsMissingException#RequiredOptionsMissingException(String[])} works. + * Tests that {@link RequiredOptionsMissingException#RequiredOptionsMissingException(String[])} works. * @throws Exception (unexpected) */ @Test @@ -43,7 +43,7 @@ } /** - * Tests whether {@link RequiredOptionsMissingException#getMissingOptions()} works. + * Tests that {@link RequiredOptionsMissingException#getMissingOptions()} works. * @throws Exception (unexpected) */ @Test Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/StringJoinerTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -43,7 +43,7 @@ private static final String[] ARGS = {"foo", "bar", "buzz"}; /** - * Tests whether {@link StringJoiner#join(CharSequence,CharSequence...)} works. + * Tests that {@link StringJoiner#join(CharSequence,CharSequence...)} works. */ @Test public void testJoinCSCS() { @@ -54,7 +54,7 @@ } /** - * Tests whether {@link StringJoiner#join(CharSequence,Iterable<? extends java.lang.CharSequence>)} works. + * Tests that {@link StringJoiner#join(CharSequence,Iterable<? extends java.lang.CharSequence>)} works. */ @Test public void testJoinCSIe() { @@ -65,7 +65,7 @@ } /** - * Tests whether {@link StringJoiner#join(CharSequence,java.util.Iterator<? extends java.lang.CharSequence>)} works. + * Tests that {@link StringJoiner#join(CharSequence,java.util.Iterator<? extends java.lang.CharSequence>)} works. */ @Test public void testJoinCSIr() { Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/TerminalExceptionTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -31,7 +31,7 @@ public class TerminalExceptionTest { /** - * Tests whether {@link TerminalException#TerminalException()} works. + * Tests that {@link TerminalException#TerminalException()} works. * @throws Exception (unexpected) */ @Test @@ -41,7 +41,7 @@ } /** - * Tests whether {@link TerminalException#getReturnCode()} works. + * Tests that {@link TerminalException#getReturnCode()} works. * @throws Exception (unexpected) */ @Test Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java 2007-07-13 20:14:47 UTC (rev 532) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/UnknownOptionExceptionTest.java 2007-07-13 20:17:32 UTC (rev 533) @@ -19,10 +19,10 @@ package test.net.sf.japi.io.args; +import java.util.Arrays; import net.sf.japi.io.args.UnknownOptionException; import org.junit.Assert; import org.junit.Test; -import java.util.Arrays; /** * Test for {@link UnknownOptionException}. @@ -32,7 +32,7 @@ public class UnknownOptionExceptionTest { /** - * Tests whether {@link UnknownOptionException#UnknownOptionException(String[])} works. + * Tests that {@link UnknownOptionException#UnknownOptionException(String[])} works. * @throws Exception (unexpected) */ @Test @@ -43,7 +43,7 @@ } /** - * Tests whether {@link UnknownOptionException#getUnknownOptions()} works. + * Tests that {@link UnknownOptionException#getUnknownOptions()} works. * @throws Exception (unexpected) */ @Test This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-13 20:14:49
|
Revision: 532 http://svn.sourceforge.net/japi/?rev=532&view=rev Author: christianhujer Date: 2007-07-13 13:14:47 -0700 (Fri, 13 Jul 2007) Log Message: ----------- [ 1751332 ] Required options check should be optional / configurable Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java libs/argparser/trunk/src/net/sf/japi/io/args/Command.java libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-10 19:13:49 UTC (rev 531) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-13 20:14:47 UTC (rev 532) @@ -140,7 +140,7 @@ * @throws RequiredOptionsMissingException in case a required command line argument was missing */ private void checkRequiredMethods() throws RequiredOptionsMissingException { - if (requiredMethods.size() > 0) { + if (command.isCheckRequiredOptions() && requiredMethods.size() > 0) { final List<String> missingOptions = new ArrayList<String>(); for (final Method requiredMethod : requiredMethods) { final Option option = requiredMethod.getAnnotation(Option.class); Modified: libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2007-07-10 19:13:49 UTC (rev 531) +++ libs/argparser/trunk/src/net/sf/japi/io/args/BasicCommand.java 2007-07-13 20:14:47 UTC (rev 532) @@ -21,6 +21,7 @@ import java.lang.reflect.Method; import java.util.ArrayList; +import java.util.Collections; import java.util.Formatter; import java.util.List; import java.util.MissingResourceException; @@ -28,7 +29,6 @@ import java.util.Set; import java.util.SortedSet; import java.util.TreeSet; -import java.util.Collections; import org.jetbrains.annotations.NotNull; /** @@ -46,11 +46,26 @@ */ private boolean exiting; + /** + * Whether to check for required options. + * @see Command#isCheckRequiredOptions() + */ + private boolean checkRequiredOptions = true; + /** Create a BasicCommand. */ protected BasicCommand() { } /** + * {@inheritDoc} + * @see System#exit(int) + * @see #setExiting(Boolean) + */ + @NotNull public Boolean isExiting() { + return exiting; + } + + /** * Exit Option. * Normally you wouldn't override this method. * The default behaviour is to not exit. @@ -66,13 +81,16 @@ this.exiting = exiting; } - /** - * {@inheritDoc} - * @see System#exit(int) - * @see #setExiting(Boolean) + /** {@inheritDoc} */ + public boolean isCheckRequiredOptions() { + return checkRequiredOptions; + } + + /** Sets whether the check for required options should be performed. + * @param checkRequiredOptions <code>true</code> if the check for required options should be performed, otherwise <code>false</code>. */ - @NotNull public Boolean isExiting() { - return exiting; + public void setCheckRequiredOptions(final boolean checkRequiredOptions) { + this.checkRequiredOptions = checkRequiredOptions; } /** Help Option. */ Modified: libs/argparser/trunk/src/net/sf/japi/io/args/Command.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2007-07-10 19:13:49 UTC (rev 531) +++ libs/argparser/trunk/src/net/sf/japi/io/args/Command.java 2007-07-13 20:14:47 UTC (rev 532) @@ -45,4 +45,10 @@ */ Boolean isExiting(); + /** + * Return whether the check for required methods should be performed. + * @return <code>true</code> if {@link ArgParser} should perform a check on required methods on this command, otherwise <code>false</code>. + */ + boolean isCheckRequiredOptions(); + } // interface Command Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-10 19:13:49 UTC (rev 531) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-13 20:14:47 UTC (rev 532) @@ -148,6 +148,21 @@ } /** + * Tests whether it's not detected that a required option is missing if the command doesn't want it. + * @throws RequiredOptionsMissingException (unexpected) + * @throws TerminalException (unexpected) + * @throws UnknownOptionException (unexpected) + * @throws MissingArgumentException (unexpected) + * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1751332&group_id=149894&atid=776740">[ 1751332 ] Required options check should be optional / configurable</a> + */ + @Test + public void testCommandRequiredOptionMissingDisabled() throws RequiredOptionsMissingException, TerminalException, UnknownOptionException, MissingArgumentException { + final MockCommand command = new MockCommand(); + command.setCheckRequiredOptions(false); + ArgParser.parseAndRun(command); + } + + /** * Tests whether it's detected that an unknown option was given. * @throws RequiredOptionsMissingException (unexpected) * @throws TerminalException (unexpected) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-10 19:13:50
|
Revision: 531 http://svn.sourceforge.net/japi/?rev=531&view=rev Author: christianhujer Date: 2007-07-10 12:13:49 -0700 (Tue, 10 Jul 2007) Log Message: ----------- [ 1751333 ] doc files included in exe / lib jars Modified Paths: -------------- common/trunk/commonBuild.xml Modified: common/trunk/commonBuild.xml =================================================================== --- common/trunk/commonBuild.xml 2007-07-09 21:53:16 UTC (rev 530) +++ common/trunk/commonBuild.xml 2007-07-10 19:13:49 UTC (rev 531) @@ -103,7 +103,7 @@ <copy todir="classes/production/${module.shortname}" > - <fileset dir="src" includes="**/*.properties" excludes="test/**/*.properties" /> + <fileset dir="src" includes="net/**/*.properties" /> <fileset dir="src" includes="META-INF/services/**" /> </copy> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 21:53:17
|
Revision: 530 http://svn.sourceforge.net/japi/?rev=530&view=rev Author: christianhujer Date: 2007-07-09 14:53:16 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Enabled cache in checkstyle. Modified Paths: -------------- common/trunk/sun_checks.xml Modified: common/trunk/sun_checks.xml =================================================================== --- common/trunk/sun_checks.xml 2007-07-09 21:44:48 UTC (rev 529) +++ common/trunk/sun_checks.xml 2007-07-09 21:53:16 UTC (rev 530) @@ -52,6 +52,9 @@ <module name="TreeWalker"> + <property name="cacheFile" value="docs/checkstyleCache" /> + + <!-- Checks for Javadoc comments. --> <!-- See http://checkstyle.sf.net/config_javadoc.html --> <!-- Disabled because it throws an exception. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 21:44:50
|
Revision: 529 http://svn.sourceforge.net/japi/?rev=529&view=rev Author: christianhujer Date: 2007-07-09 14:44:48 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Updated default ant target to be all instead of compile. Modified Paths: -------------- libs/argparser/trunk/build.xml libs/io/trunk/build.xml libs/lang/trunk/build.xml libs/logging/trunk/build.xml libs/net/trunk/build.xml libs/registry/trunk/build.xml libs/swing-about/trunk/build.xml libs/swing-action/trunk/build.xml libs/swing-app/trunk/build.xml libs/swing-bookmarks/trunk/build.xml libs/swing-extlib/trunk/build.xml libs/swing-font/trunk/build.xml libs/swing-keyprefs/trunk/build.xml libs/swing-misc/trunk/build.xml libs/swing-prefs/trunk/build.xml libs/swing-proxyprefs/trunk/build.xml libs/swing-recent/trunk/build.xml libs/swing-tod/trunk/build.xml libs/swing-treetable/trunk/build.xml libs/taglets/trunk/build.xml libs/util/trunk/build.xml libs/xml/trunk/build.xml Modified: libs/argparser/trunk/build.xml =================================================================== --- libs/argparser/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/argparser/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib argparser" default="compile"> +<project name="japi lib argparser" default="all"> &commonBuild; Modified: libs/io/trunk/build.xml =================================================================== --- libs/io/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/io/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib net" default="compile"> +<project name="japi lib net" default="all"> &commonBuild; Modified: libs/lang/trunk/build.xml =================================================================== --- libs/lang/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/lang/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib lang" default="compile"> +<project name="japi lib lang" default="all"> &commonBuild; Modified: libs/logging/trunk/build.xml =================================================================== --- libs/logging/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/logging/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib logging" default="compile"> +<project name="japi lib logging" default="all"> &commonBuild; Modified: libs/net/trunk/build.xml =================================================================== --- libs/net/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/net/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib net" default="compile"> +<project name="japi lib net" default="all"> &commonBuild; Modified: libs/registry/trunk/build.xml =================================================================== --- libs/registry/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/registry/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib registry" default="compile"> +<project name="japi lib registry" default="all"> &commonBuild; Modified: libs/swing-about/trunk/build.xml =================================================================== --- libs/swing-about/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-about/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-about" default="compile"> +<project name="japi lib swing-about" default="all"> &commonBuild; Modified: libs/swing-action/trunk/build.xml =================================================================== --- libs/swing-action/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-action/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-action" default="compile"> +<project name="japi lib swing-action" default="all"> &commonBuild; Modified: libs/swing-app/trunk/build.xml =================================================================== --- libs/swing-app/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-app/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-app" default="compile"> +<project name="japi lib swing-app" default="all"> &commonBuild; Modified: libs/swing-bookmarks/trunk/build.xml =================================================================== --- libs/swing-bookmarks/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-bookmarks/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-bookmarks" default="compile"> +<project name="japi lib swing-bookmarks" default="all"> &commonBuild; Modified: libs/swing-extlib/trunk/build.xml =================================================================== --- libs/swing-extlib/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-extlib/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-extlib" default="compile"> +<project name="japi lib swing-extlib" default="all"> &commonBuild; Modified: libs/swing-font/trunk/build.xml =================================================================== --- libs/swing-font/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-font/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-font" default="compile"> +<project name="japi lib swing-font" default="all"> &commonBuild; Modified: libs/swing-keyprefs/trunk/build.xml =================================================================== --- libs/swing-keyprefs/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-keyprefs/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-keyprefs" default="compile"> +<project name="japi lib swing-keyprefs" default="all"> &commonBuild; Modified: libs/swing-misc/trunk/build.xml =================================================================== --- libs/swing-misc/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-misc/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing misc" default="compile"> +<project name="japi lib swing misc" default="all"> &commonBuild; Modified: libs/swing-prefs/trunk/build.xml =================================================================== --- libs/swing-prefs/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-prefs/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-prefs" default="compile"> +<project name="japi lib swing-prefs" default="all"> &commonBuild; Modified: libs/swing-proxyprefs/trunk/build.xml =================================================================== --- libs/swing-proxyprefs/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-proxyprefs/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-proxyprefs" default="compile"> +<project name="japi lib swing-proxyprefs" default="all"> &commonBuild; Modified: libs/swing-recent/trunk/build.xml =================================================================== --- libs/swing-recent/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-recent/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-recent" default="compile"> +<project name="japi lib swing-recent" default="all"> &commonBuild; Modified: libs/swing-tod/trunk/build.xml =================================================================== --- libs/swing-tod/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-tod/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-tod" default="compile"> +<project name="japi lib swing-tod" default="all"> &commonBuild; Modified: libs/swing-treetable/trunk/build.xml =================================================================== --- libs/swing-treetable/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/swing-treetable/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib swing-treetable" default="compile"> +<project name="japi lib swing-treetable" default="all"> &commonBuild; Modified: libs/taglets/trunk/build.xml =================================================================== --- libs/taglets/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/taglets/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib taglets" default="compile"> +<project name="japi lib taglets" default="all"> &commonBuild; Modified: libs/util/trunk/build.xml =================================================================== --- libs/util/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/util/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib util" default="compile"> +<project name="japi lib util" default="all"> &commonBuild; Modified: libs/xml/trunk/build.xml =================================================================== --- libs/xml/trunk/build.xml 2007-07-09 21:36:57 UTC (rev 528) +++ libs/xml/trunk/build.xml 2007-07-09 21:44:48 UTC (rev 529) @@ -20,7 +20,7 @@ <!DOCTYPE project [ <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> ]> -<project name="japi lib xml" default="compile"> +<project name="japi lib xml" default="all"> &commonBuild; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 21:36:59
|
Revision: 528 http://svn.sourceforge.net/japi/?rev=528&view=rev Author: christianhujer Date: 2007-07-09 14:36:57 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Sorted items alphabetically. Introduced new all target that should replace compile with most callers. Modified Paths: -------------- common/trunk/commonBuild.xml Modified: common/trunk/commonBuild.xml =================================================================== --- common/trunk/commonBuild.xml 2007-07-09 21:28:03 UTC (rev 527) +++ common/trunk/commonBuild.xml 2007-07-09 21:36:57 UTC (rev 528) @@ -3,14 +3,19 @@ <!-- ~ Common build.xml for use in multiple projects. ~ + ~ Note: + ~ Taskdefs and targets are sorted alphabetically. + ~ Properties are also sorted alphabetically unless they depend on each other. + ~ ~ @author <a href="mailto:ch...@ri...">Christian Hujer</a> --> +<property file="developer.properties" /> <property file="module.properties" /> -<property file="developer.properties" /> + +<property name="commonPath" value="common" /> <property name="distName" value="${module.name}-${module.version}" /> <property name="distPath" value="dist/${distName}" /> -<property name="commonPath" value="common" /> <property name="javaversion" value="1.5" /> <path id="class.path"> @@ -18,11 +23,60 @@ <fileset dir="${commonPath}" includes="lib/*.jar" excludes="lib/LICENSE-*.jar" /> </path> +<taskdef classpath="${commonPath}/antlib/checkstyle-all-4.3.jar" resource="checkstyletask.properties" /> +<taskdef name="freshmeat" classpath="${commonPath}/antlib/antmeat.jar" classname="de.frewert.ant.freshmeat.Announcement" /> <taskdef name="pack200" classpath="${commonPath}/antlib/Pack200Task.jar" classname="com.sun.tools.apache.ant.pack200.Pack200Task" /> -<taskdef name="freshmeat" classpath="${commonPath}/antlib/antmeat.jar" classname="de.frewert.ant.freshmeat.Announcement" /> -<taskdef classpath="${commonPath}/antlib/checkstyle-all-4.3.jar" resource="checkstyletask.properties" /> +<!-- targets are sorted alphabetically. --> + <target + name = "all" + description = "incrementally executes all standard build targets." + depends = "compile, checkstyle, test" +/> + +<target + name = "announce" + description = "announce new version on freshmeat.net" +> + <echo>Announcing. Press return to start announcing this release at FreshMeat.</echo> + <input /> + <echo><![CDATA[ + <freshmeat + username = "${user.freshmeat.username}" + password = "${user.freshmeat.password}" + > + <printlicenses/> + <printreleasefoci/> + <publish + projectname = "japi" + branchname = "${module.name}" + version = "${module.version}" + focus = "${update.focus}" + > + <changes file="LatestNews" /> + <urlblock + homepage = "http://japi.sourceforge.net/" + cvs = "http://cvs.sourceforge.net/viewcvs.py/japi/" + mailinglist = "http://sourceforge.net/mailarchive/forum.php?forum=japi-users" + tgz = "http://prdownloads.sourceforge.net/japi/${distName}.src.tar.gz?download" + bz2 = "http://prdownloads.sourceforge.net/japi/${distName}.src.tar.bz2?download" + zip = "http://prdownloads.sourceforge.net/japi/${distName}.src.zip?download" + /> + </publish> + </freshmeat> + ]]></echo> +</target> + +<target name="checkstyle" description="Runs checkstyle over the source code."> + <checkstyle + config="${commonPath}/sun_checks.xml" + > + <fileset dir="src" includes="**/*.java,**/*.properties" /> + </checkstyle> +</target> + +<target name = "clean" description = "Cleans Sandbox" > @@ -54,56 +108,92 @@ </copy> </target> -<target name="checkstyle" description="Runs checkstyle over the source code."> - <checkstyle - config="${commonPath}/sun_checks.xml" - > - <fileset dir="src" includes="**/*.java,**/*.properties" /> - </checkstyle> +<target + name = "dist" + description = "Creates and packs distribution archives." + depends = "clean, compile, checkstyle, test, doc" +> + <delete dir="dist" /> + <mkdir dir="dist" /> + <parallel> + <tar tarfile="${distPath}.src.tar" longfile="gnu"> + <tarfileset dir="." prefix="${module.name}-${module.version}"> + <include name="src/**" /> + <include name="common/**" /> + <include name="devlib/**" /> + <include name="lib/**" /> + <include name="*.iml,build.xml,module.properties" /> + <include name="CHANGES,COPYING,CREDITS,INSTALL,LICENSE,MAINTAINERS,NEWS,README" /> + <!-- TODO --> + </tarfileset> + </tar> + <zip destfile="${distPath}.src.zip"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="src/**" /> + <include name="common/**" /> + <include name="devlib/**" /> + <include name="lib/**" /> + <include name="*.iml,build.xml,module.properties" /> + <include name="CHANGES,COPYING,CREDITS,INSTALL,LICENSE,MAINTAINERS,NEWS,README" /> + <!-- TODO --> + </zipfileset> + </zip> + <jar destfile="${distPath}.src.jar"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="src/**" /> + <include name="common/**" /> + <include name="devlib/**" /> + <include name="lib/**" /> + <include name="*.iml,build.xml,module.properties" /> + <include name="CHANGES,COPYING,CREDITS,INSTALL,LICENSE,MAINTAINERS,NEWS,README" /> + <!-- TODO --> + </zipfileset> + </jar> + <jar destfile="${distPath}.jar"> + <zipfileset dir="classes/production/${module.shortname}" /> + <manifest> + <attribute name="Implementation-Title" value="${module.name}" /> + <attribute name="Implementation-Vendor" value="Christian Hujer + the JAPI Developers" /> + <attribute name="Implementation-Version" value="${module.version}" /> + <attribute name="Implementation-URL" value="http://sourceforge.net/projects/japi/" /> + </manifest> + </jar> + <tar tarfile="${distPath}.doc.tar" longfile="gnu"> + <tarfileset dir="." prefix="${module.name}-${module.version}"> + <include name="docs/**" /> + </tarfileset> + </tar> + <zip destfile="${distPath}.doc.zip"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="docs/**" /> + </zipfileset> + </zip> + <jar destfile="${distPath}.doc.jar"> + <zipfileset dir="." prefix="${module.name}-${module.version}"> + <include name="docs/**" /> + </zipfileset> + </jar> + </parallel> + <parallel> + <gzip src="${distPath}.src.tar" destfile="${distPath}.src.tar.gz" /> + <bzip2 src="${distPath}.src.tar" destfile="${distPath}.src.tar.bz2" /> + <gzip src="${distPath}.doc.tar" destfile="${distPath}.doc.tar.gz" /> + <bzip2 src="${distPath}.doc.tar" destfile="${distPath}.doc.tar.bz2" /> + <pack200 + src="${distPath}.jar" + destfile="${distPath}.pack.gz" + gzipoutput="true" + stripdebug="true" + effort="9" + keepfileorder="false" + modificationtime="latest" + deflatehint="false" + /> + </parallel> + <delete file="${distPath}.src.tar" /> + <delete file="${distPath}.doc.tar" /> </target> -<target name="test" description="Performs JUnit tests." depends="compile"> - <mkdir dir="classes/test/${module.shortname}" /> - <mkdir dir="docs/test" /> - <javac - srcdir="src" - destdir="classes/test/${module.shortname}" - encoding="utf-8" - source="${javaversion}" - target="${javaversion}" - debug="yes" - > - <classpath refid="class.path" /> - <classpath location="classes/production/${module.shortname}" /> - <include name="test/**/*.java" /> - <exclude name="**/package-info.java" /> - </javac> - <copy - todir="classes/test/${module.shortname}" - > - <fileset dir="src" includes="test/**/*.properties" /> - </copy> - <junit printsummary="yes" haltonfailure="yes"> - <classpath refid="class.path" /> - <classpath location="classes/production/${module.shortname}" /> - <classpath location="classes/test/${module.shortname}" /> - <formatter type="plain" /> - <formatter type="xml" /> - <batchtest todir="docs/test"> - <fileset dir="src"> - <include name="test/**/*Test.java" /> - <exclude name="test/**/Abstract*Test.java" /> - </fileset> - </batchtest> - </junit> - <junitreport todir="docs/test"> - <fileset dir="docs/test"> - <include name="TEST-*.xml" /> - </fileset> - <report format="frames" todir="docs/test" /> - </junitreport> -</target> - <target name = "doc" description = "Creates public API documentation" @@ -207,121 +297,44 @@ </javadoc> </target> -<target - name = "dist" - description = "Creates and packs distribution archives." - depends = "clean, compile, doc, checkstyle, test" -> - <delete dir="dist" /> - <mkdir dir="dist" /> - <parallel> - <tar tarfile="${distPath}.src.tar" longfile="gnu"> - <tarfileset dir="." prefix="${module.name}-${module.version}"> - <include name="src/**" /> - <include name="common/**" /> - <include name="devlib/**" /> - <include name="lib/**" /> - <include name="*.iml,build.xml,module.properties" /> - <include name="CHANGES,COPYING,CREDITS,INSTALL,LICENSE,MAINTAINERS,NEWS,README" /> - <!-- TODO --> - </tarfileset> - </tar> - <zip destfile="${distPath}.src.zip"> - <zipfileset dir="." prefix="${module.name}-${module.version}"> - <include name="src/**" /> - <include name="common/**" /> - <include name="devlib/**" /> - <include name="lib/**" /> - <include name="*.iml,build.xml,module.properties" /> - <include name="CHANGES,COPYING,CREDITS,INSTALL,LICENSE,MAINTAINERS,NEWS,README" /> - <!-- TODO --> - </zipfileset> - </zip> - <jar destfile="${distPath}.src.jar"> - <zipfileset dir="." prefix="${module.name}-${module.version}"> - <include name="src/**" /> - <include name="common/**" /> - <include name="devlib/**" /> - <include name="lib/**" /> - <include name="*.iml,build.xml,module.properties" /> - <include name="CHANGES,COPYING,CREDITS,INSTALL,LICENSE,MAINTAINERS,NEWS,README" /> - <!-- TODO --> - </zipfileset> - </jar> - <jar destfile="${distPath}.jar"> - <zipfileset dir="classes/production/${module.shortname}" /> - <manifest> - <attribute name="Implementation-Title" value="${module.name}" /> - <attribute name="Implementation-Vendor" value="Christian Hujer + the JAPI Developers" /> - <attribute name="Implementation-Version" value="${module.version}" /> - <attribute name="Implementation-URL" value="http://sourceforge.net/projects/japi/" /> - </manifest> - </jar> - <tar tarfile="${distPath}.doc.tar" longfile="gnu"> - <tarfileset dir="." prefix="${module.name}-${module.version}"> - <include name="docs/**" /> - </tarfileset> - </tar> - <zip destfile="${distPath}.doc.zip"> - <zipfileset dir="." prefix="${module.name}-${module.version}"> - <include name="docs/**" /> - </zipfileset> - </zip> - <jar destfile="${distPath}.doc.jar"> - <zipfileset dir="." prefix="${module.name}-${module.version}"> - <include name="docs/**" /> - </zipfileset> - </jar> - </parallel> - <parallel> - <gzip src="${distPath}.src.tar" destfile="${distPath}.src.tar.gz" /> - <bzip2 src="${distPath}.src.tar" destfile="${distPath}.src.tar.bz2" /> - <gzip src="${distPath}.doc.tar" destfile="${distPath}.doc.tar.gz" /> - <bzip2 src="${distPath}.doc.tar" destfile="${distPath}.doc.tar.bz2" /> - <pack200 - src="${distPath}.jar" - destfile="${distPath}.pack.gz" - gzipoutput="true" - stripdebug="true" - effort="9" - keepfileorder="false" - modificationtime="latest" - deflatehint="false" - /> - </parallel> - <delete file="${distPath}.src.tar" /> - <delete file="${distPath}.doc.tar" /> -</target> - -<target - name = "announce" - description = "announce new version on freshmeat.net" -> - <echo>Announcing. Press return to start announcing this release at FreshMeat.</echo> - <input /> - <echo><![CDATA[ - <freshmeat - username = "${user.freshmeat.username}" - password = "${user.freshmeat.password}" +<target name="test" description="Performs JUnit tests." depends="compile"> + <mkdir dir="classes/test/${module.shortname}" /> + <mkdir dir="docs/test" /> + <javac + srcdir="src" + destdir="classes/test/${module.shortname}" + encoding="utf-8" + source="${javaversion}" + target="${javaversion}" + debug="yes" > - <printlicenses/> - <printreleasefoci/> - <publish - projectname = "japi" - branchname = "${module.name}" - version = "${module.version}" - focus = "${update.focus}" - > - <changes file="LatestNews" /> - <urlblock - homepage = "http://japi.sourceforge.net/" - cvs = "http://cvs.sourceforge.net/viewcvs.py/japi/" - mailinglist = "http://sourceforge.net/mailarchive/forum.php?forum=japi-users" - tgz = "http://prdownloads.sourceforge.net/japi/${distName}.src.tar.gz?download" - bz2 = "http://prdownloads.sourceforge.net/japi/${distName}.src.tar.bz2?download" - zip = "http://prdownloads.sourceforge.net/japi/${distName}.src.zip?download" - /> - </publish> - </freshmeat> - ]]></echo> + <classpath refid="class.path" /> + <classpath location="classes/production/${module.shortname}" /> + <include name="test/**/*.java" /> + <exclude name="**/package-info.java" /> + </javac> + <copy + todir="classes/test/${module.shortname}" + > + <fileset dir="src" includes="test/**/*.properties" /> + </copy> + <junit printsummary="yes" haltonfailure="yes"> + <classpath refid="class.path" /> + <classpath location="classes/production/${module.shortname}" /> + <classpath location="classes/test/${module.shortname}" /> + <formatter type="plain" /> + <formatter type="xml" /> + <batchtest todir="docs/test"> + <fileset dir="src"> + <include name="test/**/*Test.java" /> + <exclude name="test/**/Abstract*Test.java" /> + </fileset> + </batchtest> + </junit> + <junitreport todir="docs/test"> + <fileset dir="docs/test"> + <include name="TEST-*.xml" /> + </fileset> + <report format="frames" todir="docs/test" /> + </junitreport> </target> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 21:28:05
|
Revision: 527 http://svn.sourceforge.net/japi/?rev=527&view=rev Author: christianhujer Date: 2007-07-09 14:28:03 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Fixed javadoc issues with new code. (I really should always use IntelliJ IDEA to commit, ouch) Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 21:16:49 UTC (rev 526) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 21:28:03 UTC (rev 527) @@ -19,6 +19,8 @@ package net.sf.japi.io.args; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.ArrayList; @@ -30,8 +32,6 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; -import java.io.FileInputStream; -import java.io.FileNotFoundException; import net.sf.japi.io.args.converter.ConverterRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -95,6 +95,8 @@ /** * Returns a list of all arguments after parsing arguments files. + * @param args arguments before parsing argument files. + * @return all arguments after parsing argument files. */ public List<String> getAllArguments(@NotNull final List<String> args) { final List<String> argList = new ArrayList<String>(args); @@ -115,13 +117,15 @@ /** * Returns a tokenized unparsed list of arguments from an arguments file. + * @param filename Argument file to read. + * @return all arguments from that argument file. */ public List<String> readFromFile(@NotNull final String filename) { final List<String> args = new ArrayList<String>(); final TokenReader in; try { in = new TokenReader(new FileInputStream(filename)); - } catch (FileNotFoundException e) { + } catch (final FileNotFoundException e) { // TODO TODO TODO TODO TODO return args; } Modified: libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java 2007-07-09 21:16:49 UTC (rev 526) +++ libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java 2007-07-09 21:28:03 UTC (rev 527) @@ -40,7 +40,7 @@ @NotNull private Reader in; /** The next token. */ - @Nullable String next; + @Nullable private String next; /** Creates a TokenReader. * @param in InputStream to read from. @@ -95,6 +95,7 @@ switch (mode) { case WHITESPACE: if (Character.isWhitespace(c)) { + // nothing to do - still whitespace. } else if (c == '"') { mode = Mode.STRING; tokenValid = true; @@ -128,6 +129,8 @@ nextToken.append(c); mode = Mode.STRING; break; + default: + assert false; } } } catch (final IOException ignore) { @@ -138,9 +141,17 @@ /** The mode of the tokenizer. */ private enum Mode { + + /** White space. Also starting mode. */ WHITESPACE, + + /** Normal - not whitespace and not inside a String. */ NORMAL, + + /** String - inside "". */ STRING, + + /** String Escape - \ inside "". */ STRING_ESCAPE } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 21:16:52
|
Revision: 526 http://svn.sourceforge.net/japi/?rev=526&view=rev Author: christianhujer Date: 2007-07-09 14:16:49 -0700 (Mon, 09 Jul 2007) Log Message: ----------- [ 1750198 ] Allow single dash instead of double dash Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 20:54:31 UTC (rev 525) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 21:16:49 UTC (rev 526) @@ -195,7 +195,7 @@ } /** - * Parses arguments into an arguments container and invokes the Command's {@link Command#run(List<String>)} method. + * Parses arguments into an arguments container. * @throws TerminalException in case argument parsing was stopped * @throws MissingArgumentException In case a required argument was missing. * @throws UnknownOptionException In case a given option is not known. @@ -206,24 +206,29 @@ final String arg = argIterator.next(); if (arg.length() > 1 && arg.charAt(0) == '-') { argIterator.remove(); - if ("--".equals(arg)) { + if ("--".equals(arg)) { // '--': stop parsing //noinspection BreakStatement break; } - if (arg.charAt(1) == '-') { - currentOption = arg.substring(2); - final int indexOfEq = currentOption.indexOf('='); - if (indexOfEq != -1) { - argIterator.add(currentOption.substring(indexOfEq + 1)); - argIterator.previous(); - currentOption = currentOption.substring(0, indexOfEq); - } + final boolean doubleDash = arg.charAt(1) == '-'; + currentOption = arg.substring(doubleDash ? 2 : 1); + final int indexOfEq = currentOption.indexOf('='); + if (indexOfEq != -1) { + argIterator.add(currentOption.substring(indexOfEq + 1)); + argIterator.previous(); + currentOption = currentOption.substring(0, indexOfEq); + } + if (doubleDash) { // '--foo' option invokeMethod(); - } else { - for (final String co : arg.substring(1).split("")) { - if (co.length() == 1) { - currentOption = co; - invokeMethod(); + } else { // '-xyz' + if (argumentMethods.get(currentOption) != null) { // '-foo' option + invokeMethod(); + } else { // '-abc' options + for (final String co : arg.substring(1).split("")) { + if (co.length() == 1) { + currentOption = co; + invokeMethod(); + } } } } Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-09 20:54:31 UTC (rev 525) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-09 21:16:49 UTC (rev 526) @@ -232,6 +232,7 @@ * @throws TerminalException (unexpected) * @throws UnknownOptionException (unexpected) * @throws MissingArgumentException (unexpected) + * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1750193&group_id=149894&atid=776740">[ 1750193 ] Partial read of command line arguments from a file</a> */ @Test public void testOptionsFromFileSingleLine() throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { @@ -246,6 +247,40 @@ } /** + * Tests that single dash options also work. + * @throws RequiredOptionsMissingException (unexpected) + * @throws TerminalException (unexpected) + * @throws UnknownOptionException (unexpected) + * @throws MissingArgumentException (unexpected) + * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1750198&group_id=149894&atid=776740">[ 1750198 ] Allow single dash instead of double dash</a> + */ + @Test + public void testSingleDashOption() throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { + final MockCommand command = new MockCommand(); + ArgParser.parseAndRun(command, "-input", "fooInput"); + Assert.assertEquals("Option value must be stored.", "fooInput", command.getInput()); + Assert.assertTrue("Run must be called even with zero arguments.", command.isRunCalled()); + Assert.assertEquals("Argument list for invocation without arguments must be empty.", 0, command.getArgs().size()); + } + + /** + * Tests that single dash options also work. + * @throws RequiredOptionsMissingException (unexpected) + * @throws TerminalException (unexpected) + * @throws UnknownOptionException (unexpected) + * @throws MissingArgumentException (unexpected) + * @see <a href="http://sourceforge.net/tracker/index.php?func=detail&aid=1750198&group_id=149894&atid=776740">[ 1750198 ] Allow single dash instead of double dash</a> + */ + @Test + public void testSingleDashOptionWithEquals() throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { + final MockCommand command = new MockCommand(); + ArgParser.parseAndRun(command, "-input=fooInput"); + Assert.assertEquals("Option value must be stored.", "fooInput", command.getInput()); + Assert.assertTrue("Run must be called even with zero arguments.", command.isRunCalled()); + Assert.assertEquals("Argument list for invocation without arguments must be empty.", 0, command.getArgs().size()); + } + + /** * This MockCommand serves as a command for performing simple tests. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 20:54:34
|
Revision: 525 http://svn.sourceforge.net/japi/?rev=525&view=rev Author: christianhujer Date: 2007-07-09 13:54:31 -0700 (Mon, 09 Jul 2007) Log Message: ----------- [ 1750193 ] Partial read of command line arguments from a file Modified Paths: -------------- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java Added Paths: ----------- libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest_OptionsFileSingleLine libs/argparser/trunk/src/test/net/sf/japi/io/args/TokenReaderTest.java Modified: libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 19:27:05 UTC (rev 524) +++ libs/argparser/trunk/src/net/sf/japi/io/args/ArgParser.java 2007-07-09 20:54:31 UTC (rev 525) @@ -30,6 +30,8 @@ import java.util.Map; import java.util.NoSuchElementException; import java.util.Set; +import java.io.FileInputStream; +import java.io.FileNotFoundException; import net.sf.japi.io.args.converter.ConverterRegistry; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -75,7 +77,7 @@ this.command = command; commandClass = command.getClass(); initMethods(); - final List<String> argList = new ArrayList<String>(Arrays.asList(args)); + final List<String> argList = getAllArguments(Arrays.asList(args)); argIterator = argList.listIterator(); parse(); checkRequiredMethods(); @@ -92,6 +94,44 @@ } /** + * Returns a list of all arguments after parsing arguments files. + */ + public List<String> getAllArguments(@NotNull final List<String> args) { + final List<String> argList = new ArrayList<String>(args); + for (final ListIterator<String> iterator = argList.listIterator(); iterator.hasNext();) { + final String arg = iterator.next(); + if (arg.equals("--")) { + break; + } + if (arg.startsWith("@")) { + iterator.remove(); + for (final String insertArg : getAllArguments(readFromFile(arg.substring(1)))) { + iterator.add(insertArg); + } + } + } + return argList; + } + + /** + * Returns a tokenized unparsed list of arguments from an arguments file. + */ + public List<String> readFromFile(@NotNull final String filename) { + final List<String> args = new ArrayList<String>(); + final TokenReader in; + try { + in = new TokenReader(new FileInputStream(filename)); + } catch (FileNotFoundException e) { + // TODO TODO TODO TODO TODO + return args; + } + for (final String token : in) { + args.add(token); + } + return args; + } + + /** * Checks that all required methods have been invoked. * @throws RequiredOptionsMissingException in case a required command line argument was missing */ Added: libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java =================================================================== --- libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java (rev 0) +++ libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java 2007-07-09 20:54:31 UTC (rev 525) @@ -0,0 +1,147 @@ +/* + * JAPI libs-argparser is a library for parsing command line arguments. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package net.sf.japi.io.args; + +import java.io.Closeable; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.Iterator; +import java.util.NoSuchElementException; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * A TokenReader reads arguments from a file, non-recursive. + * That means the arguments are read regarding a certain argument syntax, but remain otherwise unparsed. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class TokenReader implements Closeable, Iterable<String>, Iterator<String> { + + /** Reader to read from. */ + @NotNull private Reader in; + + /** The next token. */ + @Nullable String next; + + /** Creates a TokenReader. + * @param in InputStream to read from. + */ + public TokenReader(@NotNull final InputStream in) { + this.in = new InputStreamReader(in); + next = readNextToken(); + } + + /** {@inheritDoc} */ + public void close() throws IOException { + in.close(); + } + + /** {@inheritDoc} */ + @NotNull public Iterator<String> iterator() { + return this; + } + + /** {@inheritDoc} */ + public boolean hasNext() { + return next != null; + } + + /** {@inheritDoc} */ + @NotNull public String next() { + if (next == null) { + throw new NoSuchElementException(); + } + try { + return next; + } finally { + next = readNextToken(); + } + } + + /** {@inheritDoc} */ + public void remove() { + throw new UnsupportedOperationException(); + } + + /** Reads the next token from the underlying reader. + * @return Next token read from the underlying reader or <code>null</code> if no more tokens are available. + */ + @Nullable public String readNextToken() { + final StringBuilder nextToken = new StringBuilder(); + boolean tokenValid = false; + Mode mode = Mode.WHITESPACE; + try { + for (int rc; (rc = in.read()) != -1;) { + final char c = (char) rc; + switch (mode) { + case WHITESPACE: + if (Character.isWhitespace(c)) { + } else if (c == '"') { + mode = Mode.STRING; + tokenValid = true; + } else { + nextToken.append(c); + mode = Mode.NORMAL; + tokenValid = true; + } + break; + case NORMAL: + if (Character.isWhitespace(c)) { + assert tokenValid; + assert nextToken.length() != 0; + return nextToken.toString(); + } else if (c == '"') { + mode = Mode.STRING; + } else { + nextToken.append(c); + } + break; + case STRING: + if (c == '"') { + mode = Mode.NORMAL; + } else if (c == '\\') { + mode = Mode.STRING_ESCAPE; + } else { + nextToken.append(c); + } + break; + case STRING_ESCAPE: + nextToken.append(c); + mode = Mode.STRING; + break; + } + } + } catch (final IOException ignore) { + // ignore + } + return tokenValid ? nextToken.toString() : null; + } + + /** The mode of the tokenizer. */ + private enum Mode { + WHITESPACE, + NORMAL, + STRING, + STRING_ESCAPE + } + +} // class TokenReader Property changes on: libs/argparser/trunk/src/net/sf/japi/io/args/TokenReader.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Modified: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-09 19:27:05 UTC (rev 524) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest.java 2007-07-09 20:54:31 UTC (rev 525) @@ -227,6 +227,25 @@ } /** + * Tests whether reading options from a file works. + * @throws RequiredOptionsMissingException (unexpected) + * @throws TerminalException (unexpected) + * @throws UnknownOptionException (unexpected) + * @throws MissingArgumentException (unexpected) + */ + @Test + public void testOptionsFromFileSingleLine() throws RequiredOptionsMissingException, MissingArgumentException, TerminalException, UnknownOptionException { + final MockCommand command = new MockCommand(); + ArgParser.parseAndRun(command, "@src/test/net/sf/japi/io/args/ArgParserTest_OptionsFileSingleLine"); + final List<String> args = command.getArgs(); + Assert.assertEquals("Option value must be stored.", "fooInput", command.getInput()); + Assert.assertTrue("Run must be called even with zero arguments.", command.isRunCalled()); + Assert.assertEquals("Arguments must be stored.", 2, args.size()); + Assert.assertEquals("Argument foo must be stored.", "foo", args.get(0)); + Assert.assertEquals("Argument bar must be stored.", "bar", args.get(1)); + } + + /** * This MockCommand serves as a command for performing simple tests. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest_OptionsFileSingleLine =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest_OptionsFileSingleLine (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest_OptionsFileSingleLine 2007-07-09 20:54:31 UTC (rev 525) @@ -0,0 +1 @@ +-i fooInput foo bar \ No newline at end of file Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/ArgParserTest_OptionsFileSingleLine ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/argparser/trunk/src/test/net/sf/japi/io/args/TokenReaderTest.java =================================================================== --- libs/argparser/trunk/src/test/net/sf/japi/io/args/TokenReaderTest.java (rev 0) +++ libs/argparser/trunk/src/test/net/sf/japi/io/args/TokenReaderTest.java 2007-07-09 20:54:31 UTC (rev 525) @@ -0,0 +1,162 @@ +/* + * JAPI libs-argparser is a library for parsing command line arguments. + * Copyright (C) 2007 Christian Hujer. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +package test.net.sf.japi.io.args; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.NoSuchElementException; +import net.sf.japi.io.args.TokenReader; +import org.jetbrains.annotations.NotNull; +import org.junit.Test; +import org.junit.Assert; + +/** + * Test for {@link TokenReader}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class TokenReaderTest { + + /** Tests that a TokenReader on an empty file has no tokens. */ + @Test(expected = NoSuchElementException.class) + public void testTokenReaderEmpty() { + final TokenReader reader = new TokenReader(createStream("")); + Assert.assertFalse("On an empty file, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with whitespace only has no tokens. */ + @Test(expected = NoSuchElementException.class) + public void testTokenReaderWhitespace() { + final TokenReader reader = new TokenReader(createStream(" \n ")); + Assert.assertFalse("On whitespace only, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with a single token returns that token. */ + @Test(expected = NoSuchElementException.class) + public void testTokenSimple() { + final TokenReader reader = new TokenReader(createStream("foo")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + final String token = reader.next(); + Assert.assertEquals("Token must be retrievable", "foo", token); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with preceeding whitespace returns the token without whitespace. */ + @Test(expected = NoSuchElementException.class) + public void testTokenWithPreceedingWhitespace() { + final TokenReader reader = new TokenReader(createStream(" foo")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + final String token = reader.next(); + Assert.assertEquals("Token must be retrievable", "foo", token); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with trailing whitespace returns the token without whitespace. */ + @Test(expected = NoSuchElementException.class) + public void testTokenWithTrailingWhitespace() { + final TokenReader reader = new TokenReader(createStream("foo ")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + final String token = reader.next(); + Assert.assertEquals("Token must be retrievable", "foo", token); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with surrounding whitespace returns the token without whitespace. */ + @Test(expected = NoSuchElementException.class) + public void testTokenWithSurroundingWhitespace() { + final TokenReader reader = new TokenReader(createStream(" foo ")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + final String token = reader.next(); + Assert.assertEquals("Token must be retrievable", "foo", token); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with preceeding whitespace returns the token without whitespace. */ + @Test(expected = NoSuchElementException.class) + public void testTokensWithPreceedingWhitespace() { + final TokenReader reader = new TokenReader(createStream(" foo bar")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Token must be retrievable", "foo", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Token must be retrievable", "bar", reader.next()); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with trailing whitespace returns the token without whitespace. */ + @Test(expected = NoSuchElementException.class) + public void testTokensWithTrailingWhitespace() { + final TokenReader reader = new TokenReader(createStream("foo bar ")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Token must be retrievable", "foo", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Token must be retrievable", "bar", reader.next()); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with surrounding whitespace returns the token without whitespace. */ + @Test(expected = NoSuchElementException.class) + public void testTokensWithSurroundingWhitespace() { + final TokenReader reader = new TokenReader(createStream(" foo bar ")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Token must be retrievable", "foo", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Token must be retrievable", "bar", reader.next()); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Tests that a TokenReader on a file with String tokens returns them. */ + @Test(expected = NoSuchElementException.class) + public void testTokensComplex() { + final TokenReader reader = new TokenReader(createStream(" foo\nbar\nbuzz token\n\" Multiline\n\\\"String \" anotherFoo a\"n\"a")); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", "foo", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", "bar", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", "buzz", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", "token", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", " Multiline\n\"String ", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", "anotherFoo", reader.next()); + Assert.assertTrue("Before reading the last token, hasNext() must return true.", reader.hasNext()); + Assert.assertEquals("Expecting token", "ana", reader.next()); + Assert.assertFalse("After reading the last token, hasNext() must return false.", reader.hasNext()); + reader.next(); + } + + /** Creates an InputStream for reading from a String. + * @param s String to read from. + * @return InputStream created from s. + */ + @NotNull private static InputStream createStream(@NotNull final String s) { + return new ByteArrayInputStream(s.getBytes()); + } + +} // class TokenReaderTest Property changes on: libs/argparser/trunk/src/test/net/sf/japi/io/args/TokenReaderTest.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 19:27:07
|
Revision: 524 http://svn.sourceforge.net/japi/?rev=524&view=rev Author: christianhujer Date: 2007-07-09 12:27:05 -0700 (Mon, 09 Jul 2007) Log Message: ----------- Removed warnings about long file names when creating distribution tar. Resulting tar can be read with gnu tar only anyway. Modified Paths: -------------- common/trunk/commonBuild.xml Modified: common/trunk/commonBuild.xml =================================================================== --- common/trunk/commonBuild.xml 2007-07-09 19:23:55 UTC (rev 523) +++ common/trunk/commonBuild.xml 2007-07-09 19:27:05 UTC (rev 524) @@ -215,7 +215,7 @@ <delete dir="dist" /> <mkdir dir="dist" /> <parallel> - <tar tarfile="${distPath}.src.tar"> + <tar tarfile="${distPath}.src.tar" longfile="gnu"> <tarfileset dir="." prefix="${module.name}-${module.version}"> <include name="src/**" /> <include name="common/**" /> @@ -257,7 +257,7 @@ <attribute name="Implementation-URL" value="http://sourceforge.net/projects/japi/" /> </manifest> </jar> - <tar tarfile="${distPath}.doc.tar"> + <tar tarfile="${distPath}.doc.tar" longfile="gnu"> <tarfileset dir="." prefix="${module.name}-${module.version}"> <include name="docs/**" /> </tarfileset> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-09 19:23:58
|
Revision: 523 http://svn.sourceforge.net/japi/?rev=523&view=rev Author: christianhujer Date: 2007-07-09 12:23:55 -0700 (Mon, 09 Jul 2007) Log Message: ----------- [ 1750244 ] test properties included in exe / lib jars Modified Paths: -------------- common/trunk/commonBuild.xml Modified: common/trunk/commonBuild.xml =================================================================== --- common/trunk/commonBuild.xml 2007-07-07 16:29:18 UTC (rev 522) +++ common/trunk/commonBuild.xml 2007-07-09 19:23:55 UTC (rev 523) @@ -79,7 +79,7 @@ <exclude name="**/package-info.java" /> </javac> <copy - todir="classes/production/${module.shortname}" + todir="classes/test/${module.shortname}" > <fileset dir="src" includes="test/**/*.properties" /> </copy> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 16:29:20
|
Revision: 522 http://svn.sourceforge.net/japi/?rev=522&view=rev Author: christianhujer Date: 2007-07-07 09:29:18 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Changed FindLongestPath to be a LogCommand. Modified Paths: -------------- tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.java Added Paths: ----------- tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.properties Modified: tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.java =================================================================== --- tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.java 2007-07-07 16:23:01 UTC (rev 521) +++ tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.java 2007-07-07 16:29:18 UTC (rev 522) @@ -19,17 +19,18 @@ package net.sf.japi.findLongestPath; -import net.sf.japi.io.args.BasicCommand; +import java.io.File; +import java.util.List; +import java.util.logging.Level; import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.LogCommand; import net.sf.japi.io.args.Option; import org.jetbrains.annotations.NotNull; -import java.util.List; -import java.io.File; /** Program that finds the longest path name. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ -public class FindLongestPath extends BasicCommand { +public class FindLongestPath extends LogCommand { /** Runs the program. * @param args Command line arguments. @@ -102,6 +103,12 @@ maxLength = length; maxPathname = pathname; } + if (path.isDirectory()) { + getLog().log(Level.FINE, "descending", path); + for (final File child : path.listFiles()) { + find(child); + } + } } /** {@inheritDoc} */ Added: tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.properties =================================================================== --- tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.properties (rev 0) +++ tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.properties 2007-07-07 16:29:18 UTC (rev 522) @@ -0,0 +1,20 @@ +# +# FindLongestPath recursively finds the longest pathname in directories. +# Copyright (C) 2007 Christian Hujer +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along +# with this program; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +# +setAbsolute=Whether to convert path names to absolute path names. +descending=Descending into {0}. Property changes on: tools/findLongestPath/trunk/src/net/sf/japi/findLongestPath/FindLongestPath.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 16:23:05
|
Revision: 521 http://svn.sourceforge.net/japi/?rev=521&view=rev Author: christianhujer Date: 2007-07-07 09:23:01 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Improved font lib module code: Added missing @NotNull / @Nullable annotations, removed some warnings. Modified Paths: -------------- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java Modified: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java 2007-07-07 16:05:12 UTC (rev 520) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontChooser.java 2007-07-07 16:23:01 UTC (rev 521) @@ -46,9 +46,10 @@ import javax.swing.event.ChangeListener; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; -import org.jetbrains.annotations.Nullable; import net.sf.japi.swing.ActionFactory; import static net.sf.japi.swing.ActionFactory.getFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** Class for letting the user choose a font. * There are two possibilities to use this class: @@ -66,34 +67,35 @@ /** JList for Font Family. * @serial include */ - private JList familyList; + @NotNull private final JList familyList; /** JList for Font Style. * @serial include */ - private JList styleList; + @NotNull private final JList styleList; /** JList for Font Size. * @serial include */ - private JList sizeList; + @NotNull private final JList sizeList; /** JSpinner for Font Size. * @serial include */ - private JSpinner sizeSpinner; + @NotNull private final JSpinner sizeSpinner; /** FontPreview for Font. * @serial include */ - private FontPreview preview; + @NotNull private final FontPreview preview; /** Selected Font. * @serial include */ - private Font selectedFont; + @NotNull private Font selectedFont = Font.decode(null); /** Create a new FontChooser. */ + @SuppressWarnings({"MagicNumber"}) public FontChooser() { setBorder(createCompoundBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createTitledBorder(ACTION_FACTORY.getString("desiredFont_borderTitle"))), createEmptyBorder(8, 4, 4, 4))); setLayout(new GridBagLayout()); @@ -136,15 +138,18 @@ sizeList.setSelectionMode(SINGLE_SELECTION); } - /** Set the selected font. */ - public void setSelectedFont(final Font selectedFont) { - this.selectedFont = selectedFont; - preview.setFont(selectedFont); + /** Set the selected font. + * @param selectedFont currently selected font. + */ + public void setSelectedFont(@Nullable final Font selectedFont) { + @NotNull final Font realFont = selectedFont != null ? selectedFont : Font.decode(null); + this.selectedFont = realFont; + preview.setFont(realFont); //lock = true; - sizeSpinner.setValue(selectedFont.getSize()); - sizeList.setSelectedValue(selectedFont.getSize(), true); - styleList.setSelectedValue(selectedFont.getStyle(), true); - familyList.setSelectedValue(selectedFont.getFamily(), true); + sizeSpinner.setValue(realFont.getSize()); + sizeList.setSelectedValue(realFont.getSize(), true); + styleList.setSelectedValue(realFont.getStyle(), true); + familyList.setSelectedValue(realFont.getFamily(), true); //lock = false; } @@ -159,7 +164,7 @@ } /** {@inheritDoc} */ - public void valueChanged(final ListSelectionEvent e) { + public void valueChanged(@NotNull final ListSelectionEvent e) { final Object source = e.getSource(); if (source == familyList) { // No special action except updateFont() @@ -177,7 +182,7 @@ } /** {@inheritDoc} */ - public void stateChanged(final ChangeEvent e) { + public void stateChanged(@NotNull final ChangeEvent e) { final Object source = e.getSource(); if (source == sizeSpinner) { final Object size = sizeSpinner.getValue(); @@ -194,7 +199,7 @@ * @param parent Parent component * @return seleced font or null */ - public static Font showChooseFontDialog(final Component parent) { + public static Font showChooseFontDialog(@Nullable final Component parent) { return showChooseFontDialog(parent, Font.decode(null)); } @@ -203,7 +208,7 @@ * @param font Font to modify * @return selected font or null */ - @Nullable public static Font showChooseFontDialog(final Component parent, final Font font) { + @Nullable public static Font showChooseFontDialog(@Nullable final Component parent, @Nullable final Font font) { final FontChooser chooser = new FontChooser(); chooser.setSelectedFont(font); if (showConfirmDialog(parent, chooser, ACTION_FACTORY.getString("chooser.title"), OK_CANCEL_OPTION, PLAIN_MESSAGE) == OK_OPTION) { Modified: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java 2007-07-07 16:05:12 UTC (rev 520) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontFamilyListCellRenderer.java 2007-07-07 16:23:01 UTC (rev 521) @@ -21,9 +21,12 @@ import java.awt.Component; import java.awt.Font; +import java.util.HashMap; import java.util.Map; +import javax.swing.DefaultListCellRenderer; import javax.swing.JList; -import javax.swing.DefaultListCellRenderer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** List cell renderer for letting the user choose the font family. * This list cell renderer displays each font in its font. @@ -37,22 +40,23 @@ /** The fonts to render. * @serial include */ - private Map<String, Font> fonts; + @NotNull private Map<String, Font> fonts; /** Set the fonts to render. * The key of the map is the family name, the value of the map is the font to render. * @param fonts fonts to render */ - public void setFonts(final Map<String, Font> fonts) { - this.fonts = fonts; + public void setFonts(@NotNull final Map<String, Font> fonts) { + this.fonts = new HashMap<String, Font>(fonts); } /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + @Override public Component getListCellRendererComponent(@NotNull final JList list, @Nullable final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); + final String fontName = (String) value; //Font f = FontFamilyComboBox.this.getFont(); //c.setFont(new Font((String)value, f.getStyle(), f.getSize())); - c.setFont(fonts.get((String) value)); + c.setFont(fonts.get(fontName)); return c; } Modified: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java 2007-07-07 16:05:12 UTC (rev 520) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontPreview.java 2007-07-07 16:23:01 UTC (rev 521) @@ -37,12 +37,15 @@ /** Action Factory. */ private static final ActionFactory ACTION_FACTORY = getFactory("net.sf.japi.swing.font"); + /** Default height of the JTextField. */ + private static final int DEFAULT_HEIGHT = 64; + /** Create a new FontPreview. */ public FontPreview() { super(getDefaultText()); setHorizontalAlignment(CENTER); final Dimension d = getMinimumSize(); - d.height = 64; + d.height = DEFAULT_HEIGHT; setMinimumSize(d); setPreferredSize(d); } Modified: libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java =================================================================== --- libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java 2007-07-07 16:05:12 UTC (rev 520) +++ libs/swing-font/trunk/src/net/sf/japi/swing/font/FontStyleListCellRenderer.java 2007-07-07 16:23:01 UTC (rev 521) @@ -27,6 +27,8 @@ import javax.swing.DefaultListCellRenderer; import javax.swing.JList; import net.sf.japi.swing.ActionFactory; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; /** ListCellRenderer for font styles. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> @@ -41,9 +43,9 @@ private static final ActionFactory ACTION_FACTORY = ActionFactory.getFactory("net.sf.japi.swing.font"); /** {@inheritDoc} */ - @Override public Component getListCellRendererComponent(final JList list, final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { + @Override public Component getListCellRendererComponent(@NotNull final JList list, @Nullable final Object value, final int index, final boolean isSelected, final boolean cellHasFocus) { final Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - final int style = (Integer) value; + final int style = value != null ? (Integer) value : 0; setText(getTextFor(style)); setFont(getFontFor(style)); return c; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 16:05:15
|
Revision: 520 http://svn.sourceforge.net/japi/?rev=520&view=rev Author: christianhujer Date: 2007-07-07 09:05:12 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Removed unused font package. Can be replaced with japi-libs-font. Removed Paths: ------------- progs/jeduca/trunk/src/net/sf/japi/progs/jeduca/swing/font/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 13:03:53
|
Revision: 519 http://svn.sourceforge.net/japi/?rev=519&view=rev Author: christianhujer Date: 2007-07-07 06:03:52 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Added ArgParser module dependency. Modified Paths: -------------- tools/jwget/trunk/jwget.iml Modified: tools/jwget/trunk/jwget.iml =================================================================== --- tools/jwget/trunk/jwget.iml 2007-07-07 13:03:22 UTC (rev 518) +++ tools/jwget/trunk/jwget.iml 2007-07-07 13:03:52 UTC (rev 519) @@ -26,6 +26,7 @@ <SOURCES /> </library> </orderEntry> + <orderEntry type="module" module-name="libs-argparser" /> <orderEntryProperties /> </component> <component name="copyright"> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 13:03:23
|
Revision: 518 http://svn.sourceforge.net/japi/?rev=518&view=rev Author: christianhujer Date: 2007-07-07 06:03:22 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Improved JWGet to use ArgParser and better I/O exception handling. Modified Paths: -------------- tools/jwget/trunk/src/net/sf/japi/jwget/JWGet.java Modified: tools/jwget/trunk/src/net/sf/japi/jwget/JWGet.java =================================================================== --- tools/jwget/trunk/src/net/sf/japi/jwget/JWGet.java 2007-07-07 12:57:48 UTC (rev 517) +++ tools/jwget/trunk/src/net/sf/japi/jwget/JWGet.java 2007-07-07 13:03:22 UTC (rev 518) @@ -24,16 +24,17 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; +import java.util.List; +import net.sf.japi.io.args.ArgParser; +import net.sf.japi.io.args.BasicCommand; import org.jetbrains.annotations.NotNull; /** WGet implementation in Java. * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - * @todo use argparser */ -public class JWGet { +public class JWGet extends BasicCommand { /** Size of the I/O buffer. */ private static final int BUF_SIZE = 8192; @@ -42,8 +43,13 @@ * @param args command line arguments */ public static void main(@NotNull final String... args) { + ArgParser.simpleParseAndRun(new JWGet(), args); + } + + /** {@inheritDoc} */ + public int run(@NotNull final List<String> args) throws Exception { int returnCode = 0; - if (args.length == 0) { + if (args.size() == 0) { System.err.println("Usage: JWGet url..."); returnCode++; } @@ -51,31 +57,29 @@ for (final String arg : args) { try { final URL url = new URL(arg); - OutputStream out = null; - InputStream in = null; + final URLConnection con = url.openConnection(); + final InputStream in = con.getInputStream(); try { - final URLConnection con = url.openConnection(); - in = con.getInputStream(); final String location = con.getHeaderField("Content-Location"); final String outputFilename = new File((location != null ? new URL(url, location) : url).getFile()).getName(); System.err.println(outputFilename); - out = new FileOutputStream(outputFilename); - for (int bytesRead; (bytesRead = in.read(buf)) != -1; ) { - out.write(buf, 0, bytesRead); + final OutputStream out = new FileOutputStream(outputFilename); + try { + for (int bytesRead; (bytesRead = in.read(buf)) != -1; ) { + out.write(buf, 0, bytesRead); + } + } finally { + out.close(); } - } catch (final IOException e) { - System.err.println(e); - returnCode++; } finally { - try { in.close(); } catch (final Exception ignore) { /* ignore */ } - try { out.close(); } catch (final Exception ignore) { /* ignore */ } + in.close(); } - } catch (final MalformedURLException e) { + } catch (final IOException e) { System.err.println(e); returnCode++; } } - System.exit(returnCode); + return returnCode; } } // class JWGet This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 12:57:50
|
Revision: 517 http://svn.sourceforge.net/japi/?rev=517&view=rev Author: christianhujer Date: 2007-07-07 05:57:48 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Added preview of the selected font. Modified Paths: -------------- tools/fontbrowser/trunk/src/net/sf/japi/tools/fontbrowser/FontBrowser.java Modified: tools/fontbrowser/trunk/src/net/sf/japi/tools/fontbrowser/FontBrowser.java =================================================================== --- tools/fontbrowser/trunk/src/net/sf/japi/tools/fontbrowser/FontBrowser.java 2007-07-07 10:15:32 UTC (rev 516) +++ tools/fontbrowser/trunk/src/net/sf/japi/tools/fontbrowser/FontBrowser.java 2007-07-07 12:57:48 UTC (rev 517) @@ -20,16 +20,26 @@ package net.sf.japi.tools.fontbrowser; import java.awt.Component; +import java.awt.Dimension; +import java.awt.Font; import java.awt.GraphicsEnvironment; +import java.awt.Point; +import java.awt.Toolkit; import javax.swing.JFrame; import javax.swing.JList; import javax.swing.JScrollPane; +import javax.swing.JSplitPane; import javax.swing.JTabbedPane; +import javax.swing.JTextArea; import static javax.swing.WindowConstants.DISPOSE_ON_CLOSE; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; import net.sf.japi.swing.ActionFactory; import org.jetbrains.annotations.NotNull; -/** A Font Browser. */ +/** A Font Browser. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ public class FontBrowser { /** Action Factory. */ @@ -50,7 +60,11 @@ frame.add(tabs); tabs.add(ACTION_FACTORY.getString("names.title"), createNamesTab()); tabs.add(ACTION_FACTORY.getString("fonts.title"), createFontsTab()); - frame.pack(); + final Dimension size = Toolkit.getDefaultToolkit().getScreenSize(); + size.width >>= 1; + size.height >>= 1; + frame.setSize(size); + frame.setLocation(new Point(size.width >> 1, size.height >> 1)); frame.setDefaultCloseOperation(DISPOSE_ON_CLOSE); frame.setVisible(true); } @@ -59,7 +73,17 @@ * @return The tab component for font names. */ @NotNull private static Component createNamesTab() { - return new JScrollPane(new JList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames())); + final JList fontNameList = new JList(GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames()); + final JTextArea fontExample = new JTextArea(64, 16); + fontNameList.addListSelectionListener(new ListSelectionListener() { + public void valueChanged(final ListSelectionEvent e) { + final String value = (String) fontNameList.getSelectedValue(); + fontExample.setFont(new Font(value, Font.PLAIN, 14)); + System.err.println(value); + } + }); + fontExample.setText("Falsches Üben von Xylophonmusik quält jeden größeren Zwerg."); + return new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, new JScrollPane(fontNameList), new JScrollPane(fontExample)); } /** Create the tab component for fonts. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 10:15:33
|
Revision: 516 http://svn.sourceforge.net/japi/?rev=516&view=rev Author: christianhujer Date: 2007-07-07 03:15:32 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Added unit test for Arrays2. Modified Paths: -------------- libs/util/trunk/libs-util.iml Added Paths: ----------- libs/util/trunk/src/test/ libs/util/trunk/src/test/net/ libs/util/trunk/src/test/net/sf/ libs/util/trunk/src/test/net/sf/japi/ libs/util/trunk/src/test/net/sf/japi/util/ libs/util/trunk/src/test/net/sf/japi/util/Arrays2Test.java Modified: libs/util/trunk/libs-util.iml =================================================================== --- libs/util/trunk/libs-util.iml 2007-07-07 09:54:41 UTC (rev 515) +++ libs/util/trunk/libs-util.iml 2007-07-07 10:15:32 UTC (rev 516) @@ -5,10 +5,12 @@ <exclude-output /> <content url="file://$MODULE_DIR$"> <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + <sourceFolder url="file://$MODULE_DIR$/src/test" isTestSource="true" packagePrefix="test" /> </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> <orderEntry type="library" name="annotations" level="project" /> + <orderEntry type="library" name="junit" level="project" /> <orderEntryProperties /> </component> <component name="copyright"> Copied: libs/util/trunk/src/test/net/sf/japi/util/Arrays2Test.java (from rev 506, historic/trunk/src/test/net/sf/japi/util/Arrays2Test.java) =================================================================== --- libs/util/trunk/src/test/net/sf/japi/util/Arrays2Test.java (rev 0) +++ libs/util/trunk/src/test/net/sf/japi/util/Arrays2Test.java 2007-07-07 10:15:32 UTC (rev 516) @@ -0,0 +1,47 @@ +/* JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2004-2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package test.net.sf.japi.util; + +import java.util.Arrays; +import junit.framework.TestCase; +import net.sf.japi.util.Arrays2; +import org.junit.Test; + +/** Test for {@link Arrays2}. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Arrays2Test extends TestCase { + + /** Test case for Arrays2#concat(double[]...). */ + @Test + public void testConcat() { + final byte[] data1Orig = {1, 2, 3}; + final byte[] data2Orig = {4, 5, 6, 7}; + final byte[] data1Copy = data1Orig.clone(); + final byte[] data2Copy = data2Orig.clone(); + final byte[] concatExpected = {1, 2, 3, 4, 5, 6, 7}; + final byte[] concatResult = Arrays2.concat(data1Copy, data2Copy); + assertTrue("Original arrays must be unmodified", Arrays.equals(data1Orig, data1Copy)); + assertTrue("Original arrays must be unmodified", Arrays.equals(data2Orig, data2Copy)); + assertTrue("Concatenation must correctly concatenate", Arrays.equals(concatExpected, concatResult)); + } + +} // class Arrays2Test \ No newline at end of file Property changes on: libs/util/trunk/src/test/net/sf/japi/util/Arrays2Test.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 09:54:42
|
Revision: 515 http://svn.sourceforge.net/japi/?rev=515&view=rev Author: christianhujer Date: 2007-07-07 02:54:41 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Updated Copier and Forwarder to match new code conventions / warnings policy. Modified Paths: -------------- libs/io/trunk/src/net/sf/japi/io/Copier.java libs/net/trunk/src/net/sf/japi/net/Forwarder.java Modified: libs/io/trunk/src/net/sf/japi/io/Copier.java =================================================================== --- libs/io/trunk/src/net/sf/japi/io/Copier.java 2007-07-07 09:49:53 UTC (rev 514) +++ libs/io/trunk/src/net/sf/japi/io/Copier.java 2007-07-07 09:54:41 UTC (rev 515) @@ -21,12 +21,12 @@ package net.sf.japi.io; +import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; -import java.io.IOException; /** A Runnable that copies from an InputStream to an OutputStream. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class Copier implements Runnable { Modified: libs/net/trunk/src/net/sf/japi/net/Forwarder.java =================================================================== --- libs/net/trunk/src/net/sf/japi/net/Forwarder.java 2007-07-07 09:49:53 UTC (rev 514) +++ libs/net/trunk/src/net/sf/japi/net/Forwarder.java 2007-07-07 09:54:41 UTC (rev 515) @@ -21,33 +21,34 @@ package net.sf.japi.net; +import java.io.IOException; import java.net.ServerSocket; import java.net.Socket; -import java.io.IOException; import net.sf.japi.io.Copier; /** This class forwards incoming TCP connections to another host and port. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> */ public class Forwarder implements Runnable { /** Main program. * @param args command line arguments (currently ignored) + * @throws IOException In case of I/O problems. */ public static void main(final String... args) throws IOException { - ServerSocket serverSocket = null; - serverSocket = new ServerSocket(Integer.parseInt(args[0])); + final ServerSocket serverSocket = new ServerSocket(Integer.parseInt(args[0])); + //noinspection InfiniteLoopStatement while (true) { final Socket server = serverSocket.accept(); - Socket client = null; try { - client = new Socket(args[1], Integer.parseInt(args[2])); + final Socket client = new Socket(args[1], Integer.parseInt(args[2])); new Forwarder(client, server).start(); } catch (final IOException e) { - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { server.close(); } catch (final Exception ignore) { /* ignore */ } - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { client.close(); } catch (final Exception ignore) { /* ignore */ } + try { + server.close(); + } catch (final IOException ignore) { + /* ignore */ + } } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 09:49:55
|
Revision: 514 http://svn.sourceforge.net/japi/?rev=514&view=rev Author: christianhujer Date: 2007-07-07 02:49:53 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Moved Forwarder to libs-net. Modified Paths: -------------- libs/net/trunk/libs-net.iml Added Paths: ----------- libs/net/trunk/src/net/ libs/net/trunk/src/net/sf/ libs/net/trunk/src/net/sf/japi/ libs/net/trunk/src/net/sf/japi/net/ libs/net/trunk/src/net/sf/japi/net/Forwarder.java Removed Paths: ------------- historic/trunk/src/app/net/sf/japi/net/Forwarder.java Deleted: historic/trunk/src/app/net/sf/japi/net/Forwarder.java =================================================================== --- historic/trunk/src/app/net/sf/japi/net/Forwarder.java 2007-07-07 09:48:21 UTC (rev 513) +++ historic/trunk/src/app/net/sf/japi/net/Forwarder.java 2007-07-07 09:49:53 UTC (rev 514) @@ -1,94 +0,0 @@ -/* - * JAPI - (Yet another (hopefully) useful) Java API - * - * Copyright (C) 2006 Christian Hujer - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -package net.sf.japi.net; - -import java.net.ServerSocket; -import java.net.Socket; -import java.io.IOException; -import net.sf.japi.io.Copier; - -/** This class forwards incoming TCP connections to another host and port. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class Forwarder implements Runnable { - - /** Main program. - * @param args command line arguments (currently ignored) - */ - public static void main(final String... args) throws IOException { - ServerSocket serverSocket = null; - serverSocket = new ServerSocket(Integer.parseInt(args[0])); - while (true) { - final Socket server = serverSocket.accept(); - Socket client = null; - try { - client = new Socket(args[1], Integer.parseInt(args[2])); - new Forwarder(client, server).start(); - } catch (final IOException e) { - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { server.close(); } catch (final Exception ignore) { /* ignore */ } - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { client.close(); } catch (final Exception ignore) { /* ignore */ } - } - } - } - - /** First socket. */ - private final Socket s1; - - /** Second socket. */ - private final Socket s2; - - /** Create a new Forwarder. - * @param s1 first socket - * @param s2 second socket - */ - public Forwarder(final Socket s1, final Socket s2) { - this.s1 = s1; - this.s2 = s2; - } - - /** Start the forwarder. */ - public void start() { - new Thread(this).start(); - } - - /** {@inheritDoc} */ - public void run() { - try { - final Thread c1 = new Copier(s1.getInputStream(), s2.getOutputStream()).start(); - final Thread c2 = new Copier(s2.getInputStream(), s1.getOutputStream()).start(); - c1.join(); - c2.join(); - } catch (final InterruptedException ignore) { - /* ignore */ - } catch (final IOException e) { - e.printStackTrace(); //TODO - } finally { - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { s1.close(); } catch (final Exception ignore) { /* ignore */ } - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { s2.close(); } catch (final Exception ignore) { /* ignore */ } - } - } - -} // class Forwarder Modified: libs/net/trunk/libs-net.iml =================================================================== --- libs/net/trunk/libs-net.iml 2007-07-07 09:48:21 UTC (rev 513) +++ libs/net/trunk/libs-net.iml 2007-07-07 09:49:53 UTC (rev 514) @@ -8,6 +8,7 @@ </content> <orderEntry type="inheritedJdk" /> <orderEntry type="sourceFolder" forTests="false" /> + <orderEntry type="module" module-name="libs-io" /> <orderEntryProperties /> </component> <component name="copyright"> Added: libs/net/trunk/src/net/sf/japi/net/Forwarder.java =================================================================== --- libs/net/trunk/src/net/sf/japi/net/Forwarder.java (rev 0) +++ libs/net/trunk/src/net/sf/japi/net/Forwarder.java 2007-07-07 09:49:53 UTC (rev 514) @@ -0,0 +1,94 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.net; + +import java.net.ServerSocket; +import java.net.Socket; +import java.io.IOException; +import net.sf.japi.io.Copier; + +/** This class forwards incoming TCP connections to another host and port. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Forwarder implements Runnable { + + /** Main program. + * @param args command line arguments (currently ignored) + */ + public static void main(final String... args) throws IOException { + ServerSocket serverSocket = null; + serverSocket = new ServerSocket(Integer.parseInt(args[0])); + while (true) { + final Socket server = serverSocket.accept(); + Socket client = null; + try { + client = new Socket(args[1], Integer.parseInt(args[2])); + new Forwarder(client, server).start(); + } catch (final IOException e) { + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { server.close(); } catch (final Exception ignore) { /* ignore */ } + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { client.close(); } catch (final Exception ignore) { /* ignore */ } + } + } + } + + /** First socket. */ + private final Socket s1; + + /** Second socket. */ + private final Socket s2; + + /** Create a new Forwarder. + * @param s1 first socket + * @param s2 second socket + */ + public Forwarder(final Socket s1, final Socket s2) { + this.s1 = s1; + this.s2 = s2; + } + + /** Start the forwarder. */ + public void start() { + new Thread(this).start(); + } + + /** {@inheritDoc} */ + public void run() { + try { + final Thread c1 = new Copier(s1.getInputStream(), s2.getOutputStream()).start(); + final Thread c2 = new Copier(s2.getInputStream(), s1.getOutputStream()).start(); + c1.join(); + c2.join(); + } catch (final InterruptedException ignore) { + /* ignore */ + } catch (final IOException e) { + e.printStackTrace(); //TODO + } finally { + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { s1.close(); } catch (final Exception ignore) { /* ignore */ } + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { s2.close(); } catch (final Exception ignore) { /* ignore */ } + } + } + +} // class Forwarder Property changes on: libs/net/trunk/src/net/sf/japi/net/Forwarder.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 09:48:23
|
Revision: 513 http://svn.sourceforge.net/japi/?rev=513&view=rev Author: christianhujer Date: 2007-07-07 02:48:21 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Removed package with typo. Removed Paths: ------------- libs/io/trunk/src/net/sf/jaoi/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 09:47:51
|
Revision: 512 http://svn.sourceforge.net/japi/?rev=512&view=rev Author: christianhujer Date: 2007-07-07 02:47:49 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Moved Copier to IO lib. Added Paths: ----------- libs/io/trunk/libs-io.iml libs/io/trunk/src/net/ libs/io/trunk/src/net/sf/ libs/io/trunk/src/net/sf/jaoi/ libs/io/trunk/src/net/sf/jaoi/io/ libs/io/trunk/src/net/sf/japi/ libs/io/trunk/src/net/sf/japi/io/ libs/io/trunk/src/net/sf/japi/io/Copier.java Removed Paths: ------------- historic/trunk/src/app/net/sf/japi/io/Copier.java Deleted: historic/trunk/src/app/net/sf/japi/io/Copier.java =================================================================== --- historic/trunk/src/app/net/sf/japi/io/Copier.java 2007-07-07 09:35:46 UTC (rev 511) +++ historic/trunk/src/app/net/sf/japi/io/Copier.java 2007-07-07 09:47:49 UTC (rev 512) @@ -1,122 +0,0 @@ -/* - * JAPI - (Yet another (hopefully) useful) Java API - * - * Copyright (C) 2006 Christian Hujer - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA - * 02111-1307, USA. - */ - -package net.sf.japi.io; - -import java.io.InputStream; -import java.io.OutputStream; -import java.io.IOException; - -/** A Runnable that copies from an InputStream to an OutputStream. - * @author <a href="mailto:ch...@ri...">Christian Hujer</a> - */ -public class Copier implements Runnable { - - /** Default buffer size when copying. */ - public static final int DEFAULT_BUF_SIZE = 8192; - - /** Default automatic flush. */ - public static final boolean DEFAULT_AUTO_FLUSH = true; - - /** Default automatic close. */ - public static final boolean DEFAULT_AUTO_CLOSE = true; - - /** The InputStream to read from. */ - private final InputStream in; - - /** The OutputStream to write to. */ - private final OutputStream out; - - /** The buffer size to use. */ - private final int bufSize; - - /** Whether to flush automatically. */ - private final boolean autoFlush; - - /** Whether to close streams automatically after copying. */ - private final boolean autoClose; - - /** Create a Copier with default buffer size and autoFlush. - * @param in the InputStream to read from - * @param out the OutputStream to write to - */ - public Copier(final InputStream in, final OutputStream out) { - this(in, out, DEFAULT_BUF_SIZE, DEFAULT_AUTO_FLUSH, DEFAULT_AUTO_CLOSE); - } - - /** Create a Copier with specified buffer size and automatic flush behaviour. - * @param in the InputStream to read from - * @param out the OutputStream to write to - * @param bufSize buffer size to use while copying - */ - public Copier(final InputStream in, final OutputStream out, final int bufSize) { - this(in, out, bufSize, DEFAULT_AUTO_FLUSH, DEFAULT_AUTO_CLOSE); - } - - /** Create a Copier with specified buffer size and specified flush behaviour. - * @param in the InputStream to read from - * @param out the OutputStream to write to - * @param bufSize buffer size to use while copying - * @param autoFlush whether to flush automatically (true for automatic flush, false for flush on close) - * @param autoClose whether to close the streams automatically (true for automatic close, false for no close) - */ - public Copier(final InputStream in, final OutputStream out, final int bufSize, final boolean autoFlush, final boolean autoClose) { - this.in = in; - this.out = out; - this.bufSize = bufSize; - this.autoFlush = autoFlush; - this.autoClose = autoClose; - } - - /** Start the copier in a new thread. - * @return the newly created thread - */ - public Thread start() { - final Thread thread = new Thread(this); - thread.start(); - return thread; - } - - /** {@inheritDoc} */ - public void run() { - final byte[] buf = new byte[bufSize]; - try { - for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { - out.write(buf, 0, bytesRead); - if (autoFlush) { - out.flush(); - } - } - } catch (final IOException e) { - System.err.println(e); - } finally { - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { out.flush(); } catch (final Exception ignore) { /* ignore */ } - if (autoClose) { - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { out.close(); } catch (final Exception ignore) { /* ignore */ } - //noinspection CatchGenericClass,OverlyBroadCatchBlock - try { in.close(); } catch (final Exception ignore) { /* ignore */ } - } - } - } - -} // class Copier Added: libs/io/trunk/libs-io.iml =================================================================== --- libs/io/trunk/libs-io.iml (rev 0) +++ libs/io/trunk/libs-io.iml 2007-07-07 09:47:49 UTC (rev 512) @@ -0,0 +1,187 @@ +<?xml version="1.0" encoding="UTF-8"?> +<module relativePaths="true" type="JAVA_MODULE" version="4"> + <component name="ModuleRootManager" /> + <component name="NewModuleRootManager" inherit-compiler-output="true"> + <exclude-output /> + <content url="file://$MODULE_DIR$"> + <sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> + </content> + <orderEntry type="inheritedJdk" /> + <orderEntry type="sourceFolder" forTests="false" /> + <orderEntryProperties /> + </component> + <component name="copyright"> + <Base> + <setting name="state" value="1" /> + </Base> + <LanguageOptions name="$TEMPLATE$"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="4" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="CSS"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="HTML"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JAVA"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JSP"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="JavaScript"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="Properties"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + <LanguageOptions name="XML"> + <option name="templateOptions"> + <value> + <option name="block" value="true" /> + <option name="separateBefore" value="false" /> + <option name="separateAfter" value="false" /> + <option name="prefixLines" value="true" /> + <option name="lenBefore" value="80" /> + <option name="lenAfter" value="80" /> + <option name="box" value="false" /> + <option name="filler" value=" " /> + </value> + </option> + <option name="notice" value="Copyright (c) &#36;today.year, Your Corporation. All Rights Reserved." /> + <option name="keyword" value="Copyright" /> + <option name="fileTypeOverride" value="2" /> + <option name="relativeBefore" value="true" /> + <option name="addBlankAfter" value="true" /> + <option name="fileLocation" value="1" /> + <option name="useAlternate" value="false" /> + </LanguageOptions> + </component> +</module> + Property changes on: libs/io/trunk/libs-io.iml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF Added: libs/io/trunk/src/net/sf/japi/io/Copier.java =================================================================== --- libs/io/trunk/src/net/sf/japi/io/Copier.java (rev 0) +++ libs/io/trunk/src/net/sf/japi/io/Copier.java 2007-07-07 09:47:49 UTC (rev 512) @@ -0,0 +1,122 @@ +/* + * JAPI - (Yet another (hopefully) useful) Java API + * + * Copyright (C) 2006 Christian Hujer + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + * 02111-1307, USA. + */ + +package net.sf.japi.io; + +import java.io.InputStream; +import java.io.OutputStream; +import java.io.IOException; + +/** A Runnable that copies from an InputStream to an OutputStream. + * @author <a href="mailto:ch...@ri...">Christian Hujer</a> + */ +public class Copier implements Runnable { + + /** Default buffer size when copying. */ + public static final int DEFAULT_BUF_SIZE = 8192; + + /** Default automatic flush. */ + public static final boolean DEFAULT_AUTO_FLUSH = true; + + /** Default automatic close. */ + public static final boolean DEFAULT_AUTO_CLOSE = true; + + /** The InputStream to read from. */ + private final InputStream in; + + /** The OutputStream to write to. */ + private final OutputStream out; + + /** The buffer size to use. */ + private final int bufSize; + + /** Whether to flush automatically. */ + private final boolean autoFlush; + + /** Whether to close streams automatically after copying. */ + private final boolean autoClose; + + /** Create a Copier with default buffer size and autoFlush. + * @param in the InputStream to read from + * @param out the OutputStream to write to + */ + public Copier(final InputStream in, final OutputStream out) { + this(in, out, DEFAULT_BUF_SIZE, DEFAULT_AUTO_FLUSH, DEFAULT_AUTO_CLOSE); + } + + /** Create a Copier with specified buffer size and automatic flush behaviour. + * @param in the InputStream to read from + * @param out the OutputStream to write to + * @param bufSize buffer size to use while copying + */ + public Copier(final InputStream in, final OutputStream out, final int bufSize) { + this(in, out, bufSize, DEFAULT_AUTO_FLUSH, DEFAULT_AUTO_CLOSE); + } + + /** Create a Copier with specified buffer size and specified flush behaviour. + * @param in the InputStream to read from + * @param out the OutputStream to write to + * @param bufSize buffer size to use while copying + * @param autoFlush whether to flush automatically (true for automatic flush, false for flush on close) + * @param autoClose whether to close the streams automatically (true for automatic close, false for no close) + */ + public Copier(final InputStream in, final OutputStream out, final int bufSize, final boolean autoFlush, final boolean autoClose) { + this.in = in; + this.out = out; + this.bufSize = bufSize; + this.autoFlush = autoFlush; + this.autoClose = autoClose; + } + + /** Start the copier in a new thread. + * @return the newly created thread + */ + public Thread start() { + final Thread thread = new Thread(this); + thread.start(); + return thread; + } + + /** {@inheritDoc} */ + public void run() { + final byte[] buf = new byte[bufSize]; + try { + for (int bytesRead; (bytesRead = in.read(buf)) != -1;) { + out.write(buf, 0, bytesRead); + if (autoFlush) { + out.flush(); + } + } + } catch (final IOException e) { + System.err.println(e); + } finally { + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { out.flush(); } catch (final Exception ignore) { /* ignore */ } + if (autoClose) { + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { out.close(); } catch (final Exception ignore) { /* ignore */ } + //noinspection CatchGenericClass,OverlyBroadCatchBlock + try { in.close(); } catch (final Exception ignore) { /* ignore */ } + } + } + } + +} // class Copier Property changes on: libs/io/trunk/src/net/sf/japi/io/Copier.java ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2007-07-07 09:35:49
|
Revision: 511 http://svn.sourceforge.net/japi/?rev=511&view=rev Author: christianhujer Date: 2007-07-07 02:35:46 -0700 (Sat, 07 Jul 2007) Log Message: ----------- Added io library. Added Paths: ----------- libs/io/ libs/io/branches/ libs/io/tags/ libs/io/trunk/ libs/io/trunk/CHANGES libs/io/trunk/COPYING libs/io/trunk/CREDITS libs/io/trunk/INSTALL libs/io/trunk/LICENSE libs/io/trunk/MAINTAINERS libs/io/trunk/NEWS libs/io/trunk/README libs/io/trunk/build.xml libs/io/trunk/module.properties libs/io/trunk/src/ Property changes on: libs/io/trunk ___________________________________________________________________ Name: svn:ignore + classes dest developer.properties dist docs Name: svn:externals + common https://japi.svn.sourceforge.net/svnroot/japi/common/trunk Added: libs/io/trunk/CHANGES =================================================================== --- libs/io/trunk/CHANGES (rev 0) +++ libs/io/trunk/CHANGES 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,6 @@ +JAPI LIB IO CHANGLOG +-------------------- + +2007 + Christian Hujer: + * Creation Property changes on: libs/io/trunk/CHANGES ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/COPYING =================================================================== --- libs/io/trunk/COPYING (rev 0) +++ libs/io/trunk/COPYING 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,340 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + <one line to give the program's name and a brief idea of what it does.> + Copyright (C) <year> <name of author> + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. Property changes on: libs/io/trunk/COPYING ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/CREDITS =================================================================== --- libs/io/trunk/CREDITS (rev 0) +++ libs/io/trunk/CREDITS 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,4 @@ +The following people have contributed to JAPI Lib IO: + +* Christian Hujer <ch...@ri...> + Inventor, creator, maintainer Property changes on: libs/io/trunk/CREDITS ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/INSTALL =================================================================== --- libs/io/trunk/INSTALL (rev 0) +++ libs/io/trunk/INSTALL 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,22 @@ +BUILDING / INSTALLING JAPI LIB IO +--------------------------------- + + +Japi Lib IO is a library for Java developers. Because of that, installation +is not applicable. The rest of the file is concerned with building it only. + +To build Japi Lib IO, you need Java 5.0 and Ant 1.6.5. The applications you +build using Japi Lib net will need Java 5.0 or newer and of course Japi +Lib Net. + + +To build Japi Lib IO, just run ant in the project's root directory or +specifying the build.xml in the project's root directory. To find out, what +other options you have for building Japi Lib IO, try "ant -projecthelp". + + +Usually, you'd just want to use Japi Lib IO in your favorite IDE and include +all those Japi Lib IO classes that you used directly or indirectly in your +build. To do so, the easiest way usually is this: +1. Create a .jar file with the Japi Lib IO classes by running "ant dist". +2. Include that .jar file in the classpath of your IDE. Property changes on: libs/io/trunk/INSTALL ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/LICENSE =================================================================== --- libs/io/trunk/LICENSE (rev 0) +++ libs/io/trunk/LICENSE 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,9 @@ +JAPI LIB IO LICENSE INFORMATION +------------------------------- + +Japi Lib IO is licensed under GPL. See file COPYING. + +Japi Lib IO uses some third part libraries, especially for building. These +libraries are contained in the lib/ directory and have their own licenses. See +the corresponding LICENSE-*-files in the common/lib/ directory for the licenses +of third party libraries. Property changes on: libs/io/trunk/LICENSE ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/MAINTAINERS =================================================================== --- libs/io/trunk/MAINTAINERS (rev 0) +++ libs/io/trunk/MAINTAINERS 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,7 @@ +JAPI LIB NET MAINTAINERS +------------------------ + +2007 + Christian Hujer <ch...@ri...> + * Creation + * Maintenance Property changes on: libs/io/trunk/MAINTAINERS ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/NEWS =================================================================== --- libs/io/trunk/NEWS (rev 0) +++ libs/io/trunk/NEWS 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,4 @@ +JAPI LIB IO NEWS +---------------- + +No news yet. Property changes on: libs/io/trunk/NEWS ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/README =================================================================== --- libs/io/trunk/README (rev 0) +++ libs/io/trunk/README 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,119 @@ +JAPI LIB IO README +================== + +This file contains some important information about Japi Lib IO. You should +read it first. + + +TABLE OF CONTENTS +----------------- +* project description +* project website +* system requirements +* file structure +* build / installation (see file INSTALL) +* maintainers / credits (see file CREDITS) +* project news (see file NEWS) +* mailing lists +* license information (see file LICENSE) + + +PROJECT DESCRIPTION +------------------- +Japi Lib IO is a subproject of Japi. +Japi Lib IO is an API for networking. +Japi is a set of APIs for various purposes. + + +PROJECT WEBSITE +--------------- +Project homepage: http://japi.sourceforge.net/ +Project website: http://sourceforge.net/projects/japi/ +Project statistics: http://cia.navi.cx/projects/japi +Subproject homepage: http://japi.sourceforge.net/libs/io/ + + +SYSTEM REQUIREMENTS +------------------- +Java 5.0 + Previous versions of Java will not work. Japi uses Generics, autoboxing, + static imports, foreach loops, assertions, covariant return types and varargs + quite a lot. + +Ant 1.6.5 + Previous versions of Ant might work but are not tested. + + +FILE STRUCTURE +-------------- +build.xml + The build file to build the project with Ant. + +common/ + Directory with libraries and other files that are common to all or most + Japi projects / modules. + +CHANGES + Changelog with significant changes. + +COPYING + Japi Lib IO license conditions. Note: applies to Japi Lib IO only, + not third party libraries. + +CREDITS + List of project contributors. See also MAINTAINERS. + +INSTALL + Description of how to build and install Japi Lib IO. + +LICENSE + File with license information. + +MAINTAINERS + List of current project maintainers. See also CREDITS. + +NEWS + Project News. + +module.properties + File with module-specific settings for common/commonBuild.xml. + +README + This file. + +src/ + Source files. + + +BUILD / INSTALLATION +-------------------- +See the file INSTALL. + + +MAINTAINERS / CREDITS +--------------------- +See the file CREDITS. + + +PROJECT NEWS +------------ +See the file NEWS. + + +MAILING LISTS +------------- +Japi mailing lists are the usual sourceforge hosted sourceforge project +mailing lists. The current mailing lists are: +* jap...@li... + News for JAPI users and developers (low traffic) +* jap...@li... + japi developer talk list +* jap...@li... + svn commit digest list (named cvs for historic reasons) +To find out how to subscribe or read the archives, go to: + http://sourceforge.net/mail/?group_id=149894 + + +LICSENSE INFORMATION +-------------------- +See the file LICENSE Property changes on: libs/io/trunk/README ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF Added: libs/io/trunk/build.xml =================================================================== --- libs/io/trunk/build.xml (rev 0) +++ libs/io/trunk/build.xml 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- + ~ JAPI libs-io is a library for I/O. + ~ Copyright (C) 2007 Christian Hujer. + ~ + ~ This library is free software; you can redistribute it and/or + ~ modify it under the terms of the GNU Lesser General Public + ~ License as published by the Free Software Foundation; either + ~ version 2.1 of the License, or (at your option) any later version. + ~ + ~ This library is distributed in the hope that it will be useful, + ~ but WITHOUT ANY WARRANTY; without even the implied warranty of + ~ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + ~ Lesser General Public License for more details. + ~ + ~ You should have received a copy of the GNU Lesser General Public + ~ License along with this library; if not, write to the Free Software + ~ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + --> +<!DOCTYPE project [ + <!ENTITY commonBuild SYSTEM "common/commonBuild.xml"> +]> +<project name="japi lib net" default="compile"> + + &commonBuild; + +</project> Property changes on: libs/io/trunk/build.xml ___________________________________________________________________ Name: svn:mime-type + text/xml Name: svn:eol-style + LF Added: libs/io/trunk/module.properties =================================================================== --- libs/io/trunk/module.properties (rev 0) +++ libs/io/trunk/module.properties 2007-07-07 09:35:46 UTC (rev 511) @@ -0,0 +1,24 @@ +# +# JAPI libs-io is a library for IO. +# Copyright (C) 2007 Christian Hujer. +# +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. +# +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public +# License along with this library; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +# + +update.focus=none +module.version=trunk +module.name=japi-lib-io +module.shortname=io +module.title=IO Property changes on: libs/io/trunk/module.properties ___________________________________________________________________ Name: svn:mime-type + text/plain Name: svn:eol-style + LF This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |