net.sf.magicproject.tools
Class MCardCompare

java.lang.Object
  extended by net.sf.magicproject.tools.MCardCompare
All Implemented Interfaces:
java.lang.Comparable<MCardCompare>, java.util.Comparator<MCardCompare>

public class MCardCompare
extends java.lang.Object
implements java.util.Comparator<MCardCompare>, java.lang.Comparable<MCardCompare>

This class represents card's name and offset of card's code in mdb file.

Since:
0.53
Author:
Jan Blaha, Fabrice Daugan

Constructor Summary
MCardCompare()
          Create a new instance of MCardCompare
MCardCompare(java.lang.String name, int amount, java.util.Map<java.lang.String,java.lang.String> properties, long mdbOffset)
          Create a new instance of MCardCompare
MCardCompare(java.lang.String name, long mdbOffset)
          Create a new instance of MCardCompare
 
Method Summary
 void add(int amount)
          Add some cards.
 MCardCompare clone()
           
 int compare(MCardCompare o1, MCardCompare o2)
           
 int compareTo(MCardCompare o)
           
 boolean equals(java.lang.Object other)
           
 int getAmount()
          return the associated integer
 Targetable getCard(java.io.FileInputStream dbStream)
          Return an implementation of card corresponding to this card name.
 java.util.Map<java.lang.String,java.lang.String> getConstraints()
           
 long getMdbOffset()
          Return the MDB offset of first byte of card.
 CardModel getModel(java.io.FileInputStream dbStream)
          Return an implementation of card corresponding to this card name.
 java.lang.String getName()
          return card's name
 int hashCode()
           
 void remove(int amount)
          Remove some cards.
 void setAmount(int amount)
           
 void setMdbOffset(long mdbOffset)
           
 void setName(java.lang.String realCardName)
           
 java.lang.String toString()
          return the string representation of this item.
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MCardCompare

public MCardCompare()
Create a new instance of MCardCompare


MCardCompare

public MCardCompare(java.lang.String name,
                    long mdbOffset)
Create a new instance of MCardCompare

Parameters:
name - card's name.
mdbOffset - The MDB offset of first byte of card.

MCardCompare

public MCardCompare(java.lang.String name,
                    int amount,
                    java.util.Map<java.lang.String,java.lang.String> properties,
                    long mdbOffset)
Create a new instance of MCardCompare

Parameters:
name - card's name.
amount - amount of card
properties - the optional properties attached to these cards.
mdbOffset - The MDB offset of first byte of card.
Method Detail

getName

public java.lang.String getName()
return card's name

Returns:
card's name

getAmount

public int getAmount()
return the associated integer

Returns:
the associated integer

add

public void add(int amount)
Add some cards.

Parameters:
amount - the amount of card to add.

remove

public void remove(int amount)
Remove some cards.

Parameters:
amount - the amount of card to remove.

getConstraints

public java.util.Map<java.lang.String,java.lang.String> getConstraints()
Returns:
the list of properties of the current card

toString

public java.lang.String toString()
return the string representation of this item.

Overrides:
toString in class java.lang.Object
Returns:
name ; amount ; constraints

compare

public int compare(MCardCompare o1,
                   MCardCompare o2)
Specified by:
compare in interface java.util.Comparator<MCardCompare>

equals

public boolean equals(java.lang.Object other)
Specified by:
equals in interface java.util.Comparator<MCardCompare>
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

compareTo

public int compareTo(MCardCompare o)
Specified by:
compareTo in interface java.lang.Comparable<MCardCompare>

getMdbOffset

public long getMdbOffset()
Return the MDB offset of first byte of card.

Returns:
the MDB offset of first byte of card.

setName

public void setName(java.lang.String realCardName)
Parameters:
realCardName -

setAmount

public void setAmount(int amount)
Parameters:
amount -

setMdbOffset

public void setMdbOffset(long mdbOffset)
Parameters:
mdbOffset - The mdbOffset to set.

getCard

public Targetable getCard(java.io.FileInputStream dbStream)
                   throws java.io.IOException
Return an implementation of card corresponding to this card name. The returned instance cannot be modified and only contains the database data.

Parameters:
dbStream - the mdb stream's header.
Returns:
a lightweight implementation of a card corresponding to this card name.
Throws:
java.io.IOException - if io exception occurred.

getModel

public CardModel getModel(java.io.FileInputStream dbStream)
                   throws java.io.IOException
Return an implementation of card corresponding to this card name. The returned instance cannot be modified and only contains the database data.

Parameters:
dbStream - the mdb stream's header.
Returns:
a lightweight implementation of a card corresponding to this card name.
Throws:
java.io.IOException - if io exception occurred.

clone

public MCardCompare clone()
Overrides:
clone in class java.lang.Object


Copyright © 2003-2007 Magic-Project. All Rights Reserved.