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

net.sf.jcmdlineparser.options.FileMultiOption Maven / Gradle / Ivy

/**********************************************************************
Copyright (c) 2009-2010 Alexander Kerner. All rights reserved.
Licensed 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 net.sf.jcmdlineparser.options;

import java.io.File;
import java.util.ArrayList;
import java.util.Collection;

/**
 * 

* An {@code FileMultiOption} represents a command line option that has one or * more string values, representing a relative or absolute file path. *

*

* Each value is separated by {@link AbstractMultiOption#DELIM_PATTERN}. *

*

* Example: *

    *
  • * {@code -f file.txt}
  • *
  • * {@code --files=file.txt,/home/user/stuff.lst,file}
  • *
*

* * @author Alexander Kerner * @version 2010-08-10 * @see AbstractMultiOption * @see AbstractOption * * */ public class FileMultiOption extends AbstractMultiOption { // lastVisit 2010-08-11 /** * TODO */ protected FileMultiOption(Class returnType, char identifierShort, String identifierLong, String description, boolean required) { super(returnType, identifierShort, identifierLong, description, required); } /** * TODO */ protected FileMultiOption(Class returnType, char identifierShort, String identifierLong, String description, boolean required, Collection values) { super(returnType, identifierShort, identifierLong, description, required, values); } @Override public synchronized void parse(String string) { if(string == null) throw new NullPointerException(); if(string.length() < 1) throw new NumberFormatException(); final String[] s = string.split(DELIM_PATTERN); ArrayList l = new ArrayList(); for (String ss : s) { l.add(new File(ss)); } setValues(l); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy