01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.wicket.markup;
18:
19: /**
20: * Base class for different kinds of markup elements. Markup elements are held
21: * in a Markup container object.
22: * <p>
23: * Wicket divides markup like (x)html, wml etc. into two types of
24: * MarkupElements:
25: * <ul>
26: * <li>ComponentTag, which represents a "significant" markup tag (meaning that
27: * the tag has some meaning to Wicket)
28: * <li>RawMarkup, which is a section of unparsed markup having no meaning to
29: * Wicket.
30: * </ul>
31: *
32: * @see MarkupResourceData
33: * @see org.apache.wicket.markup.RawMarkup
34: * @see ComponentTag
35: * @author Jonathan Locke
36: */
37: public abstract class MarkupElement {
38: /**
39: * Constructor.
40: */
41: public MarkupElement() {
42: }
43:
44: /**
45: * Gets whether this element closes the given element.
46: *
47: * @param open
48: * The open tag
49: * @return True if this markup element closes the given open tag
50: */
51: public boolean closes(final MarkupElement open) {
52: return false;
53: }
54:
55: /**
56: * This is not an implementation of equals because we don't care about
57: * hashCodes for MarkupElements yet. Also, this method only compares the
58: * namespace, name and attributes of the given MarkupElements.
59: *
60: * @param element
61: * The markup element to compare with
62: * @return True if the other element equals this one
63: */
64: public abstract boolean equalTo(MarkupElement element);
65:
66: /**
67: * @return Gets the charseqence representation of this element
68: */
69: public abstract CharSequence toCharSequence();
70:
71: /**
72: * Gets a string represenetation.
73: *
74: * @return A string representation suitable for displaying to the user when
75: * something goes wrong.
76: */
77: public abstract String toUserDebugString();
78: }
|