/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* $Header:$
*/
package org.apache.beehive.netui.tags.rendering;
import java.util.HashMap;
import java.util.Map;
/**
* This class extends the AbstractAttributeState
to add support for HTML.
* This class add support for the id
, style
, and class
* attributes. In addition, there is a Map
that supports the JavaScript
* event attributes.
*/
public class AbstractHtmlState extends AbstractAttributeState
{
/**
* Define the Attribute Map for the JavaScript event handler attributes.
*/
public static final int ATTR_JAVASCRIPT = 12;
/**
* The HTML id
attribute.
*/
public String id;
/**
* The HTML style
attribute.
*/
public String style;
/**
* The HTML class
attribute.
*/
public String styleClass;
private HashMap _jsMap = null; // Map used to hold the registered JavaScript attributes.
/**
* Return the Map Containing the JavaScript entries.
* @return a Map
of the JavaScript attributes.
*/
public HashMap getEventMap()
{
return _jsMap;
}
/**
* Initialize the state.
*/
public void clear()
{
super.clear();
if (_jsMap != null)
_jsMap.clear();
id = null;
style = null;
styleClass = null;
}
/**
* This method will return the map that represents the passed in type
. The boolean flag
* createIfNull indicates that the map should be created or not if it's null. This
* class defines two maps defined by @see #ATTR_STYLE
and ATTR_JAVASCRIPT
* @param type integer
type indentifying the map to be created.
* @param createIfNull boolean
flag indicating if the map should be created if it doesn't exist.
* @return The map or null
* @see #ATTR_JAVASCRIPT
*/
public Map selectMap(int type, boolean createIfNull)
{
if (type == ATTR_JAVASCRIPT) {
if (_jsMap == null && createIfNull)
_jsMap = new HashMap();
return _jsMap;
}
return super.selectMap(type, createIfNull);
}
}