org.apache.fop.util.text

## Class IfFieldPart

- java.lang.Object
- - org.apache.fop.util.text.IfFieldPart

All Implemented Interfaces:
  AdvancedMessageFormat.Part

Direct Known Subclasses:
  EqualsFieldPart

    public class IfFieldPart
    extends Object
    implements AdvancedMessageFormat.Part

Defines an "if" field part that checks if field's value is true or false. It returns either of two possible values attached as additional part parameters. Example: `{field,if,Yes,No}`

### Nested Class Summary

Nested Classes
`static class` `IfFieldPart.Factory` Part factory for "if".

### Field Summary

Fields
`protected String` `elseValue` the value being returned if the field is false
`protected String` `fieldName` the field name for the part
`protected String` `ifValue` the value being returned if the field is true

### Constructor Summary

Constructors
Constructor and Description
`IfFieldPart(String fieldName, String values)` Creates a new "if" field part.

### Method Summary

All Methods Instance Methods Concrete Methods
`boolean` `isGenerated(Map params)`
`protected boolean` `isTrue(Map params)` Indicates whether the field's value is true.
`protected void` `parseValues(String values)` Parses the parameter values
`String` `toString()`
`void` `write(StringBuffer sb, Map params)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

### Field Detail

#### fieldName

    protected String fieldName

the field name for the part

#### ifValue

    protected String ifValue

the value being returned if the field is true

#### elseValue

    protected String elseValue

the value being returned if the field is false

### Constructor Detail

#### IfFieldPart

    public IfFieldPart(String fieldName,
                       String values)

Creates a new "if" field part.

Parameters:
  `fieldName` - the field name
  `values` - the unparsed parameter values

### Method Detail

#### parseValues

    protected void parseValues(String values)

Parses the parameter values

Parameters:
  `values` - the unparsed parameter values

#### write

    public void write(StringBuffer sb,
                      Map params)

Specified by:
  `write` in interface `AdvancedMessageFormat.Part`

#### isTrue

    protected boolean isTrue(Map params)

Indicates whether the field's value is true. If the field is not a boolen, it is true if the field is not null.

Parameters:
  `params` - the message parameters
Returns:
  true the field's value as boolean

#### isGenerated

    public boolean isGenerated(Map params)

Specified by:
  `isGenerated` in interface `AdvancedMessageFormat.Part`

#### toString

    public String toString()

Overrides:
  `toString` in class `Object`