当前位置: 首页>>代码示例>>Java>>正文


Java Parameter类代码示例

本文整理汇总了Java中org.apache.tools.ant.types.Parameter的典型用法代码示例。如果您正苦于以下问题:Java Parameter类的具体用法?Java Parameter怎么用?Java Parameter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Parameter类属于org.apache.tools.ant.types包,在下文中一共展示了Parameter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setParameters

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * When using this as a custom selector, this method will be called.
 * It translates each parameter into the appropriate setXXX() call.
 *
 * @param parameters the complete set of parameters for this selector
 */
public void setParameters(Parameter... parameters) {
    super.setParameters(parameters);
    if (parameters != null) {
        for (int i = 0; i < parameters.length; i++) {
            String paramname = parameters[i].getName();
            if (NAME_KEY.equalsIgnoreCase(paramname)) {
                setName(parameters[i].getValue());
            } else if (CASE_KEY.equalsIgnoreCase(paramname)) {
                setCasesensitive(Project.toBoolean(
                        parameters[i].getValue()));
            } else if (NEGATE_KEY.equalsIgnoreCase(paramname)) {
                setNegate(Project.toBoolean(parameters[i].getValue()));
            } else if (REGEX_KEY.equalsIgnoreCase(paramname)) {
                setRegex(parameters[i].getValue());
            } else {
                setError("Invalid parameter " + paramname);
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:27,代码来源:FilenameSelector.java

示例2: setParameters

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * When using this as a custom selector, this method will be called.
 * It translates each parameter into the appropriate setXXX() call.
 *
 * @param parameters the complete set of parameters for this selector
 */
public void setParameters(Parameter... parameters) {
    super.setParameters(parameters);
    if (parameters != null) {
        for (int i = 0; i < parameters.length; i++) {
            String paramname = parameters[i].getName();
            if (CONTAINS_KEY.equalsIgnoreCase(paramname)) {
                setText(parameters[i].getValue());
            } else if (CASE_KEY.equalsIgnoreCase(paramname)) {
                setCasesensitive(Project.toBoolean(
                        parameters[i].getValue()));
            } else if (WHITESPACE_KEY.equalsIgnoreCase(paramname)) {
                setIgnorewhitespace(Project.toBoolean(
                        parameters[i].getValue()));
            } else {
                setError("Invalid parameter " + paramname);
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:26,代码来源:ContainsSelector.java

示例3: setParameters

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * When using this as a custom selector, this method will be called.
 * It translates each parameter into the appropriate setXXX() call.
 *
 * @param parameters the complete set of parameters for this selector
 */
@Override
public void setParameters(Parameter... parameters) {
    super.setParameters(parameters);
    if (parameters != null) {
        for (int i = 0; i < parameters.length; i++) {
            String paramname = parameters[i].getName();
            if (TYPE_KEY.equalsIgnoreCase(paramname)) {
                FileType t = new FileType();
                t.setValue(parameters[i].getValue());
                setType(t);
            } else {
                setError("Invalid parameter " + paramname);
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:23,代码来源:TypeSelector.java

示例4: setParameters

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * When using this as a custom selector, this method will be called.
 * It translates each parameter into the appropriate setXXX() call.
 *
 * @param parameters the complete set of parameters for this selector
 */
public void setParameters(Parameter... parameters) {
    super.setParameters(parameters);
    if (parameters != null) {
        for (int i = 0; i < parameters.length; i++) {
            String paramname = parameters[i].getName();
            if (EXPRESSION_KEY.equalsIgnoreCase(paramname)) {
                setExpression(parameters[i].getValue());
            } else if (CS_KEY.equalsIgnoreCase(paramname)) {
                setCaseSensitive(Project
                                 .toBoolean(parameters[i].getValue()));
            } else if (ML_KEY.equalsIgnoreCase(paramname)) {
                setMultiLine(Project.toBoolean(parameters[i].getValue()));
            } else if (SL_KEY.equalsIgnoreCase(paramname)) {
                setSingleLine(Project.toBoolean(parameters[i].getValue()));
            } else {
                setError("Invalid parameter " + paramname);
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:27,代码来源:ContainsRegexpSelector.java

示例5: initialize

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * Parses the parameters to set the line-breaking characters.
 */
private void initialize() {
    String userDefinedLineBreaks = null;
    Parameter[] params = getParameters();
    if (params != null) {
        for (int i = 0; i < params.length; i++) {
            if (LINE_BREAKS_KEY.equals(params[i].getName())) {
                userDefinedLineBreaks = params[i].getValue();
                break;
            }
        }
    }
    if (userDefinedLineBreaks != null) {
        lineBreaks = userDefinedLineBreaks;
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:19,代码来源:StripLineBreaks.java

示例6: initialize

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * Scans the parameters list for the "lines" parameter and uses
 * it to set the number of lines to be returned in the filtered stream.
 * also scan for skip parameter.
 */
private void initialize() {
    Parameter[] params = getParameters();
    if (params != null) {
        for (int i = 0; i < params.length; i++) {
            if (LINES_KEY.equals(params[i].getName())) {
                lines = Long.parseLong(params[i].getValue());
                continue;
            }
            if (SKIP_KEY.equals(params[i].getName())) {
                skip = Long.parseLong(params[i].getValue());
                continue;
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:21,代码来源:HeadFilter.java

示例7: initialize

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * Scans the parameters list for the "lines" parameter and uses
 * it to set the number of lines to be returned in the filtered stream.
 * also scan for "skip" parameter.
 */
private void initialize() {
    Parameter[] params = getParameters();
    if (params != null) {
        for (int i = 0; i < params.length; i++) {
            if (LINES_KEY.equals(params[i].getName())) {
                setLines(Long.parseLong(params[i].getValue()));
                continue;
            }
            if (SKIP_KEY.equals(params[i].getName())) {
                skip = Long.parseLong(params[i].getValue());
                continue;
            }
        }
    }
}
 
开发者ID:apache,项目名称:ant,代码行数:21,代码来源:TailFilter.java

示例8: testValidate

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * Test the code that validates the selector.
 */
@Test
public void testValidate() {
    ContainsSelector s = new ContainsSelector();
    try {
        s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
        fail("ContainsSelector did not check for required field 'text'");
    } catch (BuildException be1) {
        assertEquals("The text attribute is required", be1.getMessage());
    }

    s = new ContainsSelector();
    Parameter param = new Parameter();
    param.setName("garbage in");
    param.setValue("garbage out");
    Parameter[] params = {param};
    s.setParameters(params);
    try {
        s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
        fail("ContainsSelector did not check for valid parameter element");
    } catch (BuildException be2) {
        assertEquals("Invalid parameter garbage in", be2.getMessage());
    }

}
 
开发者ID:apache,项目名称:ant,代码行数:28,代码来源:ContainsSelectorTest.java

示例9: testValidate

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
/**
 * Test the code that validates the selector.
 */
@Test
public void testValidate() {
    FilenameSelector s = new FilenameSelector();
    try {
        s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
        fail("FilenameSelector did not check for required fields");
    } catch (BuildException be1) {
        assertEquals("The name or regex attribute is required", be1.getMessage());
    }

    s = new FilenameSelector();
    Parameter param = new Parameter();
    param.setName("garbage in");
    param.setValue("garbage out");
    Parameter[] params = {param};
    s.setParameters(params);
    try {
        s.isSelected(selectorRule.getProject().getBaseDir(),selectorRule.getFilenames()[0],selectorRule.getFiles()[0]);
        fail("FilenameSelector did not check for valid parameter element");
    } catch (BuildException be2) {
        assertEquals("Invalid parameter garbage in", be2.getMessage());
    }

}
 
开发者ID:apache,项目名称:ant,代码行数:28,代码来源:FilenameSelectorTest.java

示例10: testModuleRejectedIfNotEager

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
public void testModuleRejectedIfNotEager() throws Exception {
    File cfg = new File(new File(getWorkDir(), "config"), "Modules");
    cfg.mkdirs();
    assertTrue("Created", cfg.isDirectory());
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar("org.my.module", new String[0], m);
    
    File trackingFile = new File(cfg, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"\n" +
                        "                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">\n" +
                        "<module name=\"org.my.module\">\n" +
                        "    <param name=\"autoload\">true</param>\n" +
                        "    <param name=\"eager\">false</param>\n" +
                        "    <param name=\"jar\">modules/org-openide-awt.jar</param>\n" +
                        "    <param name=\"reloadable\">false</param>\n" +
                        "    <param name=\"specversion\">7.4.0.1</param>\n" +
                        "</module>\n"
        );
    }

    Parameter p = new Parameter();
    p.setName("acceptEager");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("acceptAutoload");
    p2.setValue("false");
    selector.setParameters(new Parameter[] { p, p2 });
    
    assertFalse("module not accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ModuleStateSelectorTest.java

示例11: testModuleAcceptedIfEager

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
public void testModuleAcceptedIfEager() throws Exception {
    File cfg = new File(new File(getWorkDir(), "config"), "Modules");
    cfg.mkdirs();
    assertTrue("Created", cfg.isDirectory());

    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module/1");
    File aModule = generateJar("org.my.module", new String[0], m);

    File trackingFile = new File(cfg, "org-my-module.xml");
    try (FileWriter w = new FileWriter(trackingFile)) {
        w.write(
                "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
                        "<!DOCTYPE module PUBLIC \"-//NetBeans//DTD Module Status 1.0//EN\"\n" +
                        "                        \"http://www.netbeans.org/dtds/module-status-1_0.dtd\">\n" +
                        "<module name=\"org.my.module\">\n" +
                        "    <param name=\"autoload\">false</param>\n" +
                        "    <param name=\"eager\">true</param>\n" +
                        "    <param name=\"jar\">modules/org-openide-awt.jar</param>\n" +
                        "    <param name=\"reloadable\">false</param>\n" +
                        "    <param name=\"specversion\">7.4.0.1</param>\n" +
                        "</module>\n"
        );
    }

    Parameter p = new Parameter();
    p.setName("acceptEager");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("acceptAutoload");
    p2.setValue("false");
    selector.setParameters(new Parameter[] { p, p2 });

    assertTrue("module accepted", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:ModuleStateSelectorTest.java

示例12: testCanExcludeAModule

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
public void testCanExcludeAModule() throws Exception {
    Parameter p = new Parameter();
    p.setName("excludeModules");
    p.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    assertFalse("Refused", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ModuleSelectorTest.java

示例13: testCanExcludeOSGiWithAttributes

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
public void testCanExcludeOSGiWithAttributes() throws Exception {
    Parameter p = new Parameter();
    p.setName("excludeModules");
    p.setValue("org.eclipse.core.jobs");
    selector.setParameters(new Parameter[] { p });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("Bundle-SymbolicName", "org.eclipse.core.jobs; singleton:=true");
    File aModule = generateJar(new String[0], m);
    assertFalse("Refused", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:12,代码来源:ModuleSelectorTest.java

示例14: testCanShowOnlyExcludedModules

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
public void testCanShowOnlyExcludedModules() throws Exception {
    Parameter p = new Parameter();
    p.setName("excluded");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("excludeModules");
    p2.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p, p2 });
    
    Manifest m = createManifest ();
    m.getMainAttributes().putValue("OpenIDE-Module", "org.my.module");
    File aModule = generateJar(new String[0], m);
    assertTrue("Now we are accepting only excluded modules", selector.isSelected(getWorkDir(), aModule.toString(), aModule));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:ModuleSelectorTest.java

示例15: testIsSelectedForNotAModuleIsStillFalseEvenWeAcceptOnlyExcludedModules

import org.apache.tools.ant.types.Parameter; //导入依赖的package包/类
public void testIsSelectedForNotAModuleIsStillFalseEvenWeAcceptOnlyExcludedModules() throws IOException {
    Parameter p = new Parameter();
    p.setName("excluded");
    p.setValue("true");
    Parameter p2 = new Parameter();
    p2.setName("excludeModules");
    p2.setValue("org.my.module");
    selector.setParameters(new Parameter[] { p, p2 });
    
    
    File noModule = generateJar(new String[0], createManifest ());
    assertFalse("Not acceptable", selector.isSelected(getWorkDir(), noModule.toString(), noModule));
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:ModuleSelectorTest.java


注:本文中的org.apache.tools.ant.types.Parameter类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。