001 package org.gwtbootstrap3.client.ui.base.mixin;
002
003 /*
004 * #%L
005 * GwtBootstrap3
006 * %%
007 * Copyright (C) 2013 - 2014 GwtBootstrap3
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 *
013 * http://www.apache.org/licenses/LICENSE-2.0
014 *
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023 import com.google.gwt.user.client.ui.UIObject;
024
025 /**
026 * @author Joshua Godi
027 */
028 public class AttributeMixin<T extends UIObject> extends AbstractMixin {
029
030 public AttributeMixin(final T uiObject) {
031 super(uiObject);
032 }
033
034 /**
035 * Sets the attribute on the UiObject
036 *
037 * @param attributeName attribute name
038 * @param attributeValue attribute value
039 */
040 public void setAttribute(final String attributeName, final String attributeValue) {
041 uiObject.getElement().setAttribute(attributeName, attributeValue);
042 }
043
044 /**
045 * Get the attribute name on the UiObject
046 *
047 * @param attributeName attribute name
048 * @return attribute value
049 */
050 public String getAttribute(final String attributeName) {
051 return uiObject.getElement().getAttribute(attributeName);
052 }
053
054 /**
055 * Removes the attribute from the UiObject
056 *
057 * @param attributeName attribute name
058 */
059 public void removeAttribute(final String attributeName) {
060 uiObject.getElement().removeAttribute(attributeName);
061 }
062
063 /**
064 * Checks whether or not the UiObject has the element
065 *
066 * @param attributeName attribute name
067 * @return true if has the attribute, false otherwise
068 */
069 public boolean hasAttribute(final String attributeName) {
070 return uiObject.getElement().hasAttribute(attributeName);
071 }
072 }