/*
	In XTM, topicRef, resourceRef, and subjectIndicatorRef
	have the same structure.  This module defines objects
	corresponding to each of these.
*/

function abstractRef(uri){
	this.id=''
	this.uri=''
	this.localId=''

	// ===== Interface ======
	this.isLocal=_is_local
	this.setRef=_set_ref
	this.getLocal=_get_local
	this.getUri=_get_uri

	this.setRef(uri)

	// Test for scheme - presence of a colon indicates non-local reference
	// Even a Windows drive letter (i.e., d:) rules out an internal id.
	function _is_local(uri){
		if (!uri || !uri.split){return true}
		return (uri.split(':').length==1)
	}

	// Load local id or uri as applicable - blank out the other one
	function _set_ref(uri){
		if (!uri){return}
		if (this.isLocal(uri)){
			this.localId=uri
			this.uri=''
		}
		else {
			this.uri=uri
			this.localId=''
		}
	}

	function _get_local(){
		return this.localId
	}
	
	function _get_uri(){
		return this.uri
	}
	
	
}

function resourceRef(uri){
	this.parent=abstractRef
	this.parent(uri)
}

resourceRef.prototype.toString=resourceRefToString
function resourceRefToString(){
	return "[resourceRef]"
}

function subjectIndicatorRef(uri){
	this.parent=abstractRef
	this.parent(uri)
}

subjectIndicatorRef.prototype.toString=subjectIndicatorRefToString
function subjectIndicatorRefToString(){
	return "[resourceRef]"
}


function topicRef(uri){
	this.parent=abstractRef
	this.parent(uri)
}

topicRef.prototype.toString=topicRefToString
function topicRefToString(){
	return "[resourceRef]"
}

