@@ -99,6 +99,8 @@ public abstract class DomNode implements Cloneable, Serializable, Node {
99
99
/** The name of the "element" property. Used when watching property change events. */
100
100
public static final String PROPERTY_ELEMENT = "element" ;
101
101
102
+ private static final NamedNodeMap EMPTY_NAMED_NODE_MAP = new ReadOnlyEmptyNamedNodeMapImpl ();
103
+
102
104
/** The owning page of this node. */
103
105
private SgmlPage page_ ;
104
106
@@ -662,7 +664,7 @@ public boolean hasAttributes() {
662
664
*/
663
665
@ Override
664
666
public NamedNodeMap getAttributes () {
665
- return NamedAttrNodeMapImpl . EMPTY_MAP ;
667
+ return EMPTY_NAMED_NODE_MAP ;
666
668
}
667
669
668
670
/**
@@ -1938,4 +1940,77 @@ public DomElement closest(final String selectorString) {
1938
1940
throw new CSSException ("Error parsing CSS selectors from '" + selectorString + "': " + e .getMessage (), e );
1939
1941
}
1940
1942
}
1943
+
1944
+ /**
1945
+ * An unmodifiable empty {@link NamedNodeMap} implementation.
1946
+ */
1947
+ private static final class ReadOnlyEmptyNamedNodeMapImpl implements NamedNodeMap , Serializable {
1948
+ private ReadOnlyEmptyNamedNodeMapImpl () {
1949
+ super ();
1950
+ }
1951
+
1952
+ /**
1953
+ * {@inheritDoc}
1954
+ */
1955
+ @ Override
1956
+ public int getLength () {
1957
+ return 0 ;
1958
+ }
1959
+
1960
+ /**
1961
+ * {@inheritDoc}
1962
+ */
1963
+ @ Override
1964
+ public DomAttr getNamedItem (final String name ) {
1965
+ return null ;
1966
+ }
1967
+
1968
+ /**
1969
+ * {@inheritDoc}
1970
+ */
1971
+ @ Override
1972
+ public Node getNamedItemNS (final String namespaceURI , final String localName ) {
1973
+ return null ;
1974
+ }
1975
+
1976
+ /**
1977
+ * {@inheritDoc}
1978
+ */
1979
+ @ Override
1980
+ public Node item (final int index ) {
1981
+ return null ;
1982
+ }
1983
+
1984
+ /**
1985
+ * {@inheritDoc}
1986
+ */
1987
+ @ Override
1988
+ public Node removeNamedItem (final String name ) throws DOMException {
1989
+ return null ;
1990
+ }
1991
+
1992
+ /**
1993
+ * {@inheritDoc}
1994
+ */
1995
+ @ Override
1996
+ public Node removeNamedItemNS (final String namespaceURI , final String localName ) {
1997
+ return null ;
1998
+ }
1999
+
2000
+ /**
2001
+ * {@inheritDoc}
2002
+ */
2003
+ @ Override
2004
+ public DomAttr setNamedItem (final Node node ) {
2005
+ throw new UnsupportedOperationException ("ReadOnlyEmptyNamedAttrNodeMapImpl.setNamedItem" );
2006
+ }
2007
+
2008
+ /**
2009
+ * {@inheritDoc}
2010
+ */
2011
+ @ Override
2012
+ public Node setNamedItemNS (final Node node ) throws DOMException {
2013
+ throw new UnsupportedOperationException ("ReadOnlyEmptyNamedAttrNodeMapImpl.setNamedItemNS" );
2014
+ }
2015
+ }
1941
2016
}
0 commit comments