FileDocCategorySizeDatePackage
Set.javaAPI DocphoneME MR2 API (J2ME)8634Wed May 02 18:00:34 BST 2007com.sun.perseus.model

Set

public final class Set extends Animation
Set represents an SVG Tiny <set> element.
version
$Id: Set.java,v 1.5 2006/06/29 10:47:34 ln156897 Exp $

Fields Summary
static final String[]
REQUIRED_TRAITS
Required Set traits
String[]
to
The target Set value.
RefValues
refValues
The RefValues corresponding to this <set> element. A <set> element has a single segment with the same begin and end value.
String
traitQName
The trait's qualified name.
Constructors Summary
public Set(DocumentNode ownerDocument)
Builds a new Set element that belongs to the given document. This Set will belong to the DocumentNode's time container.

param
ownerDocument the document this node belongs to.
throws
IllegalArgumentException if the input ownerDocument is null


                                              
        
        super(ownerDocument, SVGConstants.SVG_SET_TAG);
    
Methods Summary
java.lang.Object[]f(long t)
This is the Set element's animation function. It is very simple as it simply returns the 'to' value, no matter what time t is.

param
t the animation's simple time.

        return refValues.getSegment(0).getStart();
    
public java.lang.String[]getRequiredTraits()

return
an array of traits that are required by this element.

        return REQUIRED_TRAITS;
    
public java.lang.StringgetTraitImpl(java.lang.String name)
Set supports the to and attributeName traits. Returns the trait value as String. In SVG Tiny only certain traits can be obtained as a String value. Syntax of the returned String matches the syntax of the corresponding attribute. This element is exactly equivalent to {@link org.w3c.dom.svg.SVGElement#getTraitNS getTraitNS} with namespaceURI set to null. The method is meant to be overridden by derived classes. The implementation pattern is that derived classes will override the method and call their super class' implementation. If the ElementNode implementation is called, it means that the trait is either not supported or that it cannot be seen as a String.

param
name the requested trait name.
return
the trait 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_TO_ATTRIBUTE == name) {
            return to[0];
        } else if (SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE == name) {
            return traitQName;
        } else {
            return super.getTraitImpl(name);
        }
    
public ElementNodenewInstance(DocumentNode doc)
Used by DocumentNode to create a new instance from a prototype TimedElementNode.

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

        return new Set(doc);
    
public voidsetTraitImpl(java.lang.String name, java.lang.String value)
Set supports the attributeName and to traits.

param
name the trait's name.
param
value the trait's value.
throws
DOMException with error code NOT_SUPPORTED_ERR 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_TO_ATTRIBUTE == name) {
            checkWriteLoading(name);
            if (value == null) {
                throw illegalTraitValue(name, value);
            }
            to[0] = value;
        } else if (SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE == name) {
            checkWriteLoading(name);

            if (value == null) {
                throw illegalTraitValue(name, value);
            }

            // Now, if this is a QName, we need to use the namespace prefix map.
            int i = value.indexOf(':");
            if (i == -1) {
                this.traitName = value.intern();
                this.traitQName = value.intern();
            } else {
                if (i == value.length() - 1) {
                    // ':' is the last character, this is invalid.
                    throw illegalTraitValue(name, value);
                }

                String prefix = value.substring(0, i);
                String tName = value.substring(i+1);

                String ns = ownerDocument.toNamespace(prefix, this);
                if (ns == null) {
                    throw illegalTraitValue(name, value);
                }

                traitName = tName.intern();
                traitNamespace = ns.intern();
                traitQName = value;
            }
        } else {
            super.setTraitImpl(name, value);
        }
    
booleansupportsTrait(java.lang.String traitName)
Supported traits: to, attributeName

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_TO_ATTRIBUTE == traitName
            ||
            SVGConstants.SVG_ATTRIBUTE_NAME_ATTRIBUTE == traitName) {
            return true;
        } else {
            return super.supportsTrait(traitName);
        }
    
voidvalidate()
Validating a Set consists in: a) Setting its target element. If there was no idRef, then targetElement is still null and will be positioned to the parent node. b) Validating the to value with the targetElement, using the target trait name, namespace and value.

throws
DOMException if there is a validation error, for example if the to value is incompatible with the target trait or if the target trait is not animatable.

        // a) Set the target element.
        if (targetElement == null) {
            targetElement = (ElementNode) parent;
        }

        // b) Validate the to value with the target element.
        traitAnim = targetElement.getSafeTraitAnimNS(traitNamespace, traitName);

        if (to[0] != null) {
            refValues = traitAnim.toRefValues(this,
                                              to,
                                              null,
                                              SVGConstants.SVG_TO_ATTRIBUTE);
        } else {
            hasNoEffect = true;
        }