Changeset 69d070a


Ignore:
Timestamp:
Aug 17, 2010, 9:42:24 PM (8 years ago)
Author:
Michael Seifert <mseifert@…>
Branches:
master
Children:
0267dff
Parents:
df50e1c
Message:

Refactoring;
Added javadoc comments

Files:
17 edited
2 moved

Legend:

Unmodified
Added
Removed
  • core/src/main/java/de/erichseifert/warp/core/DataPresenter.java

    rdf50e1c r69d070a  
    3232
    3333import de.erichseifert.warp.core.io.MemoryStorage;
     34import de.erichseifert.warp.core.io.ReplayDataChangeListener;
    3435import de.erichseifert.warp.core.io.ReplayStorage;
    3536import de.erichseifert.warp.core.io.Settings;
     
    3738import de.erichseifert.warp.core.io.search.indices.Index.Range;
    3839import de.erichseifert.warp.core.replay.Replay;
    39 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
    4040import de.erichseifert.warp.core.replay.ReplayDescriptor;
    4141import de.erichseifert.warp.core.replay.ReplayParser;
  • core/src/main/java/de/erichseifert/warp/core/WARP.java

    rdf50e1c r69d070a  
    2222package de.erichseifert.warp.core;
    2323
    24 import de.erichseifert.warp.core.io.BufferedStorage;
    25 import de.erichseifert.warp.core.io.ReplayStorage;
    26 import de.erichseifert.warp.core.io.SerializingStorage;
    2724import de.erichseifert.warp.core.io.Settings;
    28 import de.erichseifert.warp.core.ui.CLI;
    2925import de.erichseifert.warp.core.ui.WARPUI;
    3026
    3127/**
    32  * Class that represents the supervising class of the replay parser.
    33  * It coordinates the data model and the user interface.
     28 * Class that represents the main class of the core module.
     29 * It coordinates the data model (<code>MemoryStorage</code>) and the
     30 * user interface (<code>CLI</code>).
    3431 */
    3532public class WARP extends DataPresenter {
    3633
     34        /**
     35         * Creates a <code>WARP</code> object.
     36         */
    3737        public WARP() {
    38                 ReplayStorage storage = new SerializingStorage();
    39                 ReplayStorage storageBuffer = new BufferedStorage(storage);
    40                 setStorage(storageBuffer);
    41 
    42                 WARPUI ui = new CLI();
    43                 setUi(ui);
    44 
    45                 ui.setReplays(storage.getDescriptors());
     38                WARPUI ui = getUi();
     39                ui.setReplays(getStorage().getDescriptors());
    4640                boolean parsingComplete = Settings.getInstance().isParsingComplete();
    4741                if (!parsingComplete) {
  • core/src/main/java/de/erichseifert/warp/core/io/AbstractReplayStorage.java

    rdf50e1c r69d070a  
    2626
    2727import de.erichseifert.warp.core.replay.Replay;
    28 import de.erichseifert.warp.core.replay.ReplayChangeEvent;
    29 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
    3028import de.erichseifert.warp.core.replay.ReplayDescriptor;
    3129
     30/**
     31 * Abstract class that implements basic functionality of a replay storage.
     32 * Implemented functionality includes the administration of listeners and
     33 * their notification on data changes.
     34 */
    3235public abstract class AbstractReplayStorage implements ReplayStorage {
    33         protected transient final Set<ReplayDataChangeListener> listeners;
     36        private transient final Set<ReplayDataChangeListener> listeners;
    3437
     38        /**
     39         * Creates an <code>AbstractReplayStorage</code> object.
     40         */
    3541        public AbstractReplayStorage() {
    3642                listeners = new HashSet<ReplayDataChangeListener>();
     
    5965        }
    6066
     67        /**
     68         * Notifies all registered listeners that the data of a replay has changed.
     69         *
     70         * If the old descriptor is <code>null</code>, a replay has been added.
     71         * If the new descriptor is <code>null</code>, a replay has been removed.
     72         * @param descriptorOld Old replay descriptor.
     73         * @param descriptorNew New replay descriptor.
     74         */
    6175        protected void fireReplayDataChanged(ReplayDescriptor descriptorOld, ReplayDescriptor descriptorNew) {
    6276                ReplayChangeEvent evt = new ReplayChangeEvent(this, descriptorOld, descriptorNew);
     
    6579                }
    6680        }
     81
     82        /**
     83         * Returns a set of all registered listeners.
     84         * @return Listeners.
     85         */
     86        protected Set<ReplayDataChangeListener> getListeners() {
     87                return listeners;
     88        }
    6789}
  • core/src/main/java/de/erichseifert/warp/core/io/BufferedStorage.java

    rdf50e1c r69d070a  
    3131import de.erichseifert.warp.core.io.statistics.Statistics;
    3232import de.erichseifert.warp.core.replay.Replay;
    33 import de.erichseifert.warp.core.replay.ReplayChangeEvent;
    34 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
    3533import de.erichseifert.warp.core.replay.ReplayDescriptor;
    3634
     
    145143        public void replayChanged(ReplayChangeEvent evt) {
    146144                evt.setSource(this);
    147                 for (ReplayDataChangeListener listener : listeners) {
     145                for (ReplayDataChangeListener listener : getListeners()) {
    148146                        listener.replayChanged(evt);
    149147                }
  • core/src/main/java/de/erichseifert/warp/core/io/ReplayChangeEvent.java

    rdf50e1c r69d070a  
    2020 */
    2121
    22 package de.erichseifert.warp.core.replay;
     22package de.erichseifert.warp.core.io;
    2323
    24 import de.erichseifert.warp.core.io.ReplayStorage;
     24import de.erichseifert.warp.core.replay.ReplayDescriptor;
    2525
    2626public class ReplayChangeEvent {
  • core/src/main/java/de/erichseifert/warp/core/io/ReplayDataChangeListener.java

    rdf50e1c r69d070a  
    2020 */
    2121
    22 package de.erichseifert.warp.core.replay;
     22package de.erichseifert.warp.core.io;
    2323
    2424/**
  • core/src/main/java/de/erichseifert/warp/core/io/ReplayStorage.java

    rdf50e1c r69d070a  
    3030import de.erichseifert.warp.core.io.statistics.Statistics;
    3131import de.erichseifert.warp.core.replay.Replay;
    32 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
    3332import de.erichseifert.warp.core.replay.ReplayDescriptor;
    3433
    3534/**
    3635 * Interface that provides basic functions to store and load replays.
     36 * It also provides statistics and search functionality.
    3737 */
    3838public interface ReplayStorage {
     
    5555        void delete(long id);
    5656
     57        /**
     58         * Returns the replay with the specified descriptor.
     59         * @param descriptor Descriptor of the replay.
     60         * @return Replay.
     61         */
    5762        Replay getReplay(ReplayDescriptor descriptor);
    5863
     
    7176        int size();
    7277
     78        /**
     79         * Returns the statistics class for the stored replays.
     80         * @return Statistics.
     81         */
    7382        Statistics getStatistics();
    7483
    75         Set<ReplayDescriptor> search(Map<String, Object> query, Map<String, Range> ranges, SearchMode mode);
     84        /**
     85         * Returns all descriptors whose replays match the specified queries
     86         * and ranges applied in the specified search mode.
     87         * @param queries Map containing the index name to be searched and the value to be searched for.
     88         * @param ranges Map containing the index name and the range to delimit the search.
     89         * @param mode Search mode.
     90         * @return Replay descriptors.
     91         */
     92        Set<ReplayDescriptor> search(Map<String, Object> queries, Map<String, Range> ranges, SearchMode mode);
    7693
    7794        /**
    7895         * Returns, whether the specified replay has already been stored or not.
    7996         * @param replayFile File to the unparsed replay.
    80          * @return <code>true</code> if the replay already has been stored.
     97         * @return <code>true</code> if the replay already has been stored, <code>false</code> otherwise.
    8198         */
    8299        boolean contains(File replayFile);
    83100
     101        /**
     102         * Adds the specified listener to the set of notified listeners.
     103         * @param listener Listener to be added.
     104         */
    84105        void addReplayDataChangeListener(ReplayDataChangeListener listener);
     106        /**
     107         * Removes the specified listener from the set of notified listeners.
     108         * @param listener Listener to be removed.
     109         */
    85110        void removeReplayDataChangeListener(ReplayDataChangeListener listener);
    86111
     112        /**
     113         * Returns the names of all registered indices.
     114         * @return Names of indices.
     115         */
    87116        Set<String> getIndexNames();
    88117
     118        /**
     119         * Removes all replays from the storage.
     120         * This method also clears possible metadata.
     121         */
    89122        void clear();
    90123}
  • core/src/main/java/de/erichseifert/warp/core/io/search/DefaultReplayIndexer.java

    rdf50e1c r69d070a  
    3131import java.util.Set;
    3232
     33import de.erichseifert.warp.core.io.ReplayChangeEvent;
    3334import de.erichseifert.warp.core.io.ReplayStorage;
     35import de.erichseifert.warp.core.io.ReplayChangeEvent.EventType;
    3436import de.erichseifert.warp.core.io.search.IndexHierarchy.Node;
    3537import de.erichseifert.warp.core.io.search.indices.Index;
    3638import de.erichseifert.warp.core.io.search.indices.Index.Range;
    3739import de.erichseifert.warp.core.replay.Replay;
    38 import de.erichseifert.warp.core.replay.ReplayChangeEvent;
    3940import de.erichseifert.warp.core.replay.ReplayDescriptor;
    40 import de.erichseifert.warp.core.replay.ReplayChangeEvent.EventType;
    4141
    4242/**
  • core/src/main/java/de/erichseifert/warp/core/io/search/ReplayIndexer.java

    rdf50e1c r69d070a  
    2626import java.util.Set;
    2727
     28import de.erichseifert.warp.core.io.ReplayDataChangeListener;
    2829import de.erichseifert.warp.core.io.ReplayStorage;
    2930import de.erichseifert.warp.core.io.search.IndexHierarchy.Node;
    3031import de.erichseifert.warp.core.io.search.indices.Index.Range;
    31 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
    3232import de.erichseifert.warp.core.replay.ReplayDescriptor;
    3333
  • core/src/main/java/de/erichseifert/warp/core/io/statistics/SC2Statistics.java

    rdf50e1c r69d070a  
    2222package de.erichseifert.warp.core.io.statistics;
    2323
    24 import de.erichseifert.warp.core.replay.ReplayChangeEvent;
     24import de.erichseifert.warp.core.io.ReplayChangeEvent;
    2525
    2626public class SC2Statistics implements Statistics {
  • core/src/main/java/de/erichseifert/warp/core/io/statistics/Statistics.java

    rdf50e1c r69d070a  
    2424import java.io.Serializable;
    2525
    26 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
     26import de.erichseifert.warp.core.io.ReplayDataChangeListener;
    2727
    2828public interface Statistics extends ReplayDataChangeListener, Serializable {
  • core/src/main/java/de/erichseifert/warp/core/replay/DefaultChatMessage.java

    rdf50e1c r69d070a  
    2222package de.erichseifert.warp.core.replay;
    2323
    24 import de.erichseifert.warp.core.DefaultVersionedComponent;
    2524import de.erichseifert.warp.core.io.search.Indexable;
    2625import de.erichseifert.warp.core.io.search.indices.FullTextIndex;
     
    2928 * Class that represents a default implementation of a chat message.
    3029 */
    31 public class DefaultChatMessage extends DefaultVersionedComponent implements ChatMessage {
     30public class DefaultChatMessage implements ChatMessage {
    3231        private final int timeStamp;
    3332        private final int channelCode;
  • core/src/main/java/de/erichseifert/warp/core/replay/DefaultGameAction.java

    rdf50e1c r69d070a  
    2222package de.erichseifert.warp.core.replay;
    2323
    24 import de.erichseifert.warp.core.DefaultVersionedComponent;
    2524
    2625/**
    2726 * Class the represents the default implementation of a game action.
    2827 */
    29 public class DefaultGameAction extends DefaultVersionedComponent implements GameAction {
     28public class DefaultGameAction implements GameAction {
    3029        private int timestamp;
    3130
  • core/src/main/java/de/erichseifert/warp/core/replay/DefaultPlayer.java

    rdf50e1c r69d070a  
    2727import java.util.List;
    2828
    29 import de.erichseifert.warp.core.DefaultVersionedComponent;
    3029import de.erichseifert.warp.core.io.search.Indexable;
    3130import de.erichseifert.warp.core.io.search.IndexableChildren;
    3231import de.erichseifert.warp.core.io.search.indices.FullTextIndex;
    3332
    34 public class DefaultPlayer extends DefaultVersionedComponent implements Player {
     33/**
     34 * Class that represents the default implementation of a player.
     35 * It contains a the player's actions and chat messages, as well as his
     36 * name, color, and race. Players may even be observers only.
     37 */
     38public class DefaultPlayer implements Player {
    3539        private final List<GameAction> actions;
    3640        private final List<ChatMessage> messages;
     
    4044        private boolean observer;
    4145
     46        /**
     47         * Creates a <code>DefaultPlayer</code> with the specified name.
     48         * @param name Player name.
     49         */
    4250        public DefaultPlayer(String name) {
    4351                this.name = name;
     
    5159        }
    5260
     61        /**
     62         * Sets the player's actions to the specified value.
     63         * @param actions Actions.
     64         */
    5365        protected void setActions(List<? extends GameAction> actions) {
    5466                this.actions.clear();
     
    6375        }
    6476
     77        /**
     78         * Sets the color to the specified value.
     79         * @param color Color.
     80         */
    6581        protected void setColor(Color color) {
    6682                this.color = color;
     
    7389        }
    7490
     91        /**
     92         * Sets the player's chat messages to the specified value.
     93         * @param messages Chat messages.
     94         */
    7595        protected void setMessages(List<? extends ChatMessage> messages) {
    7696                this.messages.clear();
     
    92112        }
    93113
     114        /**
     115         * Sets the race to the specified value.
     116         * @param race Race.
     117         */
    94118        protected void setRace(String race) {
    95119                this.race = race;
     
    101125        }
    102126
     127        /**
     128         * Sets whether the player is an observer.
     129         * @param observer <code>true</code>, if the player is an observer, <code>false</code> otherwise.
     130         */
    103131        protected void setObserver(boolean observer) {
    104132                this.observer = observer;
  • core/src/main/java/de/erichseifert/warp/core/replay/DefaultReplay.java

    rdf50e1c r69d070a  
    3232
    3333/**
    34  * Abstract implementation of the <code>Replay</code> interface.
    35  * The <code>AbstracReplay</code> itself is also a <code>VersionedComponent</code> to
    36  * allow support for specific replay versions.
     34 * Default implementation of the <code>Replay</code> interface.
    3735 */
    3836public class DefaultReplay implements Replay {
     
    4139
    4240        /**
    43          * Creates a new AbstractReplay object with the specified file.
    44          * @param file
     41         * Creates a <code>DefaultReplay</code> object representing the
     42         * specified file.
     43         * @param file Replay location.
    4544         */
    4645        public DefaultReplay(File file) {
     
    8988        }
    9089
     90        /**
     91         * Sets the version to the specified value.
     92         * @param version Version string.
     93         */
    9194        protected void setVersion(String version) {
    9295                descriptor.setVersion(version);
    9396        }
    9497
     98        /**
     99         * Sets the duration to the specified value.
     100         * @param duration Duration.
     101         */
    95102        protected void setDuration(int duration) {
    96103                descriptor.setDuration(duration);
  • core/src/main/java/de/erichseifert/warp/core/replay/GameAction.java

    rdf50e1c r69d070a  
    2424import java.io.Serializable;
    2525
    26 import de.erichseifert.warp.core.VersionedComponent;
    27 
    2826/**
    2927 * Interface that represents a basic action a player has undertaken.
    3028 */
    31 public interface GameAction extends VersionedComponent, Serializable {
     29public interface GameAction extends Serializable {
    3230        /**
    3331         * Returns the point in time when this action has occurred.
  • gui.swing/src/main/java/de/erichseifert/warp/gui/swing/ReplayParserGUI.java

    rdf50e1c r69d070a  
    8585import de.erichseifert.warp.core.DataPresenter;
    8686import de.erichseifert.warp.core.ProgressListener;
     87import de.erichseifert.warp.core.io.ReplayChangeEvent;
     88import de.erichseifert.warp.core.io.ReplayDataChangeListener;
    8789import de.erichseifert.warp.core.io.Settings;
     90import de.erichseifert.warp.core.io.ReplayChangeEvent.EventType;
    8891import de.erichseifert.warp.core.io.search.indices.Index.Range;
    8992import de.erichseifert.warp.core.replay.Player;
    9093import de.erichseifert.warp.core.replay.Replay;
    91 import de.erichseifert.warp.core.replay.ReplayChangeEvent;
    92 import de.erichseifert.warp.core.replay.ReplayDataChangeListener;
    9394import de.erichseifert.warp.core.replay.ReplayDescriptor;
    94 import de.erichseifert.warp.core.replay.ReplayChangeEvent.EventType;
    9595import de.erichseifert.warp.core.ui.WARPUI;
    9696import de.erichseifert.warp.core.util.FileUtil;
  • sc2replay/src/main/java/de/erichseifert/warp/sc2replay/SC2ChatLog.java

    rdf50e1c r69d070a  
    2929import java.util.Map;
    3030
    31 import de.erichseifert.warp.core.DefaultVersionedComponent;
    3231import de.erichseifert.warp.core.replay.ChatMessage;
    3332import de.erichseifert.warp.core.replay.DefaultChatMessage;
     
    3534import de.erichseifert.warp.sc2replay.util.SC2ReplayUtil;
    3635
    37 public class SC2ChatLog extends DefaultVersionedComponent {
     36public class SC2ChatLog {
    3837        private static final byte CHANNEL_CODE_ALL = 0x0;
    3938        private static final byte CHANNEL_CODE_TEAM = 0x2;
  • sc2replay/src/main/java/de/erichseifert/warp/sc2replay/renderers/SC2PlayerRenderer.java

    rdf50e1c r69d070a  
     1/*
     2 * WARP: WARP is a Replay Manager for Java(R)
     3 *
     4 * (C) Copyright 2010-2010 Michael Seifert <michael.seifert[at]gmx.net>
     5 *
     6 * This file is part of WARP.
     7 *
     8 * WARP is free software: you can redistribute it and/or modify
     9 * it under the terms of the GNU General Public License as published by
     10 * the Free Software Foundation, either version 3 of the License, or
     11 * (at your option) any later version.
     12 *
     13 * WARP is distributed in the hope that it will be useful,
     14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
     15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16 * GNU General Public License for more details.
     17 *
     18 * You should have received a copy of the GNU General Public License
     19 * along with WARP.  If not, see <http://www.gnu.org/licenses/>.
     20 */
     21
    122package de.erichseifert.warp.sc2replay.renderers;
    223
Note: See TracChangeset for help on using the changeset viewer.