/*
 *  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.
 */
package org.apache.myfaces.trinidadinternal.renderkit.core.xhtml;

import java.io.IOException;

import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.faces.context.ResponseWriter;

import org.apache.myfaces.trinidad.bean.FacesBean;
import org.apache.myfaces.trinidad.component.core.output.CoreSeparator;
import org.apache.myfaces.trinidad.context.RenderingContext;

public class SeparatorRenderer extends XhtmlRenderer
{
  public SeparatorRenderer()
  {
    super(CoreSeparator.TYPE);
  }
  
  @Override
  protected void encodeBegin(
    FacesContext        context,
    RenderingContext arc,
    UIComponent         comp,
    FacesBean           bean) throws IOException
  {

    ResponseWriter rw = context.getResponseWriter();
    rw.startElement("hr", comp);
    renderId(context, comp);
    renderAllAttributes(context, arc, bean);
    rw.endElement("hr");
  }

  @Override
  protected void renderAllAttributes(
    FacesContext        context,
    RenderingContext arc,
    FacesBean           bean) throws IOException
  {
    ResponseWriter rw = context.getResponseWriter();

    renderAllAttributes(context, arc, bean, false);
    renderStyleAttributes(context, arc, bean);

    // Old PDA renderer rule
    if (isPDA(arc))
      rw.writeAttribute("size", "1", null);
  }

  @Override
  protected String getDefaultStyleClass(FacesBean bean)
  {
    return SkinSelectors.AF_SEPARATOR_STYLE_CLASS;
  }
}
