package net.xoetrope.html;
import net.xoetrope.debug.DebugLogger;
import net.xoetrope.xml.XmlElement;
import net.xoetrope.xml.XmlSource;
import net.xoetrope.xui.XMetaContentHolder;
import net.xoetrope.xui.XProjectManager;
import net.xoetrope.xui.style.XStyle;
import net.xoetrope.xui.style.XStyleComponent;
import org.w3c.dom.html.HTMLMetaElement;
/**
* <p>
* Copyright (c) Xoetrope Ltd., 1998-2003<br>
* License: see license.txt
*
* @version 1.0
*/
public class XMetaContent extends XHtmlWidget implements XMetaContentHolder, XStyleComponent
{
private XmlElement content;
private String strContent;
private String src;
private XStyle currentStyle;
/**
* Constructs a new XMetaContent component
*/
public XMetaContent()
{
super();
HTMLMetaElement meta = (HTMLMetaElement)htmlDoc.createElement( "META" );
metaElement = meta;
}
/**
* Create a new XMetaContent with an id
*
* @param id
* the id of the meta content
*/
public XMetaContent( String id )
{
super();
HTMLMetaElement meta = (HTMLMetaElement)htmlDoc.createElement( "META" );
meta.setId( id );
metaElement = meta;
}
/**
* Create a new XMetaContent based on an existing HTML meta element.
*
* @param meta
* the HTML meta tag the XMetaContent refers to
*/
public XMetaContent( HTMLMetaElement meta )
{
super( meta );
}
/**
* Set the meta content to a simple string value
*/
public void setContent( String content )
{
metaElement.setContent( content );
}
/**
* Get the meta content's name .
*/
public String getContent()
{
return metaElement.getContent();
}
/**
* Set the http-equiv attribute of the meta element
*
* @param httpEquiv
* the attribute value
*/
public void setHttpEquiv( String httpEquiv )
{
metaElement.setHttpEquiv( httpEquiv );
}
/**
* Get the http-equiv attribute of the meta element
*
* @return the attribute value
*/
public String getHttpEquiv()
{
return metaElement.getHttpEquiv();
}
/**
* Set the name attribute of the meta element
*
* @param name
* the attribute value
*/
public void setName( String name )
{
metaElement.setName( name );
}
/**
* Get the name attribute of the meta element
*
* @return the attribute value
*/
public String getName()
{
return metaElement.getName();
}
/**
* Set the scheme attribute of the meta element
*
* @param scheme
* the attribute value
*/
public void setScheme( String scheme )
{
metaElement.setScheme( scheme );
}
/**
* Get the scheme attribute of the meta element
*
* @return the attribute value
*/
public String getScheme()
{
return metaElement.getScheme();
}
/**
* Get the HTML element at which refers the XMetaContent.
*
* @return the HTML element.
*/
public HTMLMetaElement getHTMLElement()
{
return metaElement;
}
/*
* ============================================================================== |
* Abstract methods from the interfaces implemented |
* =============================================================================
*/
/**
* Set the meta content.
*
* @param source
* the location from which the xml was obtained
* @param srcReader
* the input xml
*/
public void setContent( String source, XmlElement srcReader )
{
if ( source.indexOf( "<?xml" ) == 0 )
strContent = source;
else if ( source.indexOf( ".xml" ) > 0 ) {
try {
srcReader = XmlSource.read( currentProject.getBufferedReader( source, null ) );
}
catch ( Exception ex ) {
DebugLogger.logWarning( "Unable to load content: " + source );
DebugLogger.logWarning( "Please check the case of the file name" );
ex.printStackTrace();
}
}
src = source;
content = srcReader;
}
/**
* Set the current style.
*
* @param style
* the style name
*/
public void setStyle( String style )
{
currentStyle = XProjectManager.getStyleManager().getStyle( style );
}
}