Changeset 8284c2d


Ignore:
Timestamp:
Sep 12, 2011, 2:36:30 PM (6 years ago)
Author:
Michael Seifert <mseifert@…>
Branches:
master
Children:
aee5e85
Parents:
24b6516
Message:

ReplayDescriptor? now is an interface;
The implementation that is now used is called DefaultReplayDescriptor?

Files:
1 added
6 edited

Legend:

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

    r24b6516 r8284c2d  
    2525import java.io.Serializable;
    2626
    27 import de.erichseifert.warp.core.io.search.Indexable;
    28 import de.erichseifert.warp.core.io.search.indices.FieldIndex;
    29 import de.erichseifert.warp.core.io.search.indices.FullTextIndex;
    30 import de.erichseifert.warp.core.util.FileUtil;
    31 
    3227/**
    33  * Immutable class that represents the most basic information about a
    34  * {@link Replay}.
     28 * Interface that exposes the most basic information about a replay.
     29 * @see Replay
     30 * @see DefaultReplayDescriptor
    3531 */
    36 // TODO: Make ReplayDescriptor an Interface
    37 public class ReplayDescriptor implements Serializable {
    38         private final File file;
    39         private final int duration;
    40         private final String version;
    41         private final long id;
    42 
    43         /**
    44          * Creates a new <code>ReplayDescriptor</code> object of the specified
    45          * file.
    46          * @param file File to replay.
    47          * @param version Version of the replay.
    48          * @param duration Duration of the match.
    49          */
    50         // TODO: Change File to InputStream
    51         public ReplayDescriptor(File file, String version, int duration) {
    52                 this.file = file;
    53                 this.version = version;
    54                 this.duration = duration;
    55                 id = FileUtil.fileHash(file);
    56         }
     32public interface ReplayDescriptor extends Serializable {
    5733
    5834        /**
     
    6036         * @return File.
    6137         */
    62         @Indexable(indexName="replay.file", indexClass=FullTextIndex.class)
    63         public File getFile() {
    64                 return file;
    65         }
     38        File getFile();
    6639
    6740        /**
     
    6942         * @return Duration.
    7043         */
    71         @Indexable(indexName="replay.duration", indexClass=FieldIndex.class)
    72         public int getDuration() {
    73                 return duration;
    74         }
     44        int getDuration();
    7545
    7646        /**
     
    7848         * @return Version
    7949         */
    80         @Indexable(indexName="replay.version", indexClass=FullTextIndex.class)
    81         public String getVersion() {
    82                 return version;
    83         }
    84 
    85         @Override
    86         public boolean equals(Object obj) {
    87                 if (obj instanceof ReplayDescriptor) {
    88                         String objFilePath = ((ReplayDescriptor) obj).getFile().getAbsolutePath();
    89                         return file.getAbsolutePath().equals(objFilePath);
    90                 }
    91                 return super.equals(obj);
    92         }
     50        String getVersion();
    9351
    9452        /**
     
    9654         * @return Unique id.
    9755         */
    98         public long getId() {
    99                 return id;
    100         }
     56        long getId();
    10157}
  • core/src/test/java/de/erichseifert/warp/core/replay/ReplayDescriptorTest.java

    r24b6516 r8284c2d  
    3232        }
    3333
    34         public static class ReplayDescriptorStub extends ReplayDescriptor {
     34        public static class ReplayDescriptorStub extends DefaultReplayDescriptor {
    3535                public ReplayDescriptorStub() {
    3636                        super(file, version, duration);
  • lolreplay/src/main/java/de/erichseifert/warp/lolreplay/LOLReplayParser.java

    r24b6516 r8284c2d  
    3333import java.util.Map;
    3434
     35import de.erichseifert.warp.core.replay.DefaultReplayDescriptor;
    3536import de.erichseifert.warp.core.replay.ReplayDescriptor;
    3637import de.erichseifert.warp.core.replay.ReplayParser;
     
    4142        @Override
    4243        public LOLReplay getReplay(File file) throws IOException {
    43                 ReplayDescriptor descriptor = new ReplayDescriptor(file, "unknown", -1);
     44                ReplayDescriptor descriptor = new DefaultReplayDescriptor(file, "unknown", -1);
    4445                LOLReplay replay = new LOLReplay(descriptor, Collections.<LOLPlayer>emptyList());
    4546
  • sc2replay/src/main/java/de/erichseifert/warp/sc2replay/SC2ReplayParser_v1.java

    r24b6516 r8284c2d  
    3838import de.erichseifert.mpqparser.MPQArchive;
    3939import de.erichseifert.warp.core.replay.ChatMessage;
     40import de.erichseifert.warp.core.replay.DefaultReplayDescriptor;
    4041import de.erichseifert.warp.core.replay.GameActionFactory;
    4142import de.erichseifert.warp.core.replay.ReplayDescriptor;
     
    8384                int duration = src.getShort();
    8485
    85                 ReplayDescriptor descriptor = new ReplayDescriptor(file, version, duration);
     86                ReplayDescriptor descriptor = new DefaultReplayDescriptor(file, version, duration);
    8687
    8788                System.out.println("Parsing file: "+file.getPath()+" Version: "+version);
  • sc2replay/src/main/java/de/erichseifert/warp/sc2replay/SC2ReplayParser_v2.java

    r24b6516 r8284c2d  
    3838import de.erichseifert.mpqparser.MPQArchive;
    3939import de.erichseifert.warp.core.replay.ChatMessage;
     40import de.erichseifert.warp.core.replay.DefaultReplayDescriptor;
    4041import de.erichseifert.warp.core.replay.GameActionFactory;
    4142import de.erichseifert.warp.core.replay.ReplayDescriptor;
     
    8586                int duration = src.getShort();
    8687
    87                 ReplayDescriptor descriptor = new ReplayDescriptor(file, version, duration);
     88                ReplayDescriptor descriptor = new DefaultReplayDescriptor(file, version, duration);
    8889
    8990                System.out.println("Parsing file: "+file.getPath()+" Version: "+version);
  • sc2replay/src/main/java/de/erichseifert/warp/sc2replay/SC2ReplayParser_v3.java

    r24b6516 r8284c2d  
    3838import de.erichseifert.mpqparser.MPQArchive;
    3939import de.erichseifert.warp.core.replay.ChatMessage;
     40import de.erichseifert.warp.core.replay.DefaultReplayDescriptor;
    4041import de.erichseifert.warp.core.replay.GameActionFactory;
    4142import de.erichseifert.warp.core.replay.ReplayDescriptor;
     
    8485                int duration = header.getDataStruct(3).getInt() >> 3;
    8586
    86                 ReplayDescriptor descriptor = new ReplayDescriptor(file, version, duration);
     87                ReplayDescriptor descriptor = new DefaultReplayDescriptor(file, version, duration);
    8788
    8889                System.out.println("Parsing file: "+file.getPath()+" Version: "+version);
Note: See TracChangeset for help on using the changeset viewer.