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


Java EndpointValidationResult类代码示例

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


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

示例1: getErrorMessage

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
@Override
public String getErrorMessage(EndpointValidationResult result, Map.Entry<String, String> entry) {
    String name = entry.getKey();
    String[] choices = result.getInvalidEnumChoices().get(name);
    String defaultValue = result.getDefaultValues() != null ? result.getDefaultValues().get(entry.getKey()) : null;
    String str = Arrays.asList(choices).toString();
    String msg = "Invalid enum value: " + entry.getValue() + ". Possible values: " + str;
    if (result.getInvalidEnumChoices() != null) {
        String[] suggestions = result.getInvalidEnumChoices().get(name);
        if (suggestions != null && suggestions.length > 0) {
            str = Arrays.asList(suggestions).toString();
            msg += ". Did you mean: " + str;
        }
    }
    if (defaultValue != null) {
        msg += ". Default value: " + defaultValue;
    }
    return msg;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:20,代码来源:CamelEndpointAnnotator.java

示例2: getErrorMessage

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
@Override
public String getErrorMessage(EndpointValidationResult result, Map.Entry<String, String> entry) {
    String name = entry.getKey();
    String[] choices = result.getInvalidEnumChoices().get(name);
    String defaultValue = result.getDefaultValues() != null ? result.getDefaultValues().get(entry.getKey()) : null;
    String str = Arrays.asList(choices).toString();
    String msg = name + " has invalid enum value: " + entry.getValue() + ". Possible values: " + str;
    if (result.getInvalidEnumChoices() != null) {
        String[] suggestions = result.getInvalidEnumChoices().get(name);
        if (suggestions != null && suggestions.length > 0) {
            str = Arrays.asList(suggestions).toString();
            msg += ". Did you mean: " + str;
        }
    }
    if (defaultValue != null) {
        msg += ". Default value: " + defaultValue;
    }
    return msg;
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:20,代码来源:AbstractCamelInspection.java

示例3: extractSetValue

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
private void extractSetValue(EndpointValidationResult result, Set<String> validationSet, String fromElement, PsiElement element,
                             AnnotationHolder holder, CamelAnnotatorEndpointMessage msg, boolean lenient) {
    if (validationSet != null && (lenient || !result.isSuccess())) {

        for (String entry : validationSet) {
            String propertyValue = entry;

            int startIdxQueryParameters = fromElement.indexOf("?" + propertyValue);
            startIdxQueryParameters = (startIdxQueryParameters == -1) ? fromElement.indexOf("&" + propertyValue) : fromElement.indexOf("?");

            int propertyIdx = fromElement.indexOf(propertyValue, startIdxQueryParameters);
            int propertyLength = propertyValue.length();

            propertyIdx = getIdeaUtils().isJavaLanguage(element) || getIdeaUtils().isXmlLanguage(element)  ? propertyIdx + 1  : propertyIdx;

            TextRange range = new TextRange(element.getTextRange().getStartOffset() + propertyIdx,
                element.getTextRange().getStartOffset() + propertyIdx + propertyLength);

            if (msg.isInfoLevel()) {
                holder.createInfoAnnotation(range, summaryMessage(result, propertyValue, msg));
            } else if (msg.isWarnLevel()) {
                holder.createWarningAnnotation(range, summaryMessage(result, propertyValue, msg));
            } else {
                holder.createErrorAnnotation(range, summaryMessage(result, propertyValue, msg));
            }
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:29,代码来源:CamelEndpointAnnotator.java

示例4: extractMapValue

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
private void extractMapValue(EndpointValidationResult result, Map<String, String> validationMap,
                             String fromElement, @NotNull PsiElement element, @NotNull AnnotationHolder holder, CamelAnnotatorEndpointMessage msg) {
    if ((!result.isSuccess()) && validationMap != null) {

        for (Map.Entry<String, String> entry : validationMap.entrySet()) {
            String propertyValue = entry.getValue();
            String propertyKey = entry.getKey();
            int startIdxQueryParameters = fromElement.indexOf("?");

            int propertyIdx = fromElement.indexOf(propertyKey, startIdxQueryParameters);
            int startIdx = propertyIdx;

            int equalsSign = fromElement.indexOf("=", propertyIdx);

            if (equalsSign > 0) {
                startIdx = equalsSign + 1;
            }

            int propertyLength = propertyValue.isEmpty() ? propertyKey.length() : propertyValue.length();
            propertyLength = element instanceof XmlToken ? propertyLength - 1 : propertyLength;

            startIdx = propertyValue.isEmpty() ? propertyIdx + 1 : fromElement.indexOf(propertyValue, startIdx) + 1;
            startIdx = getIdeaUtils().isJavaLanguage(element) || getIdeaUtils().isXmlLanguage(element) ? startIdx  : startIdx - 1;

            TextRange range = new TextRange(element.getTextRange().getStartOffset() + startIdx,
                element.getTextRange().getStartOffset() + startIdx + propertyLength);
            holder.createErrorAnnotation(range, summaryMessage(result, entry, msg));
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:31,代码来源:CamelEndpointAnnotator.java

示例5: summaryMessage

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
/**
 * A human readable summary of the validation.
 *
 * @return the summary, or <tt>empty</tt> if no validation errors
 */
@SuppressWarnings("unchecked")
private <T> String summaryMessage(EndpointValidationResult result, T entry, CamelAnnotatorEndpointMessage msg) {
    if (result.getIncapable() != null) {
        return "Incapable of parsing uri: " + result.getIncapable();
    } else if (result.getSyntaxError() != null) {
        return "Syntax error: " + result.getSyntaxError();
    } else if (result.getUnknownComponent() != null) {
        return "Unknown component: " + result.getUnknownComponent();
    }

    return msg.getErrorMessage(result, entry);
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:18,代码来源:CamelEndpointAnnotator.java

示例6: extractSetValue

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
private void extractSetValue(EndpointValidationResult result, Set<String> validationSet,
                             String fromElement, PsiElement element, final @NotNull ProblemsHolder holder,
                             boolean isOnTheFly, CamelAnnotatorEndpointMessage msg) {

    if ((!result.isSuccess()) && validationSet != null) {
        for (String entry : validationSet) {
            String desc = summaryErrorMessage(result, entry, msg);
            holder.registerProblem(element, desc);
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:12,代码来源:AbstractCamelInspection.java

示例7: extractMapValue

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
private void extractMapValue(EndpointValidationResult result, Map<String, String> validationMap,
                             String fromElement, @NotNull PsiElement element, final @NotNull ProblemsHolder holder,
                             boolean isOnTheFly, CamelAnnotatorEndpointMessage msg) {

    if ((!result.isSuccess()) && validationMap != null) {
        for (Map.Entry<String, String> entry : validationMap.entrySet()) {
            String desc = summaryErrorMessage(result, entry, msg);
            holder.registerProblem(element, desc);
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:12,代码来源:AbstractCamelInspection.java

示例8: summaryErrorMessage

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
/**
 * A human readable summary of the validation errors.
 *
 * @return the summary, or <tt>empty</tt> if no validation errors
 */
@SuppressWarnings("unchecked")
private <T> String summaryErrorMessage(EndpointValidationResult result, T entry, CamelAnnotatorEndpointMessage msg) {
    if (result.getIncapable() != null) {
        return "Incapable of parsing uri: " + result.getIncapable();
    } else if (result.getSyntaxError() != null) {
        return "Syntax error: " + result.getSyntaxError();
    } else if (result.getUnknownComponent() != null) {
        return "Unknown component: " + result.getUnknownComponent();
    }

    return msg.getErrorMessage(result, entry);
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:18,代码来源:AbstractCamelInspection.java

示例9: validateProperties

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
@Test
public void validateProperties() throws Exception {
    // spell typo error
    EndpointValidationResult result = catalog.validateEndpointProperties("log:mylog?levl=WARN");
    assertFalse(result.isSuccess());
    assertTrue(result.getUnknown().contains("levl"));
    assertEquals("level", result.getUnknownSuggestions().get("levl")[0]);
    assertEquals(1, result.getNumberOfErrors());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:10,代码来源:CamelCatalogLuceneTest.java

示例10: validateText

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
/**
 * Validate endpoint options list aka properties. eg "timer:trigger?delay=1000&bridgeErrorHandler=true"
 * if the URI is not valid a error annotation is created and highlight the invalid value.
 */
void validateText(@NotNull PsiElement element, @NotNull AnnotationHolder holder, @NotNull String uri) {
    if (QueryUtils.isQueryContainingCamelComponent(element.getProject(), uri)) {
        CamelCatalog catalogService = ServiceManager.getService(element.getProject(), CamelCatalogService.class).get();

        IElementType type = element.getNode().getElementType();
        LOG.trace("Element " + element + " of type: " + type + " to validate endpoint uri: " + uri);

        // skip special values such as configuring ActiveMQ brokerURL
        if (getCamelIdeaUtils().skipEndpointValidation(element)) {
            LOG.debug("Skipping element " + element + " for validation with text: " + uri);
            return;
        }

        // camel catalog expects &amp; as & when it parses so replace all &amp; as &
        String camelQuery = getIdeaUtils().getInnerText(uri);
        camelQuery = camelQuery.replaceAll("&amp;", "&");

        // strip up ending incomplete parameter
        if (camelQuery.endsWith("&") || camelQuery.endsWith("?")) {
            camelQuery = camelQuery.substring(0, camelQuery.length() - 1);
        }

        boolean stringFormat = getCamelIdeaUtils().isFromStringFormatEndpoint(element);
        if (stringFormat) {
            // if the node is fromF or toF, then replace all %X with {{%X}} as we cannot parse that value
            camelQuery = camelQuery.replaceAll("%s", "\\{\\{\\%s\\}\\}");
            camelQuery = camelQuery.replaceAll("%d", "\\{\\{\\%d\\}\\}");
            camelQuery = camelQuery.replaceAll("%b", "\\{\\{\\%b\\}\\}");
        }

        boolean consumerOnly = getCamelIdeaUtils().isConsumerEndpoint(element);
        boolean producerOnly = getCamelIdeaUtils().isProducerEndpoint(element);

        try {
            CamelPreferenceService preference = getCamelPreferenceService();

            EndpointValidationResult result = catalogService.validateEndpointProperties(camelQuery, false, consumerOnly, producerOnly);

            extractMapValue(result, result.getInvalidBoolean(), uri, element, holder, new BooleanErrorMsg());
            extractMapValue(result, result.getInvalidEnum(), uri, element, holder, new EnumErrorMsg());
            extractMapValue(result, result.getInvalidInteger(), uri, element, holder, new IntegerErrorMsg());
            extractMapValue(result, result.getInvalidNumber(), uri, element, holder, new NumberErrorMsg());
            extractMapValue(result, result.getInvalidReference(), uri, element, holder, new ReferenceErrorMsg());
            extractSetValue(result, result.getUnknown(), uri, element, holder, new UnknownErrorMsg(), false);
            extractSetValue(result, result.getLenient(), uri, element, holder, new LenientOptionMsg(preference.isHighlightCustomOptions()), true);
            extractSetValue(result, result.getNotConsumerOnly(), uri, element, holder, new NotConsumerOnlyErrorMsg(), false);
            extractSetValue(result, result.getNotProducerOnly(), uri, element, holder, new NotProducerOnlyErrorMsg(), false);
        } catch (Throwable e) {
            LOG.warn("Error validating Camel endpoint: " + uri, e);
        }
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:57,代码来源:CamelEndpointAnnotator.java

示例11: validateEndpoint

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
private void validateEndpoint(@NotNull PsiElement element, final @NotNull ProblemsHolder holder, @NotNull String text, boolean isOnTheFly) {
    CamelCatalog catalogService = ServiceManager.getService(element.getProject(), CamelCatalogService.class).get();

    IElementType type = element.getNode().getElementType();
    LOG.trace("Element " + element + " of type: " + type + " to inspect endpoint uri: " + text);

    // skip special values such as configuring ActiveMQ brokerURL
    if (getCamelIdeaUtils().skipEndpointValidation(element)) {
        LOG.debug("Skipping element " + element + " for validation with text: " + text);
        return;
    }

    // camel catalog expects &amp; as & when it parses so replace all &amp; as &
    String camelQuery = text;
    camelQuery = camelQuery.replaceAll("&amp;", "&");

    // strip up ending incomplete parameter
    if (camelQuery.endsWith("&") || camelQuery.endsWith("?")) {
        camelQuery = camelQuery.substring(0, camelQuery.length() - 1);
    }

    boolean stringFormat = getCamelIdeaUtils().isFromStringFormatEndpoint(element);
    if (stringFormat) {
        // if the node is fromF or toF, then replace all %X with {{%X}} as we cannot parse that value
        camelQuery = camelQuery.replaceAll("%s", "\\{\\{\\%s\\}\\}");
        camelQuery = camelQuery.replaceAll("%d", "\\{\\{\\%d\\}\\}");
        camelQuery = camelQuery.replaceAll("%b", "\\{\\{\\%b\\}\\}");
    }

    boolean consumerOnly = getCamelIdeaUtils().isConsumerEndpoint(element);
    boolean producerOnly = getCamelIdeaUtils().isProducerEndpoint(element);

    try {
        EndpointValidationResult result = catalogService.validateEndpointProperties(camelQuery, false, consumerOnly, producerOnly);

        extractMapValue(result, result.getInvalidBoolean(), text, element, holder, isOnTheFly, new AbstractCamelInspection.BooleanErrorMsg());
        extractMapValue(result, result.getInvalidEnum(), text, element, holder, isOnTheFly, new AbstractCamelInspection.EnumErrorMsg());
        extractMapValue(result, result.getInvalidInteger(), text, element, holder, isOnTheFly, new AbstractCamelInspection.IntegerErrorMsg());
        extractMapValue(result, result.getInvalidNumber(), text, element, holder, isOnTheFly, new AbstractCamelInspection.NumberErrorMsg());
        extractMapValue(result, result.getInvalidReference(), text, element, holder, isOnTheFly, new AbstractCamelInspection.ReferenceErrorMsg());
        extractSetValue(result, result.getUnknown(), text, element, holder, isOnTheFly, new AbstractCamelInspection.UnknownErrorMsg());
        extractSetValue(result, result.getNotConsumerOnly(), text, element, holder, isOnTheFly, new AbstractCamelInspection.NotConsumerOnlyErrorMsg());
        extractSetValue(result, result.getNotProducerOnly(), text, element, holder, isOnTheFly, new AbstractCamelInspection.NotProducerOnlyErrorMsg());
    } catch (Throwable e) {
        LOG.warn("Error inspecting Camel endpoint: " + text, e);
    }
}
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:48,代码来源:AbstractCamelInspection.java

示例12: getErrorMessage

import org.apache.camel.catalog.EndpointValidationResult; //导入依赖的package包/类
/**
 * Return error messaged constructed to match the validation result.
 *
 * @param endpointValidationResult - The validation result return from the {@link org.apache.camel.catalog.CamelCatalog} validator
 * @param valueObj - The key and value object validated.
 */
String getErrorMessage(EndpointValidationResult endpointValidationResult, T valueObj);
 
开发者ID:camel-idea-plugin,项目名称:camel-idea-plugin,代码行数:8,代码来源:CamelAnnotatorEndpointMessage.java


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