Class PlacementToken

  • Direct Known Subclasses:
    KoToken, MoveToken, PlacementListToken

    public class PlacementToken
    extends SGFToken
    A token that contains the point at which is was played, or the point to which it refers.

    Most often, this class will be used by BlackMoveToken and WhiteMoveToken.

    • Constructor Summary

      Constructors 
      Constructor Description
      PlacementToken()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected Point getPoint()
      Only subclasses (and classes in this package) may get at this class's Point variable.
      int getX()
      Returns: The X coordinate of the placement.
      int getY()
      Returns: The Y coordinate of the placement.
      protected boolean parseContent​(java.io.StreamTokenizer st)
      Subclasses must read all of the content and the final closing bracket.
      protected boolean parsePoint​(java.io.StreamTokenizer st)
      Parses a point, sets the X and Y values of the PlacementToken accordingly.
      • Methods inherited from class com.barrybecker4.ca.dj.jigo.sgf.tokens.SGFToken

        parse
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PlacementToken

        public PlacementToken()
    • Method Detail

      • parseContent

        protected boolean parseContent​(java.io.StreamTokenizer st)
                                throws java.io.IOException
        Description copied from class: SGFToken
        Subclasses must read all of the content and the final closing bracket. This is cool because all tokens end with a closing bracket anyway, which tells them when to stop reading. That's why there isn't a symmetrical read and validate (int)']' in the parse method, above.
        Specified by:
        parseContent in class SGFToken
        Parameters:
        st - - The SGF stream from which characters can be read.
        Throws:
        java.io.IOException
      • parsePoint

        protected boolean parsePoint​(java.io.StreamTokenizer st)
                              throws java.io.IOException
        Parses a point, sets the X and Y values of the PlacementToken accordingly. This can be called repeatedly for Tokens which take any number of points (see: PlacementListToken).

        The first opening '[' must have already been read; thus leaving two letters and a closing ']'. This method reads everything up to and including ']'. If a ']' follows immediately after the '[', then this move is considered a pass in FF[4].

        The letters are from 'a' through 'Z', inclusive, to represent row (or column) 1 through 52, respectfully.

        Please note that 'tt' is not treated as a Pass, in accordance to SGF FF[3]. It is treated as a move at 20, 20. It is up to the application (which knows the size of the board) to interpret (20, 20) as a pass--if the board size happens to be 19 lines or fewer.

        Returns: true - The point was perfectly parsed. false - The point wasn't perfectly parsed.

        Throws:
        java.io.IOException
      • getPoint

        protected Point getPoint()
        Only subclasses (and classes in this package) may get at this class's Point variable. Everybody else must use getX() and getY().
      • getX

        public int getX()
        Returns: The X coordinate of the placement.
      • getY

        public int getY()
        Returns: The Y coordinate of the placement.