uk.co.real_logic.sbe.xml.XmlSchemaParser.handleError()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(9.7k)|赞(0)|评价(0)|浏览(46)

本文整理了Java中uk.co.real_logic.sbe.xml.XmlSchemaParser.handleError()方法的一些代码示例,展示了XmlSchemaParser.handleError()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。XmlSchemaParser.handleError()方法的具体详情如下:
包路径:uk.co.real_logic.sbe.xml.XmlSchemaParser
类名称:XmlSchemaParser
方法名:handleError

XmlSchemaParser.handleError介绍

[英]Handle an error condition as consequence of parsing.
[中]作为解析的结果处理错误条件。

代码示例

代码示例来源:origin: real-logic/simple-binary-encoding

private static void validateBlockLength(
  final Node node, final long specifiedBlockLength, final long computedBlockLength)
{
  if (0 != specifiedBlockLength && computedBlockLength > specifiedBlockLength)
  {
    final String msg = "specified blockLength provides insufficient space " +
      computedBlockLength + " > " + specifiedBlockLength;
    handleError(node, msg);
  }
}

代码示例来源:origin: real-logic/simple-binary-encoding

private Type addType(final Node subTypeNode, final String name, final Type type)
{
  if (containedTypeByNameMap.put(name, type) != null)
  {
    XmlSchemaParser.handleError(subTypeNode, "composite already contains a type named: " + name);
  }
  return type;
}

代码示例来源:origin: real-logic/simple-binary-encoding

private void validateValueRef(final Node node, final Map<String, Type> typeByNameMap)
{
  final int periodIndex = valueRef.indexOf('.');
  if (periodIndex < 1 || periodIndex == (valueRef.length() - 1))
  {
    handleError(node, "valueRef format not valid (enum-name.valid-value-name): " + valueRef);
  }
  final String valueRefType = valueRef.substring(0, periodIndex);
  final Type valueType = typeByNameMap.get(valueRefType);
  if (null == valueType)
  {
    handleError(node, "valueRef for enum name not found: " + valueRefType);
  }
  if (valueType instanceof EnumType)
  {
    final EnumType enumType = (EnumType)valueType;
    final String validValueName = valueRef.substring(periodIndex + 1);
    if (null == enumType.getValidValue(validValueName))
    {
      handleError(node, "valueRef for validValue name not found: " + validValueName);
    }
  }
  else
  {
    handleError(node, "valueRef for is not of type enum: " + valueRefType);
  }
}

代码示例来源:origin: real-logic/simple-binary-encoding

XmlSchemaParser.handleError(node, "valueRef not found: " + valueRefType);
  return null;
if (enumType.encodingType() != primitiveType)
  handleError(node, "valueRef does not match this type: " + valueRef);
  return null;
  handleError(node, "valueRef for validValue name not found: " + validValueName);
  return null;

代码示例来源:origin: real-logic/simple-binary-encoding

XmlSchemaParser.handleError(node, "composite for variable length data encoding must have \"length\"");
if (!isUnsigned(primitiveType))
  XmlSchemaParser.handleError(node, "\"length\" must be unsigned type");
XmlSchemaParser.handleError(
  node, "composite for variable length data encoding cannot have presence=\"optional\"");
XmlSchemaParser.handleError(node, "composite for variable length data encoding must have \"varData\"");

代码示例来源:origin: real-logic/simple-binary-encoding

!semanticType.equals(type.semanticType()))
handleError(node, "Mismatched semanticType on type and field: " + name);
  handleError(node, "valueRef not set for constant enum");
      handleError(node, "valueRef does not match field type: " + valueRef);
    handleError(node, "valueRef does not match field type: " + valueRef);
  handleError(node, "valueRef for enum name not found: " + valueRefType);

代码示例来源:origin: real-logic/simple-binary-encoding

/**
 * Check the composite for any specified offsets and validate they are correctly specified.
 *
 * @param node of the XML for this composite
 */
public void checkForValidOffsets(final Node node)
{
  int offset = 0;
  for (final Type edt : containedTypeByNameMap.values())
  {
    final int offsetAttribute = edt.offsetAttribute();
    if (-1 != offsetAttribute)
    {
      if (offsetAttribute < offset)
      {
        XmlSchemaParser.handleError(
          node,
          String.format("composite element \"%s\" has incorrect offset specified", edt.name()));
      }
      offset = offsetAttribute;
    }
    offset += edt.encodedLength();
  }
}

代码示例来源:origin: real-logic/simple-binary-encoding

private static void validateGroupMaxValue(
  final Node node, final PrimitiveType primitiveType, final PrimitiveValue value)
{
  if (null != value)
  {
    final long longValue = value.longValue();
    final long allowedValue = primitiveType.maxValue().longValue();
    if (longValue > allowedValue)
    {
      XmlSchemaParser.handleError(node, String.format(
        "maxValue greater than allowed for type: maxValue=%d allowed=%d", longValue, allowedValue));
    }
    final long maxInt = INT32.maxValue().longValue();
    if (primitiveType == UINT32 && longValue > maxInt)
    {
      XmlSchemaParser.handleError(node, String.format(
        "maxValue greater than allowed for type: maxValue=%d allowed=%d", longValue, maxInt));
    }
  }
  else if (primitiveType == UINT32)
  {
    final long maxInt = INT32.maxValue().longValue();
    XmlSchemaParser.handleError(node, String.format(
      "maxValue must be set for varData UINT32 type: max value allowed=%d", maxInt));
  }
}

