001/* 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.apache.wicket.markup; 018 019/** 020 * Base class for different kinds of markup elements. Markup elements are held in a Markup container 021 * object. 022 * <p> 023 * Wicket divides markup like (x)html, wml etc. into two types of MarkupElements: 024 * <ul> 025 * <li>ComponentTag, which represents a "significant" markup tag (meaning that the tag has some 026 * meaning to Wicket) 027 * <li>RawMarkup, which is a section of unparsed markup having no meaning to Wicket. 028 * </ul> 029 * 030 * @see org.apache.wicket.markup.RawMarkup 031 * @see ComponentTag 032 * @author Jonathan Locke 033 */ 034public abstract class MarkupElement 035{ 036 /** 037 * Constructor. 038 */ 039 public MarkupElement() 040 { 041 } 042 043 /** 044 * Gets whether this element closes the given element. 045 * 046 * @param open 047 * The open tag 048 * @return True if this markup element closes the given open tag 049 */ 050 public boolean closes(final MarkupElement open) 051 { 052 return false; 053 } 054 055 /** 056 * This is not an implementation of equals because we don't care about hashCodes for 057 * MarkupElements yet. Also, this method only compares the namespace, name and attributes of the 058 * given MarkupElements. 059 * 060 * @param element 061 * The markup element to compare with 062 * @return True if the other element equals this one 063 */ 064 public abstract boolean equalTo(MarkupElement element); 065 066 /** 067 * @return Gets the charsequence representation of this element 068 */ 069 public abstract CharSequence toCharSequence(); 070 071 /** 072 * Gets a string representation. 073 * 074 * @return A string representation suitable for displaying to the user when something goes 075 * wrong. 076 */ 077 public abstract String toUserDebugString(); 078}