    001    package org.maltparser.core.options.option;
    002
    003    import org.maltparser.core.exception.MaltChainedException;
    004    import org.maltparser.core.options.OptionException;
    005    import org.maltparser.core.options.OptionGroup;
    006
    007    /**
    008     * An unary option is an option that doesn't need a value to the
    009     * specified. For example the --system-help option (-h or --help).
    010     *
    011     * @author Johan Hall
    012     * @since 1.0
    013    **/
    014    public class UnaryOption extends Option {
    015
    016            /**
    017             * Creates an unary option description
    018             *
    019             * @param group a reference to the option group.
    020             * @param name  the name of the option.
    021             * @param shortDescription      a short description of the option.
    022             * @param flag  a short string that can be used in the command line.
    023             * @param usage a string that explains the usage of the option.
    024             * @throws OptionException
    025             */
    026            public UnaryOption(OptionGroup group,
    027                                                    String name,
    028                                                    String shortDescription,
    029                                                    String flag,
    030                                                    String usage) throws MaltChainedException {
    031                    super(group, name, shortDescription, flag, usage);
    032            }
    033
    034            /* (non-Javadoc)
    035             * @see org.maltparser.core.options.option.Option#getValueObject(java.lang.String)
    036             */
    037            public Object getValueObject(String value) throws MaltChainedException {
    038                    if (value.equalsIgnoreCase("used")) {
    039                            return new Boolean(true);
    040                    }
    041                    return null;
    042            }
    043
    044            /* (non-Javadoc)
    045             * @see org.maltparser.core.options.option.Option#getDefaultValueObject()
    046             */
    047            public Object getDefaultValueObject() throws MaltChainedException {
    048                    return null;
    049            }
    050
    051            /* (non-Javadoc)
    052             * @see org.maltparser.core.options.option.Option#getDefaultValueString()
    053             */
    054            public String getDefaultValueString() {
    055                    return null;
    056            }
    057
    058            /* (non-Javadoc)
    059             * @see org.maltparser.core.options.option.Option#getStringRepresentation(java.lang.Object)
    060             */
    061            public String getStringRepresentation(Object value)  {
    062                    return null;
    063            }
    064
    065            /* (non-Javadoc)
    066             * @see org.maltparser.core.options.option.Option#setDefaultValue(java.lang.String)
    067             */
    068            public void setDefaultValue(String defaultValue) throws MaltChainedException { }
    069
    070            /* (non-Javadoc)
    071             * @see org.maltparser.core.options.option.Option#toString()
    072             */
    073            public String toString() {
    074                    final StringBuilder sb = new StringBuilder();
    075                    sb.append(super.toString());
    076                    sb.append("-----------------------------------------------------------------------------\n");
    077                    return sb.toString();
    078            }
    079    }