blob: 5848d90bd8b471b836bfeb2f0bca2fd0b5d35b3e [file] [log] [blame]
<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" lang=""><head><meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/><link rel="stylesheet" href="../jacoco-resources/report.css" type="text/css"/><link rel="shortcut icon" href="../jacoco-resources/report.gif" type="image/gif"/><title>FormMessage.java</title><link rel="stylesheet" href="../jacoco-resources/prettify.css" type="text/css"/><script type="text/javascript" src="../jacoco-resources/prettify.js"></script></head><body onload="window['PR_TAB_WIDTH']=4;prettyPrint()"><div class="breadcrumb" id="breadcrumb"><span class="info"><a href="../jacoco-sessions.html" class="el_session">Sessions</a></span><a href="../index.html" class="el_report">Apache Turbine</a> &gt; <a href="index.source.html" class="el_package">org.apache.turbine.util</a> &gt; <span class="el_source">FormMessage.java</span></div><h1>FormMessage.java</h1><pre class="source lang-java linenums">package org.apache.turbine.util;
/*
* 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
* &quot;License&quot;); 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
* &quot;AS IS&quot; 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.
*/
import java.util.ArrayList;
import java.util.List;
/**
* A message class for holding information about a message that
* relates to a specific form and field. Used together with
* FormMessages class.
*
* @author &lt;a href=&quot;mailto:neeme@one.lv&quot;&gt;Neeme Praks&lt;/a&gt;
* @version $Id$
*/
public class FormMessage
{
private String message;
private String formName;
private final List&lt;String&gt; fieldNames;
/**
* Constructor.
*/
public FormMessage()
<span class="nc" id="L43"> {</span>
<span class="nc" id="L44"> fieldNames = new ArrayList&lt;&gt;();</span>
<span class="nc" id="L45"> }</span>
/**
* Constructor.
*
* @param formName A String with the form name.
*/
public FormMessage(String formName)
{
<span class="nc" id="L54"> this();</span>
<span class="nc" id="L55"> setFormName(formName);</span>
<span class="nc" id="L56"> }</span>
/**
* Constructor.
*
* @param formName A String with the form name.
* @param fieldName A String with the field name.
*/
public FormMessage(String formName,
String fieldName)
{
<span class="nc" id="L67"> this(formName);</span>
<span class="nc" id="L68"> setFieldName(fieldName);</span>
<span class="nc" id="L69"> }</span>
/**
* Constructor.
*
* @param formName A String with the form name.
* @param fieldName A String with the field name.
* @param message A String with the message.
*/
public FormMessage(String formName,
String fieldName,
String message)
{
<span class="nc" id="L82"> this(formName, fieldName);</span>
<span class="nc" id="L83"> setMessage(message);</span>
<span class="nc" id="L84"> }</span>
/**
* Return the message.
*
* @return A String with the message.
*/
public String getMessage()
{
<span class="nc" id="L93"> return message;</span>
}
/**
* Return the form name.
*
* @return A String with the form name.
*/
public String getFormName()
{
<span class="nc" id="L103"> return formName;</span>
}
/**
* Return the field names.
*
* @return A String[] with the field names.
*/
public String[] getFieldNames()
{
<span class="nc" id="L113"> return fieldNames.toArray(new String[fieldNames.size()]);</span>
}
/**
* Set the message.
*
* @param message A String with the message.
*/
public void setMessage(String message)
{
<span class="nc" id="L123"> this.message = message;</span>
<span class="nc" id="L124"> }</span>
/**
* Set the form name.
*
* @param formName A String with the form name.
*/
public void setFormName(String formName)
{
<span class="nc" id="L133"> this.formName = formName;</span>
<span class="nc" id="L134"> }</span>
/**
* Adds one field name.
*
* @param fieldName A String with the field name.
*/
public void setFieldName(String fieldName)
{
<span class="nc" id="L143"> fieldNames.add(fieldName);</span>
<span class="nc" id="L144"> }</span>
/**
* Write out the contents of the message in a friendly manner.
*
*/
@Override
public String toString()
{
<span class="nc" id="L153"> StringBuilder sb = new StringBuilder(&quot;formName:&quot; + getFormName() + &quot;, fieldNames:&quot;);</span>
<span class="nc bnc" id="L154" title="All 2 branches missed."> for (int i = 0; i&lt; getFieldNames().length; i++){</span>
<span class="nc" id="L155"> sb.append(getFieldNames()[i] + &quot; &quot;);</span>
}
<span class="nc" id="L157"> sb.append(&quot;, message:&quot; + getMessage());</span>
<span class="nc" id="L159"> return sb.toString();</span>
}
}
</pre><div class="footer"><span class="right">Created with <a href="http://www.jacoco.org/jacoco">JaCoCo</a> 0.8.12.202403310830</span></div></body></html>