代码示例来源:origin: real-logic/simple-binary-encoding

if (dataEncountered)
    handleError(node, "group node specified after data node");
  if (groupEncountered || dataEncountered)
    handleError(node, "field node specified after group or data node specified");
handleError(node, "duplicate id found: " + field.id());
handleError(node, "duplicate name found: " + field.name());

代码示例来源:origin: real-logic/simple-binary-encoding

XmlSchemaParser.handleError(node, "composite for message header must have \"blockLength\"");
XmlSchemaParser.handleError(node, "\"blockLength\" must be unsigned");
XmlSchemaParser.handleError(node, "composite for message header must have \"templateId\"");
XmlSchemaParser.handleError(node, "composite for message header must have \"schemaId\"");
XmlSchemaParser.handleError(node, "composite for message header must have \"version\"");

代码示例来源:origin: real-logic/simple-binary-encoding

private static void addMessageWithIdCheck(
  final ObjectHashSet<String> distinctNames,
  final Map<Long, Message> messageByIdMap,
  final Message message,
  final Node node)
{
  if (messageByIdMap.get((long)message.id()) != null)
  {
    handleError(node, "message template id already exists: " + message.id());
  }
  if (!distinctNames.add(message.name()))
  {
    handleError(node, "message name already exists: " + message.name());
  }
  checkForValidName(node, message.name());
  messageByIdMap.put((long)message.id(), message);
}

代码示例来源:origin: real-logic/simple-binary-encoding

handleError(node, "length of " + length + " is less than provided value: " + nodeValue);

代码示例来源:origin: real-logic/simple-binary-encoding

XmlSchemaParser.handleError(subTypeNode, "ref type not found: " + refTypeName);
  XmlSchemaParser.handleError(refTypeNode, "ref types cannot create circular dependencies.");
  throw new IllegalStateException("ref types cannot create circular dependencies");

代码示例来源:origin: real-logic/simple-binary-encoding

handleError(node, "nullValue set, but presence is not optional");
handleError(node, "presence optional but no null value found");
nullValue = null;

代码示例来源:origin: real-logic/simple-binary-encoding

handleError(node, "valueRef format not valid (enum-name.valid-value-name): " + valueRef);
handleError(node, "present must be constant when valueRef is set: " + valueRef);
  handleError(node, "type has declared presence as \"constant\" but XML node has no data");
  constValue = null;

代码示例来源:origin: real-logic/simple-binary-encoding

XmlSchemaParser.handleError(node, "composite for group encodedLength encoding must have \"blockLength\"");
XmlSchemaParser.handleError(node, "\"blockLength\" must be unsigned type");
XmlSchemaParser.handleError(node, "composite for group encodedLength encoding must have \"numInGroup\"");
if (null == numInGroupMinValue)
  XmlSchemaParser.handleError(node, "\"numInGroup\" minValue must be set for signed types");
  XmlSchemaParser.handleError(node, String.format(
    "\"numInGroup\" minValue=%s must be greater than zero " +
    "for signed \"numInGroup\" types", numInGroupMinValue));
    XmlSchemaParser.handleError(node, String.format(
      "\"numInGroup\" minValue=%s greater than maxValue=%d", numInGroupMinValue, max));

代码示例来源:origin: real-logic/simple-binary-encoding

if (dimensionType == null)
  handleError(node, "could not find dimensionType: " + dimensionTypeName);
  handleError(node, "dimensionType should be a composite type: " + dimensionTypeName);
  dimensionType = null;

代码示例来源:origin: real-logic/simple-binary-encoding

if (fieldType == null)
  handleError(node, "could not find type: " + typeName);
  handleError(node, "data type is not composite type: " + typeName);

代码示例来源:origin: real-logic/simple-binary-encoding

private Field parseField(final NodeList nodeList, final int nodeIndex)
{
  final Node node = nodeList.item(nodeIndex);
  final String typeName = getAttributeValue(node, "type");
  final Type fieldType = typeByNameMap.get(typeName);
  if (fieldType == null)
  {
    handleError(node, "could not find type: " + typeName);
  }
  final Field field = new Field.Builder()
    .name(getAttributeValue(node, "name"))
    .description(getAttributeValueOrNull(node, "description"))
    .id(Integer.parseInt(getAttributeValue(node, "id")))
    .offset(Integer.parseInt(getAttributeValue(node, "offset", "0")))
    .semanticType(getAttributeValueOrNull(node, "semanticType"))
    .presence(getPresence(node, fieldType))
    .valueRef(getAttributeValueOrNull(node, "valueRef"))
    .sinceVersion(Integer.parseInt(getAttributeValue(node, "sinceVersion", "0")))
    .deprecated(Integer.parseInt(getAttributeValue(node, "deprecated", "0")))
    .epoch(getAttributeValueOrNull(node, "epoch"))
    .timeUnit(getAttributeValueOrNull(node, "timeUnit"))
    .type(fieldType)
    .build();
  field.validate(node, typeByNameMap);
  return field;
}

代码示例来源:origin: real-logic/simple-binary-encoding

handleError(node, "Offset provides insufficient space at field: " + field.name());

相关文章