CubeTwister 2.0alpha142 2012-02-11

ch.randelshofer.rubik.parser
Class DefaultNotation

java.lang.Object
  extended by ch.randelshofer.rubik.parser.DefaultNotation
All Implemented Interfaces:
Notation

public class DefaultNotation
extends java.lang.Object
implements Notation

DefaultNotation supports Superset ENG. FIXME - This class is incomplete. It currently only works with a 3x3 Rubiks Cube.

Version:
0.4 2009-08-01 Improved compatibility with Superset ENG.
0.3 2009-04-11 Added constructor with layerCount parameter.
0.2 2008-11-24 Don't print "Null", if a symbol is not supported by this notation.
0.1 September 18, 2006 Experimental.
Author:
Werner Randelshofer

Constructor Summary
DefaultNotation()
          Creates a new instance.
DefaultNotation(int layerCount)
           
 
Method Summary
 void configureMoveFromToken(MoveNode move, java.lang.String moveToken)
          Configures a MoveNode from the specified move token.
 java.lang.String getEquivalentMacro(Cube cube, java.util.Map localMacros)
          Returns a macro which performs the same transformation as the cube parameter.
 int getLayerCount()
          Returns the number of layers supported by this notation.
 java.util.List<MacroNode> getMacros()
          Returns the macros defined by this notation.
 Symbol getSymbolFor(java.lang.String token, Symbol compositeSymbol)
          Returns a symbol for the specified token.
 Syntax getSyntax(Symbol s)
          Returns the syntax for the specified symbol.
 java.lang.String getToken(Move s)
          Returns a token for the specified move.
 java.lang.String getToken(Symbol s)
          Returns a token for the specified symbol.
 boolean isSupported(Symbol s)
          Returns true, if this notation supports the specified symbol.
 boolean isToken(java.lang.String token)
          Returns true, if the specified String is a token of this notation.
 boolean isTokenFor(java.lang.String token, Symbol symbol)
          Returns true, if the specified String is a token for the specified symbol.
 void writeToken(java.io.PrintWriter w, int axis, int layerMask, int angle)
          Writes a token for the specified transformation to the print writer.
 void writeToken(java.io.PrintWriter w, Symbol symbol)
          Writes a token for the specified symbol to the print writer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultNotation

public DefaultNotation()
Creates a new instance.


DefaultNotation

public DefaultNotation(int layerCount)
Method Detail

getLayerCount

public int getLayerCount()
Description copied from interface: Notation
Returns the number of layers supported by this notation.

Specified by:
getLayerCount in interface Notation

getEquivalentMacro

public java.lang.String getEquivalentMacro(Cube cube,
                                           java.util.Map localMacros)
Description copied from interface: Notation
Returns a macro which performs the same transformation as the cube parameter. Returns null if no macro is available.

Specified by:
getEquivalentMacro in interface Notation
Parameters:
cube - A transformed cube.
localMacros - A Map with local macros.

writeToken

public void writeToken(java.io.PrintWriter w,
                       Symbol symbol)
                throws java.io.IOException
Description copied from interface: Notation
Writes a token for the specified symbol to the print writer.

Specified by:
writeToken in interface Notation
Throws:
java.io.IOException - If the symbol is not supported by the notation, and if no alternative symbols could be found.

writeToken

public void writeToken(java.io.PrintWriter w,
                       int axis,
                       int layerMask,
                       int angle)
                throws java.io.IOException
Description copied from interface: Notation
Writes a token for the specified transformation to the print writer.

Specified by:
writeToken in interface Notation
Throws:
java.io.IOException

isSupported

public boolean isSupported(Symbol s)
Description copied from interface: Notation
Returns true, if this notation supports the specified symbol.

Specified by:
isSupported in interface Notation

getSyntax

public Syntax getSyntax(Symbol s)
Description copied from interface: Notation
Returns the syntax for the specified symbol. Note: This makes only sense for composite symbols.

Specified by:
getSyntax in interface Notation

isToken

public boolean isToken(java.lang.String token)
Description copied from interface: Notation
Returns true, if the specified String is a token of this notation.

Specified by:
isToken in interface Notation

isTokenFor

public boolean isTokenFor(java.lang.String token,
                          Symbol symbol)
Description copied from interface: Notation
Returns true, if the specified String is a token for the specified symbol.

Specified by:
isTokenFor in interface Notation

getToken

public java.lang.String getToken(Symbol s)
Description copied from interface: Notation
Returns a token for the specified symbol. If the symbol has more than one token, the first token is returned. Returns null, if symbol is not supported.

Specified by:
getToken in interface Notation

getSymbolFor

public Symbol getSymbolFor(java.lang.String token,
                           Symbol compositeSymbol)
Description copied from interface: Notation
Returns a symbol for the specified token. The compositeSymbol must be specified do disambiguate tokens. If the compositeSymbol is null, then the token must be unambiguous. Returns null, if the token is not a token for the specified compositeSymbol.

Specified by:
getSymbolFor in interface Notation

configureMoveFromToken

public void configureMoveFromToken(MoveNode move,
                                   java.lang.String moveToken)
Description copied from interface: Notation
Configures a MoveNode from the specified move token.

Specified by:
configureMoveFromToken in interface Notation

getToken

public java.lang.String getToken(Move s)
Description copied from interface: Notation
Returns a token for the specified move. If the move has more than one token, the first token is returned. Returns null, if move is not supported.

Specified by:
getToken in interface Notation

getMacros

public java.util.List<MacroNode> getMacros()
Description copied from interface: Notation
Returns the macros defined by this notation.

Specified by:
getMacros in interface Notation
Returns:
macros.

(c) Werner Randelshofer.
All rights reserved.