All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.netbeans.spi.sendopts.OptionProcessor Maven / Gradle / Ivy

The newest version!
/*
 * 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
 * "License"); 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
 * "AS IS" 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.
 */

package org.netbeans.spi.sendopts;

import java.util.Map;
import java.util.Set;
import org.netbeans.api.sendopts.CommandException;

/** A subclass of this class shall be registered using {@link org.openide.util.lookup.ServiceProvider}
 * in order to register it for participation on handling
 * and processing of command line options initiated by
 * {@link org.netbeans.api.sendopts.CommandLine#getDefault}'s
 * {@link org.netbeans.api.sendopts.CommandLine#process}.
 * When the {@link Option}s provided by this processor are found
 * on the command line and are consistent, this processor's {@link #process}
 * method is going to be called to handle their values and invoke an action.
 * 

* Looking forward: consider using {@link Arg declarative annotations} for * registering your options more effectively. *

* The usual pattern for writing a subclass of processor is: *

 * {@code @}{@link org.openide.util.lookup.ServiceProvider}(service=OptionProcessor.class)
 * public class MyProcessor extends OptionProcessor {
 *   private Option option1 = ...;
 *   private Option option2 = ...;
 *   private Option option3 = ...;
 * 
 *   protected Set<Option> getOptions() {
 *      Set<Option> set = new HashSet<Option>();
 *      set.add(option1);
 *      set.add(option2);
 *      set.add(option3);
 *      return set;
 *   }
 * 
 *   protected void process(Env env, Map<Option,String[]> values) 
 *       throws {@link CommandException} {
 *     if (values.containsKey(option1)) { ... }
 *     if (values.containsKey(option2)) { ... }
 *     if (values.containsKey(option3)) { ... }
 *   }
 * }
 * 
* * @author Jaroslav Tulach */ public abstract class OptionProcessor { /** Constructor for subclasses. */ protected OptionProcessor() { } /** Method to override in subclasses to create * the right set of {@link Option}s. * See the factory methods that are part of the {@link Option}'s javadoc * or read the * usecases for the sendopts API. *

* * @return a set of options this processor is interested in, if during * processing at least on of the options appears on command line * the {@link OptionProcessor#process} method will be invoked to * handle such option and its values */ protected abstract Set





© 2015 - 2025 Weber Informatics LLC | Privacy Policy