Java 类com.beust.jcommander.Parameterized 实例源码

项目:geowave    文件:JCommanderTranslationMap.java   
/**
 * This is a mapping between the created facade's field (e.g., field_0) and
 * the JCommander parameter (param) which lives in the object it was parsed
 * from, 'item'.
 * 
 * @param newFieldName
 * @param item
 * @param param
 * @param names
 *            - the arguments values for this item.
 */
protected void addEntry(
        String newFieldName,
        Object item,
        Parameterized param,
        String prefix,
        AnnotatedElement member ) {

    translations.put(
            newFieldName,
            new TranslationEntry(
                    param,
                    item,
                    prefix,
                    member));
}
项目:geowave    文件:JCommanderPrefixTranslator.java   
public JCommanderPrefixTranslator() {
    try {
        // HP Fortify "Access Specifier Manipulation"
        // These fields are being modified by trusted code,
        // in a way that is not influenced by user input
        paraField = Parameterized.class.getDeclaredField("m_field");
        paraField.setAccessible(true);

        paraMethod = Parameterized.class.getDeclaredField("m_method");
        paraMethod.setAccessible(true);
    }
    catch (NoSuchFieldException e) {
        // This is a programmer error, and will only happen if another
        // version
        // of JCommander is being used.
        throw new RuntimeException(
                e);
    }
}
项目:geowave    文件:TranslationEntryTest.java   
@Before
public void setUp() {
    try {

        Arguments args = new Arguments();
        ArrayList<Parameterized> params = (ArrayList<Parameterized>) Parameterized.parseArg(args);
        if (params.size() == 0) {
            fail("Could not find parameter");
        }

        param = params.get(0);

    }
    catch (SecurityException e) {
        // Should never trigger
        e.printStackTrace();
    }
    obj = 4;
    prefix = "prefix";
    aElement = Integer.class;
    entry = new TranslationEntry(
            param,
            (Object) obj,
            prefix,
            aElement);
}
项目:crigtt    文件:CliValidatorServiceImpl.java   
@Override
public Object convertValue(Parameterized parameterized, Class targetType, String src) {
    if (!Resource.class.isAssignableFrom(targetType)) {
        return super.convertValue(parameterized, targetType, src);
    }

    boolean out = WritableResource.class.isAssignableFrom(targetType);

    if (src.equals(STD_STREAM_ARG)) {
        return (out ? new StandardOutputResource() : new StandardInputResource());
    }

    if (!ResourcePatternUtils.isUrl(src) && !StringUtils.startsWithAny(src, ResourceUtils.FILE_URL_PREFIX, ResourceUtils.JAR_URL_PREFIX)) {
        src = ResourceUtils.FILE_URL_PREFIX + src;
    }

    try {
        ResourceSource resourceSrc = CliValidatorServiceImpl.this.resourceSrcResolver.resolve(src);

        if (resourceSrc == null) {
            throw new CliValidatorException(String.format("Unable to resolve resource: path=%s", src));
        }

        return resourceSrc.getResource();
    } catch (IOException e) {
        throw new CliValidatorException(String.format("Unable to parse resource command line option (names=[%s], value=%s).",
            StringUtils.join(parameterized.getWrappedParameter().names(), ", "), src), e);
    }
}
项目:geowave    文件:TranslationEntry.java   
protected TranslationEntry(
        Parameterized param,
        Object object,
        String prefix,
        AnnotatedElement member ) {
    this.param = param;
    this.object = object;
    this.prefix = prefix;
    this.member = member;
    this.prefixedNames = addPrefixToNames();
}
项目:jpmml-evaluator    文件:ParameterOrderComparator.java   
private int getParameterOrder(ParameterDescription parameterDescription){
    Field field;

    try {
        field = Parameterized.class.getDeclaredField("m_field");
    } catch(NoSuchFieldException nsfe){
        throw new RuntimeException(nsfe);
    }

    Field parameterField;

    try {
        Parameterized parameterized = parameterDescription.getParameterized();

        if(!field.isAccessible()){
            field.setAccessible(true);
        }

        parameterField = (Field)field.get(parameterized);
    } catch(IllegalAccessException iae){
        throw new RuntimeException(iae);
    }

    if(parameterField != null){
        ParameterOrder parameterOrder = parameterField.getAnnotation(ParameterOrder.class);

        if(parameterOrder != null){
            return parameterOrder.value();
        }
    }

    return -1;
}
项目:geowave    文件:TranslationEntry.java   
public Parameterized getParam() {
    return param;
}