# RubyRDF / RDF Parser. Based on code contributed from
# RDF4R RDF Parser, Copyright © 2002 Brandt Kurowski (brandt@kurowski.net)
# packaged as part of RubyRDF, see http://www.w3.org/2001/12/rubyrdf/intro.html
# All Rights Reserved. This work is distributed under the W3C® Software 
# License [1] 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. 
# [1] http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231


module RDF4R
	module Consumer
		class Simple 

			attr_reader :models, :model
		
			def initialize
				@models = []
			end

			def start_model
				@anon_count = 0
				@model = []
			end

			def create_resource(uri = nil)
				if uri.nil?
					return anonymous_uri
				else
					return %Q{<#{uri}>}
				end
			end

			def create_literal(text)
				return text
			end

			def create_statement(subject, predicate, object)
				@model.push [subject, predicate, object]
			end

			def anonymous_uri
				@anon_count += 1
				return "_:j#{@anon_count}"
			end

			def nodeid_bnode(bnodeid) 		
				# danbri addition
				# keep state?
				return "_:#{bnodeid}"
			end

			def end_model
				@models.push @model
				@model = nil
			end

		end

	end

end

