Source

lqpl / GUI / src / dialogs / simulate_results / simulate_results_model.rb

require 'exceptions/quantum_stack_model_invalid_create'


class SimulateResultsModel
  include XmlDecode
  attr_accessor :simulate_results
  attr_accessor :simulate_results_text
  attr_accessor :random_value_text
  attr_accessor :stack_translation

  java_signature "void random_value_text(Object)"
  def random_value_text=(whatever)
  end

  java_signature "void simulate_results_text(Object)"
  def simulate_results_text=(whatever)
  end

  def simulate_results_text
    inner = (@simulate_results || []).collect {|triple| "#{triple[0]}(#{triple[1]}) = #{triple[2]}"}.join("<br />")
    "<html>"+inner+"</html>"
  end

  def random_value_text
    @random_value_text || ""
  end

  java_signature "void simulate_results(Object)"
  def simulate_results=(xml_data)
    raise QuantumStackModelInvalidCreate, "Missing Stack Translation" if @stack_translation.nil?
    sr = SIMULATE_PATTERN.match xml_data

    raise QuantumStackModelInvalidCreate, "Invalid Simulate Results: #{xml_data}" if !sr
    @random_value_text = "Random Value: "+sr[1]
    @simulate_results = SimulateResultsModel.result_values_to_list(sr[2],@stack_translation)
  end

  def self.result_values_to_list(rvals,stack_trans)
    values_to_list rvals, TRIPLE_PATTERN  do |ret, rv|
      ret << [stack_trans.reverse_lookup(rv[1]),rv[2],rv[3]]
    end
  end
  SIMULATE_PATTERN = Regexp.new /<Simulated><double>(.*)<\/double><results>((<triple><string>.*?<\/string><string>.*?<\/string><string>.*?<\/string><\/triple>)*)<\/results><\/Simulated>/

  TRIPLE_PATTERN = Regexp.new /<triple><string>(.*?)<\/string><string>(.*?)<\/string><string>(.*?)<\/string><\/triple>/
end
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.