xml.hyperlinks
Class HTMLHyperlinkSource

java.lang.Object
  extended by xml.hyperlinks.HTMLHyperlinkSource
All Implemented Interfaces:
gatchan.jedit.hyperlinks.HyperlinkSource

public class HTMLHyperlinkSource
extends java.lang.Object
implements gatchan.jedit.hyperlinks.HyperlinkSource

Provides hyperlinks from HTML attributes. Supported hyperlinks are all attributes with type URI in the HTML 4.01 spec. Links to other documents and anchors inside document are supported, but fragment identifiers in other documents are not. the HTML/HEAD/BASE element is used to resolve URIs if present. No reparsing is required, contrary to XMLHyperlinkSource which reparses the start tag.

Version:
$Id: HTMLHyperlinkSource.java 22580 2012-12-17 16:15:42Z kerik-sf $
Author:
Eric Le Lay

Nested Class Summary
static class HTMLHyperlinkSource.IsHyperLink
           
 
Field Summary
 
Fields inherited from interface gatchan.jedit.hyperlinks.HyperlinkSource
DEFAULT_PROPERTY, NONE, PROPERTY, SERVICE
 
Constructor Summary
HTMLHyperlinkSource()
           
 
Method Summary
static gatchan.jedit.hyperlinks.HyperlinkSource create()
           
 gatchan.jedit.hyperlinks.Hyperlink getHyperlink(org.gjt.sp.jedit.Buffer buffer, int offset)
          Returns the hyperlink for the given offset.
 gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForAttribute(org.gjt.sp.jedit.Buffer buffer, int offset, java.lang.String tagLocalName, java.lang.String attLocalName, java.lang.String attValue, XmlParsedData data, HtmlDocument.Tag tag, HtmlDocument.Attribute att, boolean quoted)
          recognize hyperlink attributes by their parent element's name and/or their name.
 gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForAttribute(org.gjt.sp.jedit.Buffer buffer, int offset, XmlParsedData data, HtmlDocument.Tag startTag, HtmlDocument.Attribute att)
          get an hyperlink for an identified HTML attribute
 gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForIDREF(org.gjt.sp.jedit.Buffer buffer, XmlParsedData data, java.lang.String id, HtmlDocument.Attribute att, boolean quoted)
          creates an hyperlink to the location of the element with id (in same or another buffer).
 gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForIDREFS(org.gjt.sp.jedit.Buffer buffer, int offset, XmlParsedData data, java.lang.String attValue, HtmlDocument.Attribute att, boolean quoted)
          creates an hyperlink to the location of the element with id (in same or another buffer)
 sidekick.util.Location getNamedAnchorLocation(XmlParsedData data, java.lang.String name)
           
static HTMLHyperlinkSource.IsHyperLink isHyperlinkAttribute(org.gjt.sp.jedit.Buffer buffer, int offset, java.lang.String tagLocalName, java.lang.String attLocalName, int attStart, java.lang.String attValue)
          recognize hyperlink attributes by their parent element's namespace:localname and/or their namespace:localname
 gatchan.jedit.hyperlinks.Hyperlink newJEditOpenFileAndGotoHyperlink(org.gjt.sp.jedit.Buffer buffer, HtmlDocument.Attribute att, java.lang.String href, int gotoLine, int gotoCol, boolean quoted)
          create an hyperlink for attribute att.
 gatchan.jedit.hyperlinks.Hyperlink newJEditOpenFileHyperlink(org.gjt.sp.jedit.Buffer buffer, HtmlDocument.Attribute att, java.lang.String href, boolean quoted)
          create an hyperlink for attribute att.
 java.lang.String resolve(java.lang.String uri, org.gjt.sp.jedit.Buffer buffer, int offset, XmlParsedData data)
          resolve a potentially relative uri using HTML BASE element, the buffer's URL, xml.Resolver.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTMLHyperlinkSource

public HTMLHyperlinkSource()
Method Detail

getHyperlink

public gatchan.jedit.hyperlinks.Hyperlink getHyperlink(org.gjt.sp.jedit.Buffer buffer,
                                                       int offset)
Returns the hyperlink for the given offset. returns an hyperlink as soon as pointer enters the attribute's value

Specified by:
getHyperlink in interface gatchan.jedit.hyperlinks.HyperlinkSource
Parameters:
buffer - the buffer
offset - the offset
Returns:
the hyperlink (or null if there is no hyperlink)

getHyperlinkForAttribute

public gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForAttribute(org.gjt.sp.jedit.Buffer buffer,
                                                                   int offset,
                                                                   XmlParsedData data,
                                                                   HtmlDocument.Tag startTag,
                                                                   HtmlDocument.Attribute att)
get an hyperlink for an identified HTML attribute

Parameters:
buffer - current buffer
offset - offset where an hyperlink is required in current buffer
data - sidekick tree for current buffer
asset - element containing offset
att - parsed attribute

getHyperlinkForIDREF

public gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForIDREF(org.gjt.sp.jedit.Buffer buffer,
                                                               XmlParsedData data,
                                                               java.lang.String id,
                                                               HtmlDocument.Attribute att,
                                                               boolean quoted)
creates an hyperlink to the location of the element with id (in same or another buffer).

Parameters:
buffer - current buffer
data - sidekick tree
id - id we are looking for
att - parsed attribute (for hyperlink boundaries)
quoted - is the value inside quotes ?

getHyperlinkForIDREFS

public gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForIDREFS(org.gjt.sp.jedit.Buffer buffer,
                                                                int offset,
                                                                XmlParsedData data,
                                                                java.lang.String attValue,
                                                                HtmlDocument.Attribute att,
                                                                boolean quoted)
creates an hyperlink to the location of the element with id (in same or another buffer)

Parameters:
buffer - current buffer
offset - offset of required hyperlink
data - sidekick tree
attValue - ids in the attribute
att - parsed attribute (for hyperlink boundaries)
quoted - is the value inside quotes ?

getHyperlinkForAttribute

public gatchan.jedit.hyperlinks.Hyperlink getHyperlinkForAttribute(org.gjt.sp.jedit.Buffer buffer,
                                                                   int offset,
                                                                   java.lang.String tagLocalName,
                                                                   java.lang.String attLocalName,
                                                                   java.lang.String attValue,
                                                                   XmlParsedData data,
                                                                   HtmlDocument.Tag tag,
                                                                   HtmlDocument.Attribute att,
                                                                   boolean quoted)
recognize hyperlink attributes by their parent element's name and/or their name.


isHyperlinkAttribute

public static HTMLHyperlinkSource.IsHyperLink isHyperlinkAttribute(org.gjt.sp.jedit.Buffer buffer,
                                                                   int offset,
                                                                   java.lang.String tagLocalName,
                                                                   java.lang.String attLocalName,
                                                                   int attStart,
                                                                   java.lang.String attValue)
recognize hyperlink attributes by their parent element's namespace:localname and/or their namespace:localname


resolve

public java.lang.String resolve(java.lang.String uri,
                                org.gjt.sp.jedit.Buffer buffer,
                                int offset,
                                XmlParsedData data)
resolve a potentially relative uri using HTML BASE element, the buffer's URL, xml.Resolver. Has the effect of opening the cached document if it's in cache (eg. docbook XSD if not in catalog). Maybe this is not desirable, because if there is a relative link in this document, it won't work because the document will be .jedit/dtds/cachexxxxx.xml and not the real url.

Parameters:
uri - text of uri to reach
buffer - current buffer
offset - offset in current buffer where an hyperlink is required
data - SideKick parsed data
Returns:
resolved URL

newJEditOpenFileHyperlink

public gatchan.jedit.hyperlinks.Hyperlink newJEditOpenFileHyperlink(org.gjt.sp.jedit.Buffer buffer,
                                                                    HtmlDocument.Attribute att,
                                                                    java.lang.String href,
                                                                    boolean quoted)
create an hyperlink for attribute att. the hyperlink will span whole attribute value

Parameters:
buffer - current buffer
att - parsed attribute
href - uri to open
quoted - is the value inside quotes ?

newJEditOpenFileAndGotoHyperlink

public gatchan.jedit.hyperlinks.Hyperlink newJEditOpenFileAndGotoHyperlink(org.gjt.sp.jedit.Buffer buffer,
                                                                           HtmlDocument.Attribute att,
                                                                           java.lang.String href,
                                                                           int gotoLine,
                                                                           int gotoCol,
                                                                           boolean quoted)
create an hyperlink for attribute att. the hyperlink will span whole attribute value

Parameters:
buffer - current buffer
att - parsed attribute
href - uri to open
gotoLine - target line in buffer
gotoCol - target column in buffer
quoted - is the value inside quotes ?

getNamedAnchorLocation

public sidekick.util.Location getNamedAnchorLocation(XmlParsedData data,
                                                     java.lang.String name)

create

public static gatchan.jedit.hyperlinks.HyperlinkSource create()