FileDocCategorySizeDatePackage
Anchor.javaAPI DocphoneME MR2 API (J2ME)11099Wed May 02 18:00:36 BST 2007com.sun.perseus.model

Anchor

public class Anchor extends Group
Represents an SVG Tiny <a> element. An anchor is a simple Group extension which simply has a href and a target attribute.
version
$Id: Anchor.java,v 1.4 2006/04/21 06:36:17 st125089 Exp $

Fields Summary
protected String
href
The anchor's hyperlink reference
protected String
target
The anchor's target
Constructors Summary
public Anchor(DocumentNode ownerDocument)
Constructor.

param
ownerDocument this element's owner DocumentNode


                
        
        super(ownerDocument);
    
Methods Summary
TraitAnimcreateTraitAnimImpl(java.lang.String traitName)

param
traitName the trait name.

        if (SVGConstants.SVG_TARGET_ATTRIBUTE == traitName) {
            return new StringTraitAnim(this, NULL_NS, traitName);
        } else {
            return super.createTraitAnimImpl(traitName);
        }
    
TraitAnimcreateTraitAnimNSImpl(java.lang.String traitNamespace, java.lang.String traitName)

param
traitName the trait name.
param
traitNamespace the trait's namespace. Should not be null.

        if (traitNamespace == SVGConstants.XLINK_NAMESPACE_URI
            &&
            traitName == SVGConstants.SVG_HREF_ATTRIBUTE) {
            return new StringTraitAnim(this, traitNamespace, traitName);
        }

        return super.createTraitAnimNSImpl(traitNamespace, traitName);
    
public java.lang.StringgetHref()
This returns the absolute URI, even though the href may have been a relative URI

return
this anchor's href, as an absolute URL or null if the href set was null or if the absolute URL could not be computed.

        String uriBase = getURIBase();
        String docBase = ownerDocument.getURIBase();
        if (uriBase != null 
            && uriBase.equals(docBase) 
            && href != null 
            && href.length() > 0 
            && href.charAt(0) == '#") {
            // IMPORTANT: this prevents prepending the document URI
            // to a relative URI if the reference is a local one.
            // See:
            // http://www.ietf.org/rfc/rfc2396.txt
            // Paragraph 4.2 Same-Document References.
            uriBase = null;
        }
        try {
            if (uriBase != null) {
                return URLResolver.resolve(uriBase, href);
            } else {
                return href;
            }
        } catch (IllegalArgumentException iae) {
            return null;
        }
    
public java.lang.StringgetLocalName()

return
the SVGConstants.SVG_A_TAG value

        return SVGConstants.SVG_A_TAG;
    
public java.lang.StringgetTarget()

return
the anchor's target

        return target;
    
public java.lang.StringgetTraitImpl(java.lang.String name)
Anchor handles the target trait.

param
name the requested trait name
return
the requested trait's value.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to a String (SVG Tiny only).

        if (SVGConstants.SVG_TARGET_ATTRIBUTE == name) {
            return getTarget();
        } else {
            return super.getTraitImpl(name);
        }
    
java.lang.StringgetTraitNSImpl(java.lang.String namespaceURI, java.lang.String name)
Anchor handles the xlink:href attribute

param
namespaceURI the URI for the requested trait.
param
name the requested trait's local name (i.e., un-prefixed).
return
the requested trait's value, as a string.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if requested trait's computed value cannot be converted to a String (SVG Tiny only).
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        if (SVGConstants.XLINK_NAMESPACE_URI == namespaceURI
            &&
            SVGConstants.SVG_HREF_ATTRIBUTE == name) {
            String res = getHref();
            if (res == null) {
                res = href;
            }

            return res;
        } else {
            return super.getTraitNSImpl(namespaceURI, name);
        }
    
public ElementNodenewInstance(DocumentNode doc)
Used by DocumentNode to create a new instance from a prototype AnchorNode.

param
doc the DocumentNode for which a new node is should be created.
return
a new Anchor for the requested document.

        return new Anchor(doc);
    
public voidsetHref(java.lang.String href)

param
href the new anchor's href

        if (href == null) {
            throw new IllegalArgumentException();
        }

        if (href.equals(this.href)) {
            return;
        }

        modifyingNode();
        this.href = href;
        modifiedNode();
    
public voidsetTarget(java.lang.String target)

param
target the new anchor target. Should not be null.

        if (target == null) {
            throw new IllegalArgumentException();
        }

        if (target.equals(this.target)) {
            return;
        }

        modifyingNode();
        this.target = target;
        modifiedNode();
    
public voidsetTraitImpl(java.lang.String name, java.lang.String value)
Anchor handles the target trait.

param
name the name of the trait to set.
param
value the value of the trait to set.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a String
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
throws
DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if attempt is made to change readonly trait.

        if (SVGConstants.SVG_TARGET_ATTRIBUTE == name) {
            if (value == null) {
                throw illegalTraitValue(name, value);
            }
            setTarget(value);
        } else {
            super.setTraitImpl(name, value);
        }
    
public voidsetTraitNSImpl(java.lang.String namespaceURI, java.lang.String name, java.lang.String value)
Anchor supports the xlink:href trait.

param
namespaceURI the URI for the trait's namespace.
param
name the trait's local name (i.e., un-prefixed).
param
value the trait's value.
throws
DOMException with error code NOT_SUPPORTED_ERROR if the requested trait is not supported on this element or null.
throws
DOMException with error code TYPE_MISMATCH_ERR if the requested trait's value cannot be specified as a String
throws
DOMException with error code INVALID_ACCESS_ERR if the input value is an invalid value for the given trait or null.
throws
DOMException with error code NO_MODIFICATION_ALLOWED_ERR: if attempt is made to change readonly trait.
throws
SecurityException if the application does not have the necessary privilege rights to access this (SVG) content.

        try {
            if (SVGConstants.XLINK_NAMESPACE_URI == namespaceURI
                &&
                SVGConstants.SVG_HREF_ATTRIBUTE == name) {
                setHref(value);
            } else {
                super.setTraitNSImpl(namespaceURI, name, value);
            }
        } catch (IllegalArgumentException iae) {
            throw new DOMException(DOMException.INVALID_ACCESS_ERR,
                                   iae.getMessage());
        }
    
booleansupportsTrait(java.lang.String traitName)
Anchor handles the target trait.

param
traitName the name of the trait which the element may support.
return
true if this element supports the given trait in one of the trait accessor methods.

        if (SVGConstants.SVG_TARGET_ATTRIBUTE == traitName) {
            return true;
        } else {
            return super.supportsTrait(traitName);
        }
    
booleansupportsTraitNS(java.lang.String namespaceURI, java.lang.String traitName)
Supported traits: xlink:href

param
namespaceURI the trait's namespace.
param
traitName the name of the trait which the element may support.
return
true if this element supports the given trait in one of the trait accessor methods.

        if (SVGConstants.XLINK_NAMESPACE_URI == namespaceURI
            &&
            SVGConstants.SVG_HREF_ATTRIBUTE == traitName) {
            return true;
        } else {
            return super.supportsTraitNS(namespaceURI, traitName);
        }
    
public java.lang.StringtoString()

        return "Anchor[href=(" + href + ") absolute href=(" + getHref() + ")]";