- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中org.onosproject.yang.compiler.datamodel.utils.YangConstructType
类的一些代码示例,展示了YangConstructType
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YangConstructType
类的具体详情如下:
包路径:org.onosproject.yang.compiler.datamodel.utils.YangConstructType
类名称:YangConstructType
[英]Represents ENUM to represent the type of data in parse tree.
[中]表示枚举以表示解析树中的数据类型。
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Validates identifier and returns concatenated string if string contains plus symbol.
*
* @param identifier string from yang file
* @param yangConstruct yang construct for creating error message=
* @return concatenated string after removing double quotes
*/
public static String getValidIdentifier(String identifier, YangConstructType yangConstruct) {
if (identifier.length() > IDENTIFIER_LENGTH) {
throw new LinkerException("YANG file error : " +
getYangConstructType(yangConstruct) + " name " + identifier + " is " +
"greater than 64 characters.");
} else if (!IDENTIFIER_PATTERN.matcher(identifier).matches()) {
throw new LinkerException("YANG file error : " +
getYangConstructType(yangConstruct) + " name " + identifier + " is not " +
"valid.");
} else if (identifier.toLowerCase().startsWith(XML)) {
throw new LinkerException("YANG file error : " +
getYangConstructType(yangConstruct) + " identifier " + identifier +
" must not start with (('X'|'x') ('M'|'m') ('L'|'l')).");
} else {
return identifier;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Throws parser exception for unsupported YANG constructs.
*
* @param type construct type
* @param ctx construct context
* @param errorInfo error msg
* @param fileName YANG file name
* @param identifier identifier of the node
*/
public static void handleUnsupportedYangConstruct(YangConstructType type,
ParserRuleContext ctx,
String errorInfo,
String fileName,
String identifier) {
StringBuilder b = new StringBuilder();
int lineNumber = ctx.getStart().getLine();
int charPostion = ctx.getStart().getCharPositionInLine();
b.append(YANG_FILE_ERROR).append(QUOTES).append(
getYangConstructType(type)).append(SPACE).append(identifier)
.append(QUOTES).append(AT).append(LINE_NUMBER)
.append(lineNumber).append(AT).append(CHARACTER_POSITION)
.append(charPostion).append(IN).append(FILE)
.append(fileName).append(errorInfo);
log.info(b.toString());
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
+ getYangConstructType(yangConstructType);
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Checks if a rule occurrences is as per the expected YANG grammar's
* cardinality.
*
* @param childContext child's context
* @param yangChildConstruct child construct for whom cardinality is to be
* validated
* @param yangParentConstruct parent construct
* @param parentName parent name
* @throws ParserException exception if cardinality check fails
*/
public static void validateCardinalityMaxOne(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName)
throws ParserException {
if (!childContext.isEmpty() && childContext.size() != 1) {
ParserException parserException = new ParserException("YANG file error: \""
+ getYangConstructType(yangChildConstruct) + "\" is defined more than once in \""
+ getYangConstructType(yangParentConstruct) + " " + parentName + "\".");
Iterator<?> context = childContext.iterator();
parserException.setLine(((ParserRuleContext) context.next()).getStart().getLine());
parserException.setCharPosition(((ParserRuleContext) context.next()).getStart().getCharPositionInLine());
throw parserException;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Checks if a either of one construct occurrence.
*
* @param child1Context first optional child's context
* @param yangChild1Construct first child construct for whom cardinality is
* to be validated
* @param child2Context second optional child's context
* @param yangChild2Construct second child construct for whom cardinality is
* to be validated
* @param yangParentConstruct parent construct
* @param parentName parent name
* @param parentContext parents's context
* @throws ParserException exception if cardinality check fails
*/
public static void validateCardinalityEitherOne(List<?> child1Context, YangConstructType yangChild1Construct,
List<?> child2Context, YangConstructType yangChild2Construct,
YangConstructType yangParentConstruct, String parentName,
ParserRuleContext parentContext)
throws ParserException {
if (child1Context.isEmpty() && child2Context.isEmpty()) {
ParserException parserException = new ParserException("YANG file error: Either \""
+ getYangConstructType(yangChild1Construct) + "\" or \"" + getYangConstructType(yangChild2Construct)
+ "\" should be present in \"" + getYangConstructType(yangParentConstruct) + " "
+ parentName + "\".");
parserException.setLine(parentContext.getStart().getLine());
parserException.setCharPosition(parentContext.getStart().getCharPositionInLine());
throw parserException;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
String error = "YANG file error: Either " + getYangConstructType(type1)
+ " or " + getYangConstructType(type2) + " should be present in "
+ getYangConstructType(type) + " " + parentName + ".";
ParserException parserException = new ParserException(error);
parserException.setLine(ctx.getStart().getLine());
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
getYangConstructType(yangConstruct) + " name " +
identifierString + " is " +
"greater than 64 characters.");
} else if (!IDENTIFIER_PATTERN.matcher(identifierString).matches()) {
parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) + " name " +
identifierString + " is not " +
"valid.");
} else if (identifierString.toLowerCase().startsWith(XML)) {
parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) + " identifier " +
identifierString +
" must not start with (('X'|'x') ('M'|'m') ('L'|'l')).");
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
+ getYangConstructType(yangChildConstruct) + "\" in \"" + getYangConstructType(yangParentConstruct)
+ " " + parentName + "\".");
parserException.setLine(parentContext.getStart().getLine());
Iterator<?> childcontext = childContext.iterator();
ParserException parserException = new ParserException("YANG file error: \""
+ getYangConstructType(yangChildConstruct) + "\" is present more than once in \""
+ getYangConstructType(yangParentConstruct) + " " + parentName + "\".");
parserException.setLine(((ParserRuleContext) childcontext.next()).getStart().getLine());
parserException.setCharPosition(((ParserRuleContext) childcontext.next()).getStart()
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Checks if a rule occurrences is minimum 1.
*
* @param childContext child's context
* @param yangChildConstruct child construct for whom cardinality is to be
* validated
* @param yangParentConstruct parent construct
* @param parentName parent name
* @param parentContext parents's context
* @throws ParserException exception if cardinality check fails
*/
public static void validateCardinalityNonZero(List<?> childContext, YangConstructType yangChildConstruct,
YangConstructType yangParentConstruct, String parentName,
ParserRuleContext parentContext)
throws ParserException {
if (childContext.isEmpty()) {
ParserException parserException = new ParserException("YANG file error: Missing \""
+ getYangConstructType(yangChildConstruct) + "\" in \"" + getYangConstructType(yangParentConstruct)
+ " " + parentName + "\".");
parserException.setLine(parentContext.getStart().getLine());
parserException.setCharPosition(parentContext.getStart().getCharPositionInLine());
throw parserException;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
new ParserException("YANG file error : " + getYangConstructType(yangConstructType) +
" name " + argumentString + "is not valid");
parserException.setLine(ctx.getStart().getLine());
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Checks and return valid prefix.
*
* @param inputString string from yang file
* @param yangConstruct yang construct for creating error message
* @param ctx yang construct's context to get the line number and character position
* @return valid prefix
*/
public static String getValidPrefix(String inputString,
YangConstructType yangConstruct, ParserRuleContext ctx) {
String tmpPrefixString = removeQuotesAndHandleConcat(inputString);
String[] tmpData = tmpPrefixString.split(Pattern.quote(COLON));
if (tmpData.length == 2) {
return tmpData[0];
} else {
ParserException parserException =
new ParserException("YANG file error : " + getYangConstructType(yangConstruct) +
" name " + inputString + " is not valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Validates and return the valid pattern.
*
* @param ctx context object
* @return validated string
*/
private static String getValidPattern(PatternStatementContext ctx) {
List<TerminalNode> patternList = ctx.string().STRING();
StringBuilder inputPat = new StringBuilder();
String compile;
for (TerminalNode pattern : patternList) {
inputPat.append(pattern.getText());
}
compile = inputPat.toString().replaceAll("[\'\"]", EMPTY_STRING);
try {
Pattern.compile(compile);
} catch (PatternSyntaxException e) {
ParserException exc = new ParserException(
"YANG file error : " + getYangConstructType(PATTERN_DATA)
+ " name " + ctx.string().getText()
+ " is not a valid regular expression");
exc.setLine(ctx.getStart().getLine());
exc.setCharPosition(ctx.getStart().getCharPositionInLine());
throw exc;
}
return compile;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
/**
* Validates boolean value.
*
* @param booleanValue value to be validated
* @param yangConstruct yang construct for creating error message
* @param ctx context object of the grammar rule
* @return boolean value either true or false
*/
public static boolean getValidBooleanValue(String booleanValue, YangConstructType yangConstruct,
ParserRuleContext ctx) {
String value = removeQuotesAndHandleConcat(booleanValue);
if (value.equals(TRUE)) {
return true;
} else if (value.equals(FALSE)) {
return false;
} else {
ParserException parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) +
" value " + value + " is not valid.");
parserException.setLine(ctx.getStart().getLine());
parserException.setCharPosition(ctx.getStart().getCharPositionInLine());
throw parserException;
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-linker
/**
* Checks and return valid node identifier.
*
* @param nodeIdentifierString string from yang file
* @param yangConstruct yang construct for creating error message
* @return valid node identifier
*/
static YangNodeIdentifier getValidNodeIdentifier(String nodeIdentifierString,
YangConstructType yangConstruct) {
String[] tmpData = nodeIdentifierString.split(Pattern.quote(COLON));
if (tmpData.length == 1) {
YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier();
nodeIdentifier.setName(getValidIdentifier(tmpData[0], yangConstruct));
return nodeIdentifier;
} else if (tmpData.length == 2) {
YangNodeIdentifier nodeIdentifier = new YangNodeIdentifier();
nodeIdentifier.setPrefix(getValidIdentifier(tmpData[0], yangConstruct));
nodeIdentifier.setName(getValidIdentifier(tmpData[1], yangConstruct));
return nodeIdentifier;
} else {
throw new LinkerException("YANG file error : " +
getYangConstructType(yangConstruct) + " name " +
nodeIdentifierString + " is not valid.");
}
}
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
if (!INTEGER_PATTERN.matcher(value).matches()) {
ParserException parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) +
" value " + value + " is not valid.");
parserException.setLine(ctx.getStart().getLine());
} catch (NumberFormatException e) {
ParserException parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) +
" value " + value + " is not valid.");
parserException.setLine(ctx.getStart().getLine());
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
if (!value.matches(NON_NEGATIVE_INTEGER_PATTERN)) {
ParserException parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) +
" value " + value + " is not valid.");
parserException.setLine(ctx.getStart().getLine());
} catch (NumberFormatException e) {
ParserException parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) +
" value " + value + " is not valid.");
parserException.setLine(ctx.getStart().getLine());
代码示例来源:origin: org.onosproject/onos-yang-compiler-datamodel
"YANG file error : " + getYangConstructType(conType) +
SPACE + rangeArg + " is not valid.");
ex.setLine(line);
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
} catch (NumberFormatException e) {
ParserException parserException = new ParserException("YANG file error : " +
YangConstructType.getYangConstructType(
MAX_ELEMENT_DATA) + " value " +
value + " is not " +
YangConstructType.getYangConstructType(
MAX_ELEMENT_DATA) + " value " +
value + " is not " +
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
} else {
ParserException parserException = new ParserException("YANG file error : " +
getYangConstructType(yangConstruct) +
" name " + nodeIdentifierString +
" is not valid.");
代码示例来源:origin: org.onosproject/onos-yang-compiler-parser
getYangConstructType(STATUS_DATA) + " " + ctx.status().getText() +
" is not valid.");
parserException.setLine(ctx.getStart().getLine());
本文整理了Java中org.onosproject.yang.compiler.datamodel.utils.YangConstructType.getYangConstructType()方法的一
我是一名优秀的程序员,十分优秀!