01: /*
02: * Copyright 2007 Outerthought bvba and Schaubroeck nv
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: */
16: package org.outerj.daisy.diff.html.dom;
17:
18: import org.xml.sax.Attributes;
19: import org.xml.sax.helpers.AttributesImpl;
20:
21: /**
22: * Represents an image in HTML. Even though images do not contain any text they
23: * are single visible objects on the page. They are logically a {@link TextNode}.
24: */
25: public class ImageNode extends TextNode {
26:
27: private AttributesImpl attributes;
28:
29: public ImageNode(TagNode parent, Attributes attrs) {
30: super (parent, "<img>" + attrs.getValue("src").toLowerCase()
31: + "</img>");
32: attributes = new AttributesImpl(attrs);
33: }
34:
35: @Override
36: public boolean isSameText(Object other) {
37: if (other == null)
38: return false;
39:
40: ImageNode otherImageNode;
41: try {
42: otherImageNode = (ImageNode) other;
43: } catch (ClassCastException e) {
44: return false;
45: }
46: return getText().equalsIgnoreCase(otherImageNode.getText());
47: }
48:
49: public AttributesImpl getAttributes() {
50: return attributes;
51: }
52:
53: }
|