Package henplus.property

Examples of henplus.property.PropertyHolder


        final int argc = st.countTokens();

        if (cmd.startsWith("re")) { // 'reset-property'
            if (argc == 1) {
                final String name = st.nextToken();
                PropertyHolder holder;
                holder = getRegistry().getPropertyMap().get(name);
                if (holder == null) {
                    return EXEC_FAILED;
                }
                final String defaultValue = holder.getDefaultValue();
                try {
                    holder.setValue(defaultValue);
                } catch (final Exception e) {
                    HenPlus.msg().println("setting to default '" + defaultValue + "' failed.");
                    return EXEC_FAILED;
                }
                return SUCCESS;
            }
            return SYNTAX_ERROR;
        } else {
            /*
             * no args. show available properties
             */
            if (argc == 0) {
                PROP_META[0].resetWidth();
                PROP_META[1].resetWidth();
                final TableRenderer table = new TableRenderer(PROP_META, HenPlus.out());
                for (Map.Entry<String, PropertyHolder> entry : getRegistry().getPropertyMap().entrySet()) {
                    final Column[] row = new Column[3];
                    final PropertyHolder holder = entry.getValue();
                    row[0] = new Column(entry.getKey());
                    row[1] = new Column(holder.getValue());
                    row[2] = new Column(holder.getShortDescription());
                    table.addRow(row);
                }
                table.closeTable();
                return SUCCESS;
            } else if (argc == 1) {
                /*
                 * one arg: show help
                 */
                final String name = st.nextToken();
                PropertyHolder holder;
                holder = getRegistry().getPropertyMap().get(name);
                if (holder == null) {
                    return EXEC_FAILED;
                }
                printDescription(name, holder);
View Full Code Here


        final int argc = st.countTokens();

        if (argc > ("".equals(lastWord) ? 0 : 1)) { /* one arg given */
            if (getSetCommand().equals(cmd)) {
                final String name = st.nextToken();
                PropertyHolder holder;
                holder = getRegistry().getPropertyMap().get(name);
                if (holder == null) {
                    return null;
                }
                return holder.completeValue(lastWord);
            }
            return null;
        }

        return new SortedMatchIterator(lastWord, getRegistry().getPropertyMap());
View Full Code Here

    @Override
    public void shutdown() {
        final Map<String,String> writeMap = new HashMap<String,String>();
        for (Map.Entry<String, PropertyHolder> entry : _registry.getPropertyMap().entrySet()) {
            final PropertyHolder holder = entry.getValue();
            writeMap.put(entry.getKey(), holder.getValue());
        }
        _config.storeProperties(writeMap, true, "user properties");
    }
View Full Code Here

     *            the new value of the property to be set.
     * @throws Exception
     *             , if the property does not exist or throws an Exception to veto the new value.
     */
    public void setProperty(final String name, final String value) throws Exception {
        final PropertyHolder holder = _namedProperties.get(name);
        if (holder == null) {
            throw new IllegalArgumentException("unknown property '" + name + "'");
        }
        holder.setValue(value);
    }
View Full Code Here

TOP

Related Classes of henplus.property.PropertyHolder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.