Package net.gereon.jloom.syntax.impl.commands

Source Code of net.gereon.jloom.syntax.impl.commands.SimpleCommandDefinition

/*
This file is part of JLoom
Copyright (C) 2006  Gereon Fassbender
Homepage: jloom.sourceforge.net

JLoom is free software; you can redistribute it and/or modify it under the terms
of the GNU General Public License as published by the Free Software Foundation;
either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE. See the GNU General Public License for more details.

You can find a copy of the GNU General Public License along with this program
in a file called COPYING. Information can also be found at www.fsf.org or
www.gnu.org or write to the Free Software Foundation, Inc., 51 Franklin Street,
Fifth Floor, Boston, MA 02110-1301, USA
*/
/*
created: 21.01.2006  Gereon Fassbender

$Revision$
$Date$
$Log$
*/

package net.gereon.jloom.syntax.impl.commands;

import java.util.EnumSet;

import net.gereon.jloom.core.CommandOption;
import net.gereon.jloom.problems.ProblemHandler;
import net.gereon.jloom.syntax.*;
import net.gereon.jloom.syntax.impl.ParametersImpl;
import net.gereon.jloom.util.*;



public class SimpleCommandDefinition implements CommandDefinition
{
  private final static EnumSet<CommandOption> OPTIONS =
                                EnumSet.of(CommandOption.EMPTY_ALLOWED,
                                           CommandOption.NONEMPTY_ALLOWED,
                                           CommandOption.TOPLEVEL_ALLOWED,
                                           CommandOption.TRIM);
 
  private String name;
  private Parameters parameters;
  private Parameters secondaryParameters;
 
 
 
  SimpleCommandDefinition(String name, int parameterCount, String... secondaryParameterNames)
  {
    assert name != null;
    assert !name.equals("");
    assert secondaryParameterNames != null;
    this.name = name;
    //this.parameterCount = parameterCount;
   
    this.parameters = new ParametersImpl(parameterCount);
    this.secondaryParameters = new ParametersImpl(secondaryParameterNames);
  }
 
 
  public String getName()
  {
    return name;
  }
 
 
  public Parameters getParameters()
  {
    return parameters;
  }


  public Parameters getSecondaryParameters()
  {
    return secondaryParameters;
  }


  /*
  public boolean isNonEmptyAllowed()
  {
    return true;
  }
  public boolean isEmptyAllowed()
  {
    return true;
  }
  */
 

  public EnumSet<CommandOption> getOptions()
  {
    return OPTIONS;
  }
 
 
  public boolean validate(ProblemHandler handler, CommandBlock cmd)
  {
    assert handler != null;
    assert cmd != null;
   
    return true;
    /*
    Block parent = cmd.getParent();
    assert parent != null;
    if (parent.getParent() != null) {
      String msg = "Command " + name + " has to be on the first level.";
      TranslationTools.createProblem(handler, msg, cmd.getCommand());
      return false;
    }
    else {
      Log.log.finer("command correct: " + name);
      return true;
    }
    */
  }
}
TOP

Related Classes of net.gereon.jloom.syntax.impl.commands.SimpleCommandDefinition

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.