View Javadoc
1 /* SummaryAttribute.java */ 2 3 package org.quilt.frontend.ant; 4 5 import org.apache.tools.ant.BuildException; 6 7 /*** 8 * Accept a limited set of String values for the summary attribute. 9 */ 10 public class SummaryAttribute { 11 12 private String value; 13 private boolean bVal; 14 15 /*** 16 * Constructor. 17 * @param v A candidate value; causes exception if invalid. 18 */ 19 public SummaryAttribute (String v) { 20 setValue (v); 21 } 22 /*** 23 * Return the value successfully set. 24 * 25 * @return The String passed as the value of the summary attribute. 26 */ 27 public String getValue() { 28 return value; 29 } 30 /*** 31 * Ant-compatible set method. Interprets on/true/withoutanderr/yes 32 * as true, false/no/off as false, and throws exception otherwise. 33 * 34 * @param v String, converted to lower case before checking. 35 */ 36 public final void setValue (String value) throws BuildException { 37 this.value = value.toLowerCase(); 38 if ( value.equals("on") || value.equals("true") 39 || value.equals("withoutanderr") || value.equals("yes") ) { 40 bVal = true; 41 } else if ( value.equals("false") || value.equals("no") 42 || value.equals("off" ) ) { 43 bVal = false; 44 } else { 45 throw new BuildException( 46 "invalid summary attribute value: " + value); 47 } 48 } 49 /*** 50 * @return True if the value was on/true/withoutanderr/yes, false 51 * otherwise. 52 */ 53 public boolean asBoolean() { 54 return bVal; 55 } 56 }

This page was automatically generated by Maven