group tags;

/*
 * 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.
 */


tag(tagInfo) ::= <<
// ---------- Attention: Generated code, please do not modify! -----------  

/*
 * 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 <tagInfo.packageName>;

<tagInfo.imports:import(); separator="\n">

/** 
 * JSP Tag class, generated from template {@code tag1.2.stg} with class 
 * {@link <tagInfo.sourceClass>}.
 */
public final class <tagInfo.className> extends <tagInfo.superClassName> {
  private static final Logger LOG = LoggerFactory.getLogger(<tagInfo.className>.class);
  <tagInfo.properties:field(); separator="\n">

  @Override
  public String getComponentType() {
    return <tagInfo.componentClassName>.COMPONENT_TYPE;
  }
  @Override
  public String getRendererType() {
  <if(tagInfo.rendererType)>
    return "<tagInfo.rendererType>";
  <else>
    return null;
  <endif>
  }

  <if(tagInfo.properties)>
  @Override
  protected void setProperties(final UIComponent uiComponent) {
    super.setProperties(uiComponent);
    final <tagInfo.componentClassName> component = (<tagInfo.componentClassName>) uiComponent;
    final FacesContext context = FacesContext.getCurrentInstance();
    final Application application = context.getApplication();
    <tagInfo.properties:{ p | <p:(p.template)()>}; separator="\n">
  }

  <tagInfo.properties:property(); separator="\n">

  <if(tagInfo.bodyContent)>
  @Override
  public int doAfterBody() throws javax.servlet.jsp.JspException {
    final String content = bodyContent.getString();
    bodyContent.clearBody();
    if (StringUtils.isNotBlank(content)) {
      final <tagInfo.componentClassName> component = (<tagInfo.componentClassName>) getComponentInstance();
      component.set<tagInfo.bodyContent.upperCamelCaseName>(content.trim());
    }
    return super.doAfterBody();
  }
  <endif>

  @Override
  public void release() {
    super.release();
    <tagInfo.properties:release(); separator="\n">
  }
  <endif>
}
>>

import() ::= <<
import <it>;
>>

release() ::= <<
<it.propertyName> = null;
>>

property() ::= <<
<if(it.literalOnly)>
public String get<it.upperCamelCaseName>() {
  return <it.propertyName>;
}

public void set<it.upperCamelCaseName>(final String <it.propertyName>) {
  this.<it.propertyName> = <it.propertyName>;
}
<else>
<if(it.methodExpressionRequired)>
public javax.el.MethodExpression get<it.upperCamelCaseName>() {
  return <it.propertyName>;
}

public void set<it.upperCamelCaseName>(final javax.el.MethodExpression <it.propertyName>) {
  this.<it.propertyName> = <it.propertyName>;
}
<else>
public javax.el.ValueExpression get<it.upperCamelCaseName>() {
  return <it.propertyName>;
}

public void set<it.upperCamelCaseName>(final javax.el.ValueExpression <it.propertyName>) {
  this.<it.propertyName> = <it.propertyName>;
}
<endif>
<endif>


>>

field() ::= <<
<if(it.literalOnly)>
private String <it.propertyName>;
<else>
  <if(it.methodExpressionRequired)>
private javax.el.MethodExpression  <it.propertyName>;
  <else>
private javax.el.ValueExpression  <it.propertyName>;
  <endif>
<endif>
>>

ValueExpression() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  /*} else {
    component.set<it.upperCamelCaseName>(<it.propertyName>.getExpressionString());*/
  }
}
>>

String() ::= <<
<createStringProperty(it)>
>>

Severity() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.getAttributes().put("<it.name>", <it.propertyName>.getExpressionString());
  }
}
>>

Object() ::= <<
<createStringProperty(it)>
>>

Character() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(<it.propertyName>.getExpressionString().charAt(0));
  }
}
>>

boolean() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(Boolean.parseBoolean(<it.propertyName>.getExpressionString()));
  }
}
>>

Boolean() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(Boolean.valueOf(<it.propertyName>.getExpressionString()));
  }
}
>>

int() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    <if(it.widthOrHeight)>
    String <it.propertyName>Str = <it.propertyName>.getExpressionString();
    if (<it.propertyName>Str.endsWith("px")) {
      <it.propertyName>Str = <it.propertyName>Str.substring(0, <it.propertyName>Str.length() - 2);
    }
    component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>Str));
    <else>
    component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>.getExpressionString()));
    <endif>
  }
}
>>

Integer() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    <if(it.widthOrHeight)>
    String <it.propertyName>Str = <it.propertyName>.getExpressionString();
    if (<it.propertyName>Str.endsWith("px")) {
      <it.propertyName>Str = <it.propertyName>Str.substring(0, <it.propertyName>Str.length() - 2);
    }
    component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>Str));
    <else>
    component.set<it.upperCamelCaseName>(Integer.parseInt(<it.propertyName>.getExpressionString()));
    <endif>
  }
}
>>

Measure() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.layout.Measure.valueOf(<it.propertyName>.getExpressionString()));
  }
}
>>

TextAlign() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.layout.TextAlign.parse(<it.propertyName>.getExpressionString()));
  }
}
>>

Markup() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.context.Markup.valueOf(<it.propertyName>.getExpressionString()));
  }
}
>>

OrderBy() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.internal.component.AbstractUIMessages.OrderBy.parse(<it.propertyName>.getExpressionString()));
  }
}
>>

StringArray() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(splitList(<it.propertyName>.getExpressionString()));
  }
}
>>

TabChangeListener() ::= <<
if (<it.propertyName> != null) {
  component.add<it.template>(new org.apache.myfaces.tobago.event.MethodExpressionTabChangeListener(<it.propertyName>));
}
>>

ActionListener() ::= <<
if (<it.propertyName> != null) {
  component.add<it.template>(new javax.faces.event.MethodExpressionActionListener(<it.propertyName>));
}
>>

ValueChangeListener() ::= <<
if (<it.propertyName> != null) {
  component.add<it.template>(new javax.faces.event.MethodExpressionValueChangeListener(<it.propertyName>));
}
>>

StateChangeListener() ::= <<
if (<it.propertyName> != null) {
  component.add<it.template>(new org.apache.myfaces.tobago.event.MethodExpressionStateChangeListener(<it.propertyName>));
}
>>

SortActionListener() ::= <<
if (<it.propertyName> != null) {
  component.set<it.template>Expression(<it.propertyName>);
}
>>

TreeExpansionListener() ::= <<
if (<it.propertyName> != null) {
  component.add<it.template>(new org.apache.myfaces.tobago.event.MethodExpressionTreeExpansionListener(<it.propertyName>));
}
>>

TreeMarkedListener() ::= <<
if (<it.propertyName> != null) {
  component.add<it.template>(new org.apache.myfaces.tobago.event.MethodExpressionTreeMarkedListener(<it.propertyName>));
}
>>

SuggestMethod() ::= <<
if (<it.propertyName> != null) {
  component.set<it.template>Expression(<it.propertyName>);
}
>>

SuggestFilter() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.set<it.upperCamelCaseName>(org.apache.myfaces.tobago.model.SuggestFilter.parse(<it.propertyName>.getExpressionString()));
  }
}
>>

Validator() ::= <<
if (<it.propertyName> != null) {
  component.addValidator(new javax.faces.validator.MethodExpressionValidator(<it.propertyName>));
}
>>

Action() ::= <<
if (<it.propertyName> != null) {
  component.setActionExpression(<it.propertyName>);
}
>>

Converter() ::= <<
if (<it.propertyName> != null) {
  if (!<it.propertyName>.isLiteralText()) {
    <createValueBinding(it)>
  } else {
    component.setConverter(application.createConverter(<it.propertyName>.getExpressionString()));
  }
}
>>

createStringProperty(it) ::= <<
if (<it.propertyName> != null) {
  <if(it.literalOnly)>
  component.set<it.upperCamelCaseName>(<it.propertyName>);
  <else>
  <createValueBinding(it)>
  <endif>
}

>>

createValueBinding(it) ::= <<
component.setValueExpression("<it.name>", <it.propertyName>);
>>



