001/* 002 * Copyright 2012 GWT-Bootstrap 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package com.github.gwtbootstrap.client.ui.resources; 017 018import com.google.gwt.dom.client.Document; 019import com.google.gwt.dom.client.Element; 020import com.google.gwt.dom.client.HeadElement; 021 022/** 023 * Base class for classes that inject someting into the document header. 024 * 025 * @since 2.0.4.0 026 * @author Carlos Alexandro Becker 027 * @author Dominik Mayer 028 */ 029public abstract class AbstractInjector { 030 031 private static HeadElement head; 032 033 /** 034 * Gets the document header. 035 * 036 * @return the document header 037 */ 038 protected static HeadElement getHead() { 039 if (head == null) { 040 Element element = 041 Document.get().getElementsByTagName("head").getItem(0); 042 assert element != null : "HTML Head element required"; 043 HeadElement head = HeadElement.as(element); 044 AbstractInjector.head = head; 045 } 046 return AbstractInjector.head; 047 } 048}