/** The Link class represents a connection between two locations.
*Note that all links are 'smashed flat' - it's up to the XLinkFilter class to 'resolve' extended link sets into individual links and add them to LinkSet objects.
* @version 0.22 - Last Modified 11/28/98
* Copyright 1998 Simon St.Laurent
* Information at: http://www.simonstl.com/projects/xlinkfilter/
* This code is licensed by Simon St.Laurent under the Mozilla Public License.
* See http://www.mozilla.org/MPL/ for details.
* No warranty provided - use at your own risk */

/* Modification history
*11/20/98 Added equals() method. -SSL
*11/28/98 Added originConnect, destConnect. Modified constructors, equals. -SSL
*/

package com.simonstl.sax.xlink;

public class Link {
	/*URL and Loc split up the full URI*/
	protected String originURL, 
			originConnect,
			originLoc, 
			originContentRole,
			originContentTitle,
			destURL,
			destConnect,
			destLoc,
			destRole,
			destTitle,
			destShow,
			destActuate,
			destBehavior,
			linkType;
	protected boolean inline, direction, linkHTML;

/**first constructor - short version
Note that all links using this version are assumed to:
have connectors of #, be inline, be forward links, not be HTML links, and have no roles, show, actuate, or behavior.
*/
public Link(String originURL, String originLoc, 
		String originContentTitle, String destURL, 
		String destLoc, String destTitle) {
		this.originURL=originURL;
		this.originConnect="#";
		this.originLoc=originLoc;
		this.originContentTitle=originContentTitle;
		this.destURL=destURL;
		this.destConnect="#";
		this.destLoc=destLoc;
		this.destTitle=destTitle;
		this.originContentRole=null;
		this.destRole=null;
		this.destShow=null;
		this.destActuate=null;
		this.destBehavior=null;
		this.linkType=null;
		this.inline=true;
		this.direction=true;
		this.linkHTML=false;
	}

/**second constructor - long version
This version provides access to all fields of the Link class and is the version used by the XLinkFilter class.
*/
	public Link(String originURL, String originConnect, String originLoc, 
		String originContentRole, String originContentTitle, 
		String destURL, String destConnect, String destLoc, 
		String destRole, String destTitle,
		String destShow, String destActuate,
		String destBehavior, String linkType,
		boolean inline, boolean direction, boolean linkHTML) {
		this.originURL=originURL;
		this.originConnect=originConnect;
		this.originLoc=originLoc;
		this.originContentTitle=originContentTitle;
		this.destURL=destURL;
		this.destConnect=destConnect;
		this.destLoc=destLoc;
		this.destTitle=destTitle;
		this.originContentRole=originContentRole;
		this.destRole=destRole;
		this.destShow=destShow;
		this.destActuate=destActuate;
		this.destBehavior=destBehavior;
		this.linkType=linkType;
		this.inline=inline;
		this.direction=direction;
		this.linkHTML=linkHTML;
	}



	public String getOriginURL() {return originURL;}

	public String getOriginConnect() {return originConnect;}

	public String getOriginLoc() {return originLoc;}

	public String getOriginContentTitle() {return originContentTitle;}

	public String getOriginContentRole() {return originContentRole;}

	public String getDestURL() {return destURL;}

	public String getDestConnect() {return destConnect;}
	
	public String getDestLoc() {return destLoc;}

	public String getDestRole() {return destRole;}

	public String getDestTitle() {return destTitle;}

	public String getDestShow() {return destShow;}

	public String getDestActuate() {return destActuate;}

	public String getDestBehavior() {return destBehavior;}

	public String getLinkType() {return linkType;}
	
	public boolean getInline() {return inline;}

	public boolean getDirection() {return direction;}
		
	public boolean getLinkHTML() {return linkHTML;}

	public boolean equals (Link compareLink) {
	    if ((compareLink.getOriginURL().equals(originURL)) &&
		(compareLink.getOriginConnect().equals(originConnect)) &&
		(compareLink.getOriginLoc().equals(originLoc)) &&
		(compareLink.getDestURL().equals(destURL)) &&
		(compareLink.getDestConnect().equals(destConnect)) &&
		(compareLink.getDestLoc().equals(destLoc)) &&
		(compareLink.getOriginContentTitle().equals(originContentTitle)) &&
		(compareLink.getOriginContentRole().equals(originContentRole)) &&
		(compareLink.getDestRole().equals(destRole)) &&
		(compareLink.getDestTitle().equals(destTitle)) &&
		(compareLink.getDestShow().equals(destShow)) &&
		(compareLink.getDestActuate().equals(destActuate)) &&
		(compareLink.getDestBehavior().equals(destBehavior)) &&	
		(compareLink.getLinkType().equals(linkType)))
	    {
		return true;
	    }
	    else {
		return false;
	    }
	}

	public void print() {
System.out.println("Origin URL:"+originURL);
System.out.println("Origin Connect:"+originConnect);
System.out.println("Origin Loc:"+originLoc);
System.out.println("Origin Content-Role:"+originContentRole);
System.out.println("Origin Content-Title:"+originContentTitle);

System.out.println("Dest URL:"+destURL);
System.out.println("Dest Connect:"+destConnect);
System.out.println("Dest Loc:"+destLoc);
System.out.println("Dest Role:"+destRole);
System.out.println("Dest Title:"+destTitle);

System.out.println("Dest Show:"+destShow);
System.out.println("Dest Actuate:"+destActuate);
System.out.println("Dest Behavior:"+destBehavior);
System.out.println("Dest Title:"+destTitle);

System.out.println("Link Type:"+linkType);
if (inline) {System.out.println("Inline link");}
else {System.out.println("Out-of-line link");}

if (direction) {System.out.println("Forward link");}
else {System.out.println("Backward link");}

if (linkHTML) {System.out.println("Link derived from HTML");}
else {System.out.println("Standard XML link");}
System.out.println("------------------------");
	}
}