Package ket.math.purpose

Source Code of ket.math.purpose.Value

/*
* Copyright (C) 2011  Alasdair C. Hamilton
*
* This program 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 3 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 should have received a copy of the GNU General Public License
* along with this program.  If not, see <http://www.gnu.org/licenses/>
*/

package ket.math.purpose;

import java.awt.*;
import java.util.*;

import ket.display.*;
import ket.display.box.Box;
import ket.display.box.BoxWord;
import ket.math.Argument;
import ket.math.State;

public abstract class Value extends State {
  public abstract String getValue();

  @Override
  public Box toBox(Argument argument, long settings, ColourScheme colourScheme) {
    // TODO: Is it always appropriate to have a null argument associated with the return value?
    // TODO: Is is appropriate that Text.toBox() creates boxWord instances?
    return new BoxWord(argument, getValue(), settings);
  }

  @Override
  public String toVerboseString() {
    return getValue();
  }

  /* -----------------------------------------
   * Use hasBracket() in the case of numbers?
   * ----------------------------------------- */
  @Override
  public String toHTML() {
    return getValue();
  }

  @Override
  public String toLatex() {
    return " " + getValue() + " ";
  }

  @Override
  public String toUnicode() {
    return " " + getValue() + " ";
  }
  /* ----------------------------------------- */


  /**
   * Check that this object equals the given argument, regardless of any
   * child components.
   */
  public boolean elementEquals(Argument argument) {
    return getValue().equals(argument.getValue());
  }

  public boolean subBranchEquals(Argument argument) {
    return this.elementEquals(argument);
  }

  @Override
  public int iterateToStateForwards(Vector<Argument> args, int index) {
    // Don't use this method: while these can be hidden inside a
    // compound state, they should never be searched for directly.
    throw new RuntimeException("unfinished");
  }

  @Override
  public int iterateToStateBackwards(Vector<Argument> args) {
    // Don't use this method: while these can be hidden inside a
    // compound state, they should never be searched for directly.
    throw new RuntimeException("unfinished");
  }

  @Override
  public int[] findAllStateIndices(Vector<Argument> args, boolean includeLeft, boolean includeRight) {
    // Don't use this method: while these can be hidden inside a
    // compound state, they should never be searched for directly.
    throw new RuntimeException("unfinished");
  }

  @Override
  public String getName() {
    //+ Ket.out.println(" !!! What does value::getName() mean? !!! ");
    return getValue();
  }

  @Override
  public String getFullName() {
    //+ Ket.out.println("What does value::getFullName() mean?");
    return " " + getValue();
  }

  /**
   * Ensure that each subclass returns a meaningful value.
   */
  public abstract int hashCode();
}
TOP

Related Classes of ket.math.purpose.Value

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.