Class SimpleOrder

    • Field Summary

      • Fields inherited from interface magellan.library.Order

        ALL
    • Constructor Summary

      Constructors 
      Constructor Description
      SimpleOrder​(java.util.List<OrderToken> tokens, java.lang.String text)
      Creates a new order from a list of tokens.
      SimpleOrder​(OrderToken oneToken, java.lang.String text)
      Creates an order consisting of just one token.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void execute​(ExecutionState state, GameData data, Unit unit, int line)
      The default implementation does nothing!
      java.lang.String getPrefix()  
      Problem getProblem()
      If a problem has been set, it is returned here.
      java.lang.String getText()
      Returns the original text that the order was parsed from, so it contains all white space characters and the "@".
      OrderToken getToken​(int i)  
      java.util.List<OrderToken> getTokens()
      Returns a view on the order tokens.
      boolean isEmpty()  
      boolean isLong()
      Returns true if this is a "long" order.
      boolean isPersistent()  
      boolean isValid()
      This method returns true if there's a syntactic problem with the order.
      protected void setError​(Unit unit, int line, java.lang.String string)
      Registers a severe error for a unit order.
      void setLong​(boolean isLong)
      Sets the value of isLong.
      void setPersistent​(boolean b)
      Determines if this is a persistent ("@") order.
      void setProblem​(Problem problem)
      Sets a warning or error.
      void setValid​(boolean valid)
      Marks the order as valid or unvalid.
      protected void setWarning​(Unit unit, int line, java.lang.String string)
      Registers a warning for a unit order.
      int size()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

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

      • SimpleOrder

        public SimpleOrder​(OrderToken oneToken,
                           java.lang.String text)
        Creates an order consisting of just one token. If finishWithEOC == true, an additional EOC token is added.
        Parameters:
        oneToken -
        text - The complete text of the order
      • SimpleOrder

        public SimpleOrder​(java.util.List<OrderToken> tokens,
                           java.lang.String text)
        Creates a new order from a list of tokens.
        Parameters:
        tokens - The sequence of order tokens
        text - The complete text of the order
    • Method Detail

      • isValid

        public boolean isValid()
        Description copied from interface: Order
        This method returns true if there's a syntactic problem with the order. Use Order.getProblem() to include other problems. If isValid returns true, Order.getProblem() must return a problem.
        Specified by:
        isValid in interface Order
        Returns:
        true if the order has been found valid by the order parser.
        See Also:
        Order.isValid()
      • setValid

        public void setValid​(boolean valid)
        Marks the order as valid or unvalid.
      • getTokens

        public java.util.List<OrderToken> getTokens()
        Description copied from interface: Order
        Returns a view on the order tokens. These includes the OrderToken.TT_EOC token at the end, but not the persistent ("@") token at the start.
        Specified by:
        getTokens in interface Order
        Returns:
        an unmodifiable view on the tokens
        See Also:
        Order.getTokens()
      • getText

        public java.lang.String getText()
        Description copied from interface: Order
        Returns the original text that the order was parsed from, so it contains all white space characters and the "@".
        Specified by:
        getText in interface Order
        Returns:
        the original text that the order was parsed from.
        See Also:
        Order.getText()
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object
      • setLong

        public void setLong​(boolean isLong)
        Sets the value of isLong.
        Parameters:
        isLong - The value for isLong.
      • isLong

        public boolean isLong()
        Description copied from interface: Order
        Returns true if this is a "long" order.
        Specified by:
        isLong in interface Order
        See Also:
        Order.isLong()
      • getProblem

        public Problem getProblem()
        Description copied from interface: Order
        If a problem has been set, it is returned here. If the order is invalid, at least an OrderSyntaxProblem should is returned.
        Specified by:
        getProblem in interface Order
        Returns:
        Returns the problem or null
        See Also:
        Order.getProblem()
      • setWarning

        protected void setWarning​(Unit unit,
                                  int line,
                                  java.lang.String string)
        Registers a warning for a unit order.
        See Also:
        SimpleProblem
      • setError

        protected void setError​(Unit unit,
                                int line,
                                java.lang.String string)
        Registers a severe error for a unit order.
        See Also:
        SimpleProblem
      • getPrefix

        public java.lang.String getPrefix()