View Javadoc
1   /*
2    * Copyright (c) 2002-2017 Gargoyle Software Inc.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10   * distributed under the License is distributed on an "AS IS" BASIS,
11   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12   * See the License for the specific language governing permissions and
13   * limitations under the License.
14   */
15  package com.gargoylesoftware.htmlunit.javascript.host.html;
16  
17  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL;
18  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL;
19  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_NONE_FOR_NONE_HTTP_URL;
20  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL;
21  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL;
22  import static com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PROTOCOL_COLON_UPPER_CASE_DRIVE_LETTERS;
23  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.CHROME;
24  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.EDGE;
25  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF;
26  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.FF52;
27  import static com.gargoylesoftware.htmlunit.javascript.configuration.SupportedBrowser.IE;
28  
29  import java.net.MalformedURLException;
30  import java.net.URL;
31  import java.util.Arrays;
32  import java.util.List;
33  import java.util.Locale;
34  
35  import org.apache.commons.lang3.StringUtils;
36  
37  import com.gargoylesoftware.htmlunit.SgmlPage;
38  import com.gargoylesoftware.htmlunit.html.DomElement;
39  import com.gargoylesoftware.htmlunit.html.DomNode;
40  import com.gargoylesoftware.htmlunit.html.HtmlAnchor;
41  import com.gargoylesoftware.htmlunit.html.HtmlElement;
42  import com.gargoylesoftware.htmlunit.html.HtmlPage;
43  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxClass;
44  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxConstructor;
45  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter;
46  import com.gargoylesoftware.htmlunit.javascript.configuration.JsxSetter;
47  import com.gargoylesoftware.htmlunit.javascript.host.dom.DOMTokenList;
48  import com.gargoylesoftware.htmlunit.util.UrlUtils;
49  
50  import net.sourceforge.htmlunit.corejs.javascript.Context;
51  
52  /**
53   * The JavaScript object that represents an anchor.
54   *
55   * @author <a href="mailto:mbowler@GargoyleSoftware.com">Mike Bowler</a>
56   * @author <a href="mailto:gousseff@netscape.net">Alexei Goussev</a>
57   * @author David D. Kilzer
58   * @author Marc Guillemot
59   * @author Chris Erskine
60   * @author Ahmed Ashour
61   * @author Sudhan Moghe
62   * @author Daniel Gredler
63   * @author Ronald Brill
64   */
65  @JsxClass(domClass = HtmlAnchor.class)
66  public class HTMLAnchorElement extends HTMLElement {
67      private static final List<String> REFERRER_POLICIES = Arrays.asList("no-referrer", "origin", "unsafe-url");
68  
69      /**
70       * The constructor.
71       */
72      @JsxConstructor({CHROME, FF, EDGE})
73      public HTMLAnchorElement() {
74      }
75  
76      /**
77       * Sets the {@code href} property.
78       * @param href the {@code href} property value
79       */
80      @JsxSetter
81      public void setHref(final String href) {
82          getDomNodeOrDie().setAttribute("href", href);
83      }
84  
85      /**
86       * Returns the value of this link's {@code href} property.
87       * @return the value of this link's {@code href} property
88       */
89      @JsxGetter
90      public String getHref() {
91          final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
92          final String hrefAttr = anchor.getHrefAttribute();
93  
94          if (hrefAttr == DomElement.ATTRIBUTE_NOT_DEFINED) {
95              return "";
96          }
97  
98          try {
99              return getUrl().toString();
100         }
101         catch (final MalformedURLException e) {
102             return hrefAttr;
103         }
104     }
105 
106     /**
107      * Sets the focus to this element.
108      */
109     @Override
110     public void focus() {
111         final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
112         final String hrefAttr = anchor.getHrefAttribute();
113 
114         if (hrefAttr != DomElement.ATTRIBUTE_NOT_DEFINED) {
115             anchor.focus();
116         }
117     }
118 
119     /**
120      * Sets the name property.
121      * @param name name attribute value
122      */
123     @JsxSetter
124     public void setName(final String name) {
125         getDomNodeOrDie().setAttribute("name", name);
126     }
127 
128     /**
129      * Returns the value of the name property of this link.
130      * @return the name property
131      */
132     @JsxGetter
133     public String getName() {
134         return getDomNodeOrDie().getAttribute("name");
135     }
136 
137     /**
138      * Sets the target property of this link.
139      * @param target target attribute value
140      */
141     @JsxSetter
142     public void setTarget(final String target) {
143         getDomNodeOrDie().setAttribute("target", target);
144     }
145 
146     /**
147      * Returns the value of the target property of this link.
148      * @return the href property
149      */
150     @JsxGetter
151     public String getTarget() {
152         return getDomNodeOrDie().getAttribute("target");
153     }
154 
155     /**
156      * Returns this link's current URL.
157      * @return this link's current URL
158      * @throws MalformedURLException if an error occurs
159      */
160     private URL getUrl() throws MalformedURLException {
161         final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
162         return ((HtmlPage) anchor.getPage()).getFullyQualifiedUrl(anchor.getHrefAttribute());
163     }
164 
165     /**
166      * Sets the {@code href} attribute of this link to the specified URL.
167      * @param url the new value of the {@code href} attribute
168      */
169     private void setUrl(final URL url) {
170         getDomNodeOrDie().setAttribute("href", url.toString());
171     }
172 
173     /**
174      * Sets the rel property.
175      * @param rel rel attribute value
176      */
177     @JsxSetter
178     public void setRel(final String rel) {
179         getDomNodeOrDie().setAttribute("rel", rel);
180     }
181 
182     /**
183      * Returns the value of the rel property.
184      * @return the rel property
185      */
186     @JsxGetter
187     public String getRel() {
188         return ((HtmlAnchor) getDomNodeOrDie()).getRelAttribute();
189     }
190 
191     /**
192      * Returns the value of the rev property.
193      * @return the rev property
194      */
195     @JsxGetter
196     public String getRev() {
197         return ((HtmlAnchor) getDomNodeOrDie()).getRevAttribute();
198     }
199 
200     /**
201      * Sets the rev property.
202      * @param rel rev attribute value
203      */
204     @JsxSetter
205     public void setRev(final String rel) {
206         getDomNodeOrDie().setAttribute("rev", rel);
207     }
208 
209     /**
210      * Returns the value of the rev property.
211      * @return the referrerPolicy property
212      */
213     @JsxGetter({CHROME, FF52})
214     public String getReferrerPolicy() {
215         String attrib = ((HtmlAnchor) getDomNodeOrDie()).getAttribute("referrerPolicy");
216         if (StringUtils.isEmpty(attrib)) {
217             return "";
218         }
219         attrib = attrib.toLowerCase(Locale.ROOT);
220         if (REFERRER_POLICIES.contains(attrib)) {
221             return attrib;
222         }
223         return "";
224     }
225 
226     /**
227      * Sets the rev property.
228      * @param referrerPolicy referrerPolicy attribute value
229      */
230     @JsxSetter({CHROME, FF52})
231     public void setReferrerPolicy(final String referrerPolicy) {
232         getDomNodeOrDie().setAttribute("referrerPolicy", referrerPolicy);
233     }
234 
235     /**
236      * Returns the search portion of the link's URL (the portion starting with
237      * '?' and up to but not including any '#').
238      * @return the search portion of the link's URL
239      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534620.aspx">MSDN Documentation</a>
240      */
241     @JsxGetter
242     public String getSearch() {
243         try {
244             final String query = getUrl().getQuery();
245             if (query == null) {
246                 return "";
247             }
248             return "?" + query;
249         }
250         catch (final MalformedURLException e) {
251             return "";
252         }
253     }
254 
255     /**
256      * Sets the search portion of the link's URL (the portion starting with '?'
257      * and up to but not including any '#')..
258      * @param search the new search portion of the link's URL
259      * @throws Exception if an error occurs
260      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534620.aspx">MSDN Documentation</a>
261      */
262     @JsxSetter
263     public void setSearch(final String search) throws Exception {
264         final String query;
265         if (search == null || "?".equals(search) || "".equals(search)) {
266             query = null;
267         }
268         else if (search.charAt(0) == '?') {
269             query = search.substring(1);
270         }
271         else {
272             query = search;
273         }
274 
275         setUrl(UrlUtils.getUrlWithNewQuery(getUrl(), query));
276     }
277 
278     /**
279      * Returns the hash portion of the link's URL (the portion following the '#', including the '#').
280      * @return the hash portion of the link's URL
281      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a>
282      */
283     @JsxGetter
284     public String getHash() {
285         try {
286             final String hash = getUrl().getRef();
287             if (hash == null) {
288                 return "";
289             }
290             return "#" + hash;
291         }
292         catch (final MalformedURLException e) {
293             return "";
294         }
295     }
296 
297     /**
298      * Sets the hash portion of the link's URL (the portion following the '#').
299      * @param hash the new hash portion of the link's URL
300      * @throws Exception if an error occurs
301      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533775.aspx">MSDN Documentation</a>
302      */
303     @JsxSetter
304     public void setHash(final String hash) throws Exception {
305         setUrl(UrlUtils.getUrlWithNewRef(getUrl(), hash));
306     }
307 
308     /**
309      * Returns the host portion of the link's URL (the '[hostname]:[port]' portion).
310      * @return the host portion of the link's URL
311      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533784.aspx">MSDN Documentation</a>
312      */
313     @JsxGetter
314     public String getHost() {
315         try {
316             final URL url = getUrl();
317             final int port = url.getPort();
318             final String host = url.getHost();
319 
320             if (port == -1) {
321                 return host;
322             }
323             return host + ":" + port;
324         }
325         catch (final MalformedURLException e) {
326             return "";
327         }
328     }
329 
330     /**
331      * Sets the host portion of the link's URL (the '[hostname]:[port]' portion).
332      * @param host the new host portion of the link's URL
333      * @throws Exception if an error occurs
334      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533784.aspx">MSDN Documentation</a>
335      */
336     @JsxSetter
337     public void setHost(final String host) throws Exception {
338         final String hostname;
339         final int port;
340         final int index = host.indexOf(':');
341         if (index != -1) {
342             hostname = host.substring(0, index);
343             port = Integer.parseInt(host.substring(index + 1));
344         }
345         else {
346             hostname = host;
347             port = -1;
348         }
349         final URL url = UrlUtils.getUrlWithNewHostAndPort(getUrl(), hostname, port);
350         setUrl(url);
351     }
352 
353     /**
354      * Returns the hostname portion of the link's URL.
355      * @return the hostname portion of the link's URL
356      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533785.aspx">MSDN Documentation</a>
357      */
358     @JsxGetter
359     public String getHostname() {
360         try {
361             return getUrl().getHost();
362         }
363         catch (final MalformedURLException e) {
364             return "";
365         }
366     }
367 
368     /**
369      * Sets the hostname portion of the link's URL.
370      * @param hostname the new hostname portion of the link's URL
371      * @throws Exception if an error occurs
372      * @see <a href="http://msdn.microsoft.com/en-us/library/ms533785.aspx">MSDN Documentation</a>
373      */
374     @JsxSetter
375     public void setHostname(final String hostname) throws Exception {
376         setUrl(UrlUtils.getUrlWithNewHost(getUrl(), hostname));
377     }
378 
379     /**
380      * Returns the pathname portion of the link's URL.
381      * @return the pathname portion of the link's URL
382      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534332.aspx">MSDN Documentation</a>
383      */
384     @JsxGetter
385     public String getPathname() {
386         try {
387             final URL url = getUrl();
388             if (!url.getProtocol().startsWith("http")
389                     && getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_NONE_FOR_NONE_HTTP_URL)) {
390                 return "";
391             }
392             if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) {
393                 final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
394                 String href = anchor.getHrefAttribute();
395                 if (href.length() > 1 && Character.isLetter(href.charAt(0)) && ':' == href.charAt(1)) {
396                     if (getBrowserVersion().hasFeature(JS_ANCHOR_PROTOCOL_COLON_UPPER_CASE_DRIVE_LETTERS)) {
397                         href = StringUtils.capitalize(href);
398                     }
399                     if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL)) {
400                         href = "/" + href;
401                     }
402                     return href;
403                 }
404             }
405             return url.getPath();
406         }
407         catch (final MalformedURLException e) {
408             final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
409             if (anchor.getHrefAttribute().startsWith("http")
410                     && getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL)) {
411                 return "";
412             }
413             return "/";
414         }
415     }
416 
417     /**
418      * Sets the pathname portion of the link's URL.
419      * @param pathname the new pathname portion of the link's URL
420      * @throws Exception if an error occurs
421      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534332.aspx">MSDN Documentation</a>
422      */
423     @JsxSetter
424     public void setPathname(final String pathname) throws Exception {
425         setUrl(UrlUtils.getUrlWithNewPath(getUrl(), pathname));
426     }
427 
428     /**
429      * Returns the port portion of the link's URL.
430      * @return the port portion of the link's URL
431      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534342.aspx">MSDN Documentation</a>
432      */
433     @JsxGetter
434     public String getPort() {
435         try {
436             final int port = getUrl().getPort();
437             if (port == -1) {
438                 return "";
439             }
440             return Integer.toString(port);
441         }
442         catch (final MalformedURLException e) {
443             return "";
444         }
445     }
446 
447     /**
448      * Sets the port portion of the link's URL.
449      * @param port the new port portion of the link's URL
450      * @throws Exception if an error occurs
451      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534342.aspx">MSDN Documentation</a>
452      */
453     @JsxSetter
454     public void setPort(final String port) throws Exception {
455         setUrl(UrlUtils.getUrlWithNewPort(getUrl(), Integer.parseInt(port)));
456     }
457 
458     /**
459      * Returns the protocol portion of the link's URL, including the trailing ':'.
460      * @return the protocol portion of the link's URL, including the trailing ':'
461      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534353.aspx">MSDN Documentation</a>
462      */
463     @JsxGetter
464     public String getProtocol() {
465         try {
466             if (getBrowserVersion().hasFeature(JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)) {
467                 final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
468                 final String href = anchor.getHrefAttribute().toLowerCase(Locale.ROOT);
469                 if (href.length() > 1 && Character.isLetter(href.charAt(0)) && ':' == href.charAt(1)) {
470                     return "file:";
471                 }
472             }
473 
474             return getUrl().getProtocol() + ":";
475         }
476         catch (final MalformedURLException e) {
477             final HtmlAnchor anchor = (HtmlAnchor) getDomNodeOrDie();
478             if (anchor.getHrefAttribute().startsWith("http")
479                     && getBrowserVersion().hasFeature(JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL)) {
480                 return ":";
481             }
482             return StringUtils.substringBefore(anchor.getHrefAttribute(), "/");
483         }
484     }
485 
486     /**
487      * Sets the protocol portion of the link's URL.
488      * @param protocol the new protocol portion of the link's URL
489      * @throws Exception if an error occurs
490      * @see <a href="http://msdn.microsoft.com/en-us/library/ms534353.aspx">MSDN Documentation</a>
491      */
492     @JsxSetter
493     public void setProtocol(final String protocol) throws Exception {
494         final String bareProtocol = StringUtils.substringBefore(protocol, ":");
495         setUrl(UrlUtils.getUrlWithNewProtocol(getUrl(), bareProtocol));
496     }
497 
498     /**
499      * Calls for instance for implicit conversion to string.
500      * @see com.gargoylesoftware.htmlunit.javascript.SimpleScriptable#getDefaultValue(java.lang.Class)
501      * @param hint the type hint
502      * @return the default value
503      */
504     @Override
505     public Object getDefaultValue(final Class<?> hint) {
506         final HtmlElement element = getDomNodeOrNull();
507         if (element == null) {
508             return super.getDefaultValue(null);
509         }
510         return getDefaultValue(element);
511     }
512 
513     static String getDefaultValue(final HtmlElement element) {
514         String href = element.getAttribute("href");
515 
516         if (DomElement.ATTRIBUTE_NOT_DEFINED == href) {
517             return ""; // for example for named anchors
518         }
519 
520         href = href.trim();
521 
522         final SgmlPage page = element.getPage();
523         if (page == null || !page.isHtmlPage()) {
524             return href;
525         }
526 
527         try {
528             return HtmlAnchor.getTargetUrl(href, (HtmlPage) page).toExternalForm();
529         }
530         catch (final MalformedURLException e) {
531             return href;
532         }
533     }
534 
535     /**
536      * Returns the {@code text} attribute.
537      * @return the {@code text} attribute
538      */
539     @JsxGetter
540     public String getText() {
541         final DomNode htmlElement = getDomNodeOrDie();
542         return htmlElement.asText();
543     }
544 
545     /**
546      * Sets the {@code text} attribute.
547      * @param text the {@code text} attribute
548      */
549     @JsxSetter
550     public void setText(final String text) {
551         final DomNode htmlElement = getDomNodeOrDie();
552         htmlElement.setTextContent(text);
553     }
554 
555     /**
556      * Returns the {@code charset} attribute.
557      * @return the {@code charset} attribute
558      */
559     @JsxGetter
560     public String getCharset() {
561         return getDomNodeOrDie().getAttribute("charset");
562     }
563 
564     /**
565      * Sets the {@code charset} attribute.
566      * @param charset the {@code charset} attribute
567      */
568     @JsxSetter
569     public void setCharset(final String charset) {
570         getDomNodeOrDie().setAttribute("charset", charset);
571     }
572 
573     /**
574      * Returns the {@code coords} attribute.
575      * @return the {@code coords} attribute
576      */
577     @JsxGetter
578     public String getCoords() {
579         return getDomNodeOrDie().getAttribute("coords");
580     }
581 
582     /**
583      * Sets the {@code coords} attribute.
584      * @param coords {@code coords} attribute
585      */
586     @JsxSetter
587     public void setCoords(final String coords) {
588         getDomNodeOrDie().setAttribute("coords", coords);
589     }
590 
591     /**
592      * Returns the {@code hreflang} attribute.
593      * @return the {@code hreflang} attribute
594      */
595     @JsxGetter
596     public String getHreflang() {
597         return getDomNodeOrDie().getAttribute("hreflang");
598     }
599 
600     /**
601      * Sets the {@code hreflang} attribute.
602      * @param hreflang {@code hreflang} attribute
603      */
604     @JsxSetter
605     public void setHreflang(final String hreflang) {
606         getDomNodeOrDie().setAttribute("hreflang", hreflang);
607     }
608 
609     /**
610      * Returns the {@code origin} attribute.
611      * @return the {@code origin} attribute
612      */
613     @JsxGetter({CHROME, FF})
614     public String getOrigin() {
615         if (!getDomNodeOrDie().hasAttribute("href")) {
616             return "";
617         }
618 
619         try {
620             return getUrl().getProtocol() + "://" + getHost();
621         }
622         catch (final Exception e) {
623             return "";
624         }
625     }
626 
627     /**
628      * Sets the {@code origin} attribute.
629      * @param origin {@code origin} attribute
630      */
631     @JsxSetter({CHROME, FF})
632     public void setOrigin(final String origin) {
633         // ignore
634     }
635 
636     /**
637      * Returns the {@code username} attribute.
638      * @return the {@code username} attribute
639      */
640     @JsxGetter({CHROME, FF})
641     public String getUsername() {
642         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
643     }
644 
645     /**
646      * Sets the {@code username} attribute.
647      * @param username {@code username} attribute
648      */
649     @JsxSetter({CHROME, FF})
650     public void setUsername(final String username) {
651         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
652     }
653 
654     /**
655      * Returns the {@code password} attribute.
656      * @return the {@code password} attribute
657      */
658     @JsxGetter({CHROME, FF})
659     public String getPassword() {
660         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
661     }
662 
663     /**
664      * Sets the {@code password} attribute.
665      * @param password {@code password} attribute
666      */
667     @JsxSetter({CHROME, FF})
668     public void setPassword(final String password) {
669         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
670     }
671 
672     /**
673      * Returns the {@code download} attribute.
674      * @return the {@code download} attribute
675      */
676     @JsxGetter({CHROME, FF})
677     public String getDownload() {
678         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
679     }
680 
681     /**
682      * Sets the {@code download} attribute.
683      * @param download {@code download} attribute
684      */
685     @JsxSetter({CHROME, FF})
686     public void setDownload(final String download) {
687         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
688     }
689 
690     /**
691      * Returns the {@code ping} attribute.
692      * @return the {@code ping} attribute
693      */
694     @JsxGetter({CHROME, FF})
695     public String getPing() {
696         return ((HtmlAnchor) getDomNodeOrDie()).getPingAttribute();
697     }
698 
699     /**
700      * Sets the {@code ping} attribute.
701      * @param ping {@code ping} attribute
702      */
703     @JsxSetter({CHROME, FF})
704     public void setPing(final String ping) {
705         getDomNodeOrDie().setAttribute("ping", ping);
706     }
707 
708     /**
709      * Returns the {@code shape} attribute.
710      * @return the {@code shape} attribute
711      */
712     @JsxGetter
713     public String getShape() {
714         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
715     }
716 
717     /**
718      * Sets the {@code shape} attribute.
719      * @param shape {@code shape} attribute
720      */
721     @JsxSetter
722     public void setShape(final String shape) {
723         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
724     }
725 
726     /**
727      * Returns the {@code type} attribute.
728      * @return the {@code type} attribute
729      */
730     @JsxGetter
731     public String getType() {
732         return getDomNodeOrDie().getAttribute("type");
733     }
734 
735     /**
736      * Sets the {@code type} attribute.
737      * @param type {@code type} attribute
738      */
739     @JsxSetter
740     public void setType(final String type) {
741         getDomNodeOrDie().setAttribute("type", type);
742     }
743 
744     /**
745      * Returns the {@code relList} attribute.
746      * @return the {@code relList} attribute
747      */
748     @JsxGetter(FF)
749     public DOMTokenList getRelList() {
750         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
751     }
752 
753     /**
754      * Returns the {@code protocolLong} attribute.
755      * @return the {@code protocolLong} attribute
756      */
757     @JsxGetter(IE)
758     public String getProtocolLong() {
759         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
760     }
761 
762     /**
763      * Returns the {@code Methods} attribute.
764      * @return the {@code Methods} attribute
765      */
766     @JsxGetter(propertyName = "Methods", value = IE)
767     public String getMethods() {
768         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
769     }
770 
771     /**
772      * Sets the {@code Methods} attribute.
773      * @param methods {@code Methods} attribute
774      */
775     @JsxSetter(propertyName = "Methods", value = IE)
776     public void setMethods(final String methods) {
777         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
778     }
779 
780     /**
781      * Returns the {@code mimeType} attribute.
782      * @return the {@code mimeType} attribute
783      */
784     @JsxGetter(IE)
785     public String getMimeType() {
786         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
787     }
788 
789     /**
790      * Sets the {@code mimeType} attribute.
791      * @param mimeType {@code mimeType} attribute
792      */
793     @JsxSetter(IE)
794     public void setMimeType(final String mimeType) {
795         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
796     }
797 
798     /**
799      * Returns the {@code nameProp} attribute.
800      * @return the {@code nameProp} attribute
801      */
802     @JsxGetter(IE)
803     public String getNameProp() {
804         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
805     }
806 
807     /**
808      * Returns the {@code urn} attribute.
809      * @return the {@code urn} attribute
810      */
811     @JsxGetter(IE)
812     public String getUrn() {
813         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
814     }
815 
816     /**
817      * Sets the {@code urn} attribute.
818      * @param urn {@code urn} attribute
819      */
820     @JsxSetter(IE)
821     public void setUrn(final String urn) {
822         throw Context.throwAsScriptRuntimeEx(new UnsupportedOperationException());
823     }
824 